ledger-core
RippleLikeTransactionApi.h
1 /*
2  *
3  * RippleLikeTransactionApi
4  *
5  * Created by El Khalil Bellakrid on 06/01/2019.
6  *
7  * The MIT License (MIT)
8  *
9  * Copyright (c) 2019 Ledger
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a copy
12  * of this software and associated documentation files (the "Software"), to deal
13  * in the Software without restriction, including without limitation the rights
14  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15  * copies of the Software, and to permit persons to whom the Software is
16  * furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in all
19  * copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27  * SOFTWARE.
28  *
29  */
30 
31 
32 #ifndef LEDGER_CORE_RIPPLELIKETRANSACTIONAPI_H
33 #define LEDGER_CORE_RIPPLELIKETRANSACTIONAPI_H
34 
35 #include <wallet/common/api_impl/OperationApi.h>
36 #include <wallet/ripple/api_impl/RippleLikeBlockApi.h>
37 
38 #include <api/RippleLikeMemo.hpp>
39 #include <api/RippleLikeTransaction.hpp>
40 #include <api/Amount.hpp>
41 #include <api/Currency.hpp>
42 #include <math/BigInt.h>
43 
44 namespace ledger {
45  namespace core {
47  public:
48  explicit RippleLikeTransactionApi(const api::Currency& currency);
49  explicit RippleLikeTransactionApi(const std::shared_ptr<OperationApi>& operation);
50 
51  std::string getHash() override;
52  std::shared_ptr<api::Amount> getFees() override ;
53  std::shared_ptr<api::RippleLikeAddress> getReceiver() override ;
54  std::shared_ptr<api::RippleLikeAddress> getSender() override;
55  std::shared_ptr<api::Amount> getValue() override;
56  std::vector<uint8_t> serialize() override;
57  std::chrono::system_clock::time_point getDate() override;
58  std::shared_ptr<api::BigInt> getSequence() override;
59  std::shared_ptr<api::BigInt> getLedgerSequence() override;
60  void setSignature(const std::vector<uint8_t> & rSignature, const std::vector<uint8_t> & sSignature) override ;
61  void setDERSignature(const std::vector<uint8_t> & signature) override;
62  std::vector<uint8_t> getSigningPubKey() override;
63  RippleLikeTransactionApi & setFees(const std::shared_ptr<BigInt>& fees);
64  RippleLikeTransactionApi & setValue(const std::shared_ptr<BigInt>& value);
65  RippleLikeTransactionApi & setSequence(const BigInt& sequence);
66  RippleLikeTransactionApi & setLedgerSequence(const BigInt& ledgerSequence);
67  RippleLikeTransactionApi & setSender(const std::shared_ptr<api::RippleLikeAddress> &sender);
68  RippleLikeTransactionApi & setReceiver(const std::shared_ptr<api::RippleLikeAddress> &receiver);
69  RippleLikeTransactionApi & setSigningPubKey(const std::vector<uint8_t> &pubKey);
70  RippleLikeTransactionApi & setHash(const std::string &hash);
71  RippleLikeTransactionApi & setDestinationTag(uint32_t tag);
72  std::vector<api::RippleLikeMemo> getMemos() override;
73  void addMemo(api::RippleLikeMemo const& memo) override;
75  private:
76  std::chrono::system_clock::time_point _time;
77  std::shared_ptr<RippleLikeBlockApi> _block;
78  std::string _hash;
79  api::Currency _currency;
80  std::shared_ptr<api::Amount> _fees;
81  std::shared_ptr<api::Amount> _value;
82  std::shared_ptr<api::BigInt> _sequence;
83  std::shared_ptr<api::BigInt> _ledgerSequence;
84  std::shared_ptr<api::RippleLikeAddress> _receiver;
85  std::shared_ptr<api::RippleLikeAddress> _sender;
86  std::vector<uint8_t> _rSignature;
87  std::vector<uint8_t> _sSignature;
88  std::vector<uint8_t> _signingPubKey;
89  std::vector<api::RippleLikeMemo> _memos;
90  Option<int64_t> _destinationTag;
91  };
92  }
93 }
94 
95 
96 #endif //LEDGER_CORE_RIPPLELIKETRANSACTIONAPI_H
std::shared_ptr< api::RippleLikeAddress > getReceiver() override
Definition: RippleLikeTransactionApi.cpp:124
std::shared_ptr< api::Amount > getValue() override
Definition: RippleLikeTransactionApi.cpp:132
std::shared_ptr< api::RippleLikeAddress > getSender() override
Definition: RippleLikeTransactionApi.cpp:128
void setSignature(const std::vector< uint8_t > &rSignature, const std::vector< uint8_t > &sSignature) override
Definition: RippleLikeTransactionApi.cpp:152
std::vector< api::RippleLikeMemo > getMemos() override
Definition: RippleLikeTransactionApi.cpp:371
Definition: RippleLikeTransaction.hpp:33
Definition: Currency.hpp:23
Definition: Account.cpp:8
Definition: RippleLikeMemo.hpp:18
std::experimental::optional< int64_t > getDestinationTag() override
Definition: RippleLikeTransactionApi.cpp:367
void addMemo(api::RippleLikeMemo const &memo) override
Definition: RippleLikeTransactionApi.cpp:375
std::vector< uint8_t > getSigningPubKey() override
Definition: RippleLikeTransactionApi.cpp:148
std::shared_ptr< api::Amount > getFees() override
Definition: RippleLikeTransactionApi.cpp:120
std::shared_ptr< api::BigInt > getSequence() override
Definition: RippleLikeTransactionApi.cpp:144
Definition: BigInt.h:56
std::string getHash() override
Definition: RippleLikeTransactionApi.cpp:116
std::chrono::system_clock::time_point getDate() override
Definition: RippleLikeTransactionApi.cpp:136
std::vector< uint8_t > serialize() override
Definition: RippleLikeTransactionApi.cpp:179
Definition: RippleLikeTransactionApi.h:46
std::shared_ptr< api::BigInt > getLedgerSequence() override
Definition: RippleLikeTransactionApi.cpp:140