Debian Codegraph @

monero/src/wallet/api/transaction_construction_info.cpp

raw symbols SCIP
1 #include "transaction_construction_info.h"
2
3 using namespace std;
4
5 namespace Monero {
6 TransactionConstructionInfo::~TransactionConstructionInfo() = default;
7
8 TransactionConstructionInfo::Input::Input(uint64_t _amount, const std::string &_pubkey)
9 : amount(_amount), pubkey(_pubkey) {}
10
11 TransactionConstructionInfo::Output::Output(uint64_t _amount, const std::string &_address)
12 : amount(_amount), address(_address) {}
13
14 TransactionConstructionInfoImpl::TransactionConstructionInfoImpl(WalletImpl &wallet, const tools::wallet2::tx_construction_data & txcd)
15 : m_wallet(wallet)
16 , m_txcd(txcd) {}
17
18 TransactionConstructionInfoImpl::~TransactionConstructionInfoImpl() = default;
19
20 uint64_t TransactionConstructionInfoImpl::unlockTime() const {
21 return m_txcd.unlock_time;
22 }
23
24 std::set<std::uint32_t> TransactionConstructionInfoImpl::subaddressIndices() const {
25 return m_txcd.subaddr_indices;
26 }
27
28 std::vector<std::string> TransactionConstructionInfoImpl::subaddresses() const {
29 std::vector<std::string> s;
30 auto major = m_txcd.subaddr_account;
31 for (const auto &minor : m_txcd.subaddr_indices) {
32 s.push_back(m_wallet.m_wallet->get_subaddress_as_str({major, minor}));
33 }
34 return s;
35 }
36
37 uint64_t TransactionConstructionInfoImpl::minMixinCount() const {
38 uint64_t min_mixin = -1;
39 for (const auto &source : m_txcd.sources) {
40 size_t mixin = source.outputs.size() - 1;
41 if (mixin < min_mixin)
42 min_mixin = mixin;
43 }
44
45 return min_mixin;
46 }
47
48 std::vector<TransactionConstructionInfo::Input> TransactionConstructionInfoImpl::inputs() const {
49 std::vector<Input> inputs;
50 for (const auto &i : m_txcd.sources) {
51 inputs.emplace_back(i.amount, epee::string_tools::pod_to_hex(i.outputs[i.real_output].second.dest));
52 }
53 return inputs;
54 }
55
56 std::vector<TransactionConstructionInfo::Output> TransactionConstructionInfoImpl::outputs() const {
57 std::vector<Output> outputs;
58 for (const auto &o : m_txcd.splitted_dsts) {
59 outputs.emplace_back(o.amount, o.address(m_wallet.m_wallet->nettype(), crypto::hash()));
60 }
61 return outputs;
62 }
63 }
64 namespace Bitmonero = Monero;