MCPcopy Create free account
hub / github.com/ElementsProject/elements / MakeWalletTx

Function MakeWalletTx

src/wallet/interfaces.cpp:53–91  ·  view source on GitHub ↗

Construct wallet tx struct.

Source from the content-addressed store, hash-verified

51namespace {
52//! Construct wallet tx struct.
53WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx)
54{
55 LOCK(wallet.cs_wallet);
56 WalletTx result;
57 result.tx = wtx.tx;
58 result.txin_is_mine.reserve(wtx.tx->vin.size());
59 result.txin_issuance_asset.resize(wtx.tx->vin.size());
60 result.txin_issuance_token.resize(wtx.tx->vin.size());
61 for (unsigned int i = 0; i < wtx.tx->vin.size(); ++i) {
62 const auto& txin = wtx.tx->vin[i];
63 result.txin_is_mine.emplace_back(InputIsMine(wallet, txin));
64 wtx.GetIssuanceAssets(i, &result.txin_issuance_asset[i], &result.txin_issuance_token[i]);
65 result.txin_issuance_asset_amount.emplace_back(wtx.GetIssuanceAmount(wallet, i, false));
66 result.txin_issuance_token_amount.emplace_back(wtx.GetIssuanceAmount(wallet, i, true));
67 }
68 result.txout_is_mine.reserve(wtx.tx->vout.size());
69 result.txout_address.reserve(wtx.tx->vout.size());
70 result.txout_address_is_mine.reserve(wtx.tx->vout.size());
71 for (const auto& txout : wtx.tx->vout) {
72 result.txout_is_mine.emplace_back(wallet.IsMine(txout));
73 result.txout_address.emplace_back();
74 result.txout_address_is_mine.emplace_back(ExtractDestination(txout.scriptPubKey, result.txout_address.back()) ?
75 wallet.IsMine(result.txout_address.back()) :
76 ISMINE_NO);
77 result.txout_is_change.push_back(OutputIsChange(wallet, txout));
78 }
79 // ELEMENTS: Retrieve unblinded information about outputs
80 for (unsigned int i = 0; i < wtx.tx->vout.size(); ++i) {
81 result.txout_amounts.emplace_back(wtx.GetOutputValueOut(wallet, i));
82 result.txout_assets.emplace_back(wtx.GetOutputAsset(wallet, i));
83 }
84 result.credit = CachedTxGetCredit(wallet, wtx, ISMINE_ALL);
85 result.debit = CachedTxGetDebit(wallet, wtx, ISMINE_ALL);
86 result.change = CachedTxGetChange(wallet, wtx);
87 result.time = wtx.GetTxTime();
88 result.value_map = wtx.mapValue;
89 result.is_coinbase = wtx.IsCoinBase();
90 return result;
91}
92
93//! Construct wallet tx status struct.
94WalletTxStatus MakeWalletTxStatus(const CWallet& wallet, const CWalletTx& wtx)

Callers 3

getWalletTxMethod · 0.85
getWalletTxsMethod · 0.85
getWalletTxDetailsMethod · 0.85

Calls 15

InputIsMineFunction · 0.85
ExtractDestinationFunction · 0.85
OutputIsChangeFunction · 0.85
CachedTxGetCreditFunction · 0.85
CachedTxGetDebitFunction · 0.85
CachedTxGetChangeFunction · 0.85
emplace_backMethod · 0.80
GetIssuanceAmountMethod · 0.80
GetOutputValueOutMethod · 0.80
GetOutputAssetMethod · 0.80
GetTxTimeMethod · 0.80
reserveMethod · 0.45

Tested by

no test coverage detected