Skip to content

Commit 906cc4c

Browse files
luke-jrinstagibbs
authored andcommitted
Wallet: GetIssuanceAssets to get CAmountMap for issuances
1 parent 4ea8f88 commit 906cc4c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/wallet/wallet.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,19 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
20242024
return CTransaction(tx1) == CTransaction(tx2);
20252025
}
20262026

2027+
CAmountMap CWalletTx::GetIssuanceAssets(unsigned int input_index) const {
2028+
CAmountMap ret;
2029+
CAsset asset, token;
2030+
GetIssuanceAssets(input_index, &asset, &token);
2031+
if (!asset.IsNull()) {
2032+
ret[asset] = GetIssuanceAmount(input_index, false);
2033+
}
2034+
if (!token.IsNull()) {
2035+
ret[token] = GetIssuanceAmount(input_index, true);
2036+
}
2037+
return ret;
2038+
}
2039+
20272040
std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CConnman* connman)
20282041
{
20292042
std::vector<uint256> result;
@@ -5196,9 +5209,9 @@ CPubKey CWalletTx::GetOutputBlindingPubKey(unsigned int output_index) const {
51965209
return ret;
51975210
}
51985211

5199-
void CWalletTx::GetIssuanceAssets(unsigned int vinIndex, CAsset* out_asset, CAsset* out_reissuance_token) const {
5200-
assert(vinIndex < tx->vin.size());
5201-
const CAssetIssuance& issuance = tx->vin[vinIndex].assetIssuance;
5212+
void CWalletTx::GetIssuanceAssets(unsigned int input_index, CAsset* out_asset, CAsset* out_reissuance_token) const {
5213+
assert(input_index < tx->vin.size());
5214+
const CAssetIssuance& issuance = tx->vin[input_index].assetIssuance;
52025215

52035216
if (out_asset && issuance.nAmount.IsNull()) {
52045217
out_asset->SetNull();
@@ -5212,7 +5225,7 @@ void CWalletTx::GetIssuanceAssets(unsigned int vinIndex, CAsset* out_asset, CAss
52125225

52135226
if (issuance.assetBlindingNonce.IsNull()) {
52145227
uint256 entropy;
5215-
GenerateAssetEntropy(entropy, tx->vin[vinIndex].prevout, issuance.assetEntropy);
5228+
GenerateAssetEntropy(entropy, tx->vin[input_index].prevout, issuance.assetEntropy);
52165229
if (out_reissuance_token) {
52175230
CalculateReissuanceToken(*out_reissuance_token, entropy, issuance.nAmount.IsCommitment());
52185231
}

src/wallet/wallet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ class CWalletTx : public CMerkleTx
535535
CAsset GetOutputAsset(unsigned int output_index) const;
536536
//! Get the issuance CAssets for both the asset itself and the issuing tokens
537537
void GetIssuanceAssets(unsigned int vinIndex, CAsset* out_asset, CAsset* out_reissuance_token) const;
538+
// ! Return map of issued assets at input_index
539+
CAmountMap GetIssuanceAssets(unsigned int input_index) const;
538540
// ! Returns receiver's blinding pubkey
539541
CPubKey GetOutputBlindingPubKey(unsigned int output_index) const;
540542
//! Get the issuance blinder for either the asset itself or the issuing tokens

0 commit comments

Comments
 (0)