ledger-core
BitcoinLikeBlockchainExplorer.hpp
1 /*
2  *
3  * BitcoinLikeBlockchainExplorer
4  * ledger-core
5  *
6  * Created by Pierre Pollastri on 17/01/2017.
7  *
8  * The MIT License (MIT)
9  *
10  * Copyright (c) 2016 Ledger
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy
13  * of this software and associated documentation files (the "Software"), to deal
14  * in the Software without restriction, including without limitation the rights
15  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16  * copies of the Software, and to permit persons to whom the Software is
17  * furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included in all
20  * copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  * SOFTWARE.
29  *
30  */
31 #ifndef LEDGER_CORE_BITCOINLIKEBLOCKCHAINEXPLORER_HPP
32 #define LEDGER_CORE_BITCOINLIKEBLOCKCHAINEXPLORER_HPP
33 
34 #include <string>
35 #include <chrono>
36 #include <vector>
37 
38 #include <api/Error.hpp>
39 #include <api/BigInt.hpp>
40 #include <async/Future.hpp>
41 #include <collections/collections.hpp>
42 #include <math/BigInt.h>
43 #include <utils/ConfigurationMatchable.h>
44 #include <utils/optional.hpp>
45 #include <utils/Option.hpp>
46 #include <wallet/common/explorers/AbstractBlockchainExplorer.h>
47 
48 namespace ledger {
49  namespace core {
51  uint64_t index;
52  Option<BigInt> value;
53  Option<std::string> previousTxHash;
54  Option<uint32_t> previousTxOutputIndex;
55  Option<std::string> address;
56  Option<std::string> signatureScript;
57  Option<std::string> coinbase;
58  uint32_t sequence;
59 
61  sequence = 0xFFFFFFFF;
62  };
63  };
64 
66  uint64_t index;
67  std::string transactionHash;
68  BigInt value;
69  Option<std::string> address;
70  Option<std::string> accountUid;
71  std::string script;
72  std::string time;
73  Option<uint64_t> blockHeight;
74 
76  };
77 
79  uint32_t version;
80  std::string hash;
81  std::chrono::system_clock::time_point receivedAt;
82  uint64_t lockTime;
83  Option<Block> block;
84  std::vector<BitcoinLikeBlockchainExplorerInput> inputs;
85  std::vector<BitcoinLikeBlockchainExplorerOutput> outputs;
86  Option<BigInt> fees;
87  uint64_t confirmations;
88 
90  version = 1;
91  confirmations = -1;
92  }
93 
95  this->confirmations = cpy.confirmations;
96  this->version = cpy.version;
97  this->outputs = cpy.outputs;
98  this->inputs = cpy.inputs;
99  this->receivedAt = cpy.receivedAt;
100  this->lockTime = cpy.lockTime;
101  this->fees = cpy.fees;
102  this->hash = cpy.hash;
103  this->block = cpy.block;
104  }
105  };
106 
108  public AbstractBlockchainExplorer<BitcoinLikeBlockchainExplorerTransaction> {
109  public:
110  typedef ledger::core::Block Block;
111  BitcoinLikeBlockchainExplorer(const std::shared_ptr<api::DynamicObject>& configuration,
112  const std::vector<std::string> &matchableKeys);
113 
114  virtual Future<std::vector<std::shared_ptr<api::BigInt>>> getFees() = 0;
115 
116  };
117  }
118 }
119 
120 #endif //LEDGER_CORE_BITCOINLIKEBLOCKCHAINEXPLORER_HPP
Definition: BitcoinLikeBlockchainExplorer.hpp:78
Definition: BitcoinLikeBlockchainExplorer.hpp:65
Definition: Option.hpp:49
Definition: AbstractBlockchainExplorer.h:48
Definition: Deffered.hpp:49
Definition: BitcoinLikeBlockchainExplorer.hpp:107
Definition: ConfigurationMatchable.h:38
Definition: BitcoinLikeBlockchainExplorer.hpp:50
Definition: Account.cpp:8
Definition: BigInt.h:56
Definition: Block.h:40