iota.lib.cpp
IOTA C++ Library
core.hpp
1 //
2 // MIT License
3 //
4 // Copyright (c) 2017-2018 Thibault Martinez and Simon Ninon
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //
24 //
25 
26 #pragma once
27 
28 #include <iota/api/responses/fwd.hpp>
29 #include <iota/api/service.hpp>
30 #include <iota/models/address.hpp>
31 #include <iota/models/tag.hpp>
32 
33 namespace IOTA {
34 
35 namespace API {
36 
43 class Core {
44 public:
53  explicit Core(const std::string& host, const uint16_t& port, bool localPow = true,
54  int timeout = 60);
58  virtual ~Core() = default;
59 
60 public:
69 
79 
90  Responses::AddNeighbors addNeighbors(const std::vector<std::string>& uris) const;
91 
102  Responses::RemoveNeighbors removeNeighbors(const std::vector<std::string>& uris) const;
103 
111  Responses::GetTips getTips() const;
112 
129  Responses::FindTransactions findTransactions(const std::vector<Models::Address>& addresses,
130  const std::vector<Models::Tag>& tags,
131  const std::vector<Types::Trytes>& approvees,
132  const std::vector<Types::Trytes>& bundles) const;
133 
144  Responses::GetTrytes getTrytes(const std::vector<Types::Trytes>& hashes) const;
145 
160  Responses::GetInclusionStates getInclusionStates(const std::vector<Types::Trytes>& transactions,
161  const std::vector<Types::Trytes>& tips) const;
162 
178  Responses::GetBalances getBalances(const std::vector<Models::Address>& addresses,
179  const int& threshold = 100,
180  const std::vector<Types::Trytes>& tips = {}) const;
181 
197  const int& depth, const Types::Trytes& reference = "") const;
198 
218  Responses::AttachToTangle attachToTangle(const Types::Trytes& trunkTransaction,
219  const Types::Trytes& branchTransaction,
220  const int& minWeightMagnitude,
221  const std::vector<Types::Trytes>& trytes) const;
222 
231 
242  Responses::Base broadcastTransactions(const std::vector<Types::Trytes>& trytes) const;
243 
254  Responses::Base storeTransactions(const std::vector<Types::Trytes>& trytes) const;
255 
266  const std::vector<Models::Address>& addresses) const;
267 
268  /*
269  * Used to ensure tail resolves to a consistent ledger which is necessary to validate before
270  * attempting promotion. Checks transaction hashes for promotability.
271  *
272  * This is called with a pending transaction (or more of them) and it will tell you if it is still
273  * possible for this transaction (or all the transactions simultaneously if you give more than
274  * one) to be confirmed, or not (because it conflicts with another already confirmed transaction).
275  *
276  * https://iota.readme.io/reference#checkconsistency
277  *
278  * @param tails Tails to check consistency.
279  *
280  * @return The response.
281  */
282  Responses::CheckConsistency checkConsistency(const std::vector<Types::Trytes>& tails) const;
283 
284 private:
288  Service service_;
292  bool localPow_;
293 };
294 
295 } // namespace API
296 
297 } // namespace IOTA
Responses::FindTransactions findTransactions(const std::vector< Models::Address > &addresses, const std::vector< Models::Tag > &tags, const std::vector< Types::Trytes > &approvees, const std::vector< Types::Trytes > &bundles) const
virtual ~Core()=default
Responses::GetNodeInfo getNodeInfo() const
Definition: attach_to_tangle.hpp:51
Responses::WereAddressesSpentFrom wereAddressesSpentFrom(const std::vector< Models::Address > &addresses) const
Definition: get_node_info.hpp:44
Definition: get_balances.hpp:49
Responses::AddNeighbors addNeighbors(const std::vector< std::string > &uris) const
Definition: find_transactions.hpp:47
Responses::Base interruptAttachingToTangle() const
Core(const std::string &host, const uint16_t &port, bool localPow=true, int timeout=60)
Responses::AttachToTangle attachToTangle(const Types::Trytes &trunkTransaction, const Types::Trytes &branchTransaction, const int &minWeightMagnitude, const std::vector< Types::Trytes > &trytes) const
Definition: get_neighbors.hpp:45
Responses::Base storeTransactions(const std::vector< Types::Trytes > &trytes) const
Responses::GetTrytes getTrytes(const std::vector< Types::Trytes > &hashes) const
Definition: get_transactions_to_approve.hpp:47
Responses::RemoveNeighbors removeNeighbors(const std::vector< std::string > &uris) const
Definition: core.hpp:43
Responses::GetBalances getBalances(const std::vector< Models::Address > &addresses, const int &threshold=100, const std::vector< Types::Trytes > &tips={}) const
Definition: base.hpp:43
Definition: were_addresses_spent_from.hpp:43
Definition: check_consistency.hpp:48
Definition: service.hpp:47
Responses::Base broadcastTransactions(const std::vector< Types::Trytes > &trytes) const
Definition: remove_neighbors.hpp:44
Responses::GetTips getTips() const
Definition: add_neighbors.hpp:44
Definition: get_tips.hpp:44
Responses::GetNeighbors getNeighbors() const
Definition: get_trytes.hpp:45
Definition: get_inclusion_states.hpp:48
Definition: core.hpp:33
Responses::GetTransactionsToApprove getTransactionsToApprove(const int &depth, const Types::Trytes &reference="") const
Responses::GetInclusionStates getInclusionStates(const std::vector< Types::Trytes > &transactions, const std::vector< Types::Trytes > &tips) const