From 2422a070b25e6e1c9d48bf2a4b91f9cc75947064 Mon Sep 17 00:00:00 2001 From: levonpetrosyan93 <45027856+levonpetrosyan93@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:52:14 +0400 Subject: [PATCH] Show spark output addresses (#1485) --- src/wallet/rpcwallet.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a5ade6b12f..9ed20ecbd8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1682,6 +1682,17 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const std:: } entry.push_back(Pair("account", strSentAccount)); MaybePushAddress(entry, s.destination, addr); + + CSparkOutputTx output; + if (wtx.tx->IsSparkTransaction()) { + const CTxOut& txout = wtx.tx->vout[s.vout]; + if (txout.scriptPubKey.IsSparkMint() || txout.scriptPubKey.IsSparkSMint()) { + if(pwallet->GetSparkOutputTx(txout.scriptPubKey, output)) { + entry.push_back(Pair("address", output.address)); + } + } + } + if (wtx.tx->HasNoRegularInputs()) { entry.push_back(Pair("category", "spend")); } @@ -1691,7 +1702,12 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const std:: else { entry.push_back(Pair("category", "send")); } - entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); + + if (!output.address.empty()) + entry.push_back(Pair("amount", ValueFromAmount(-output.amount))); + else + entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); + if (pwallet->mapAddressBook.count(s.destination)) { entry.push_back(Pair("label", pwallet->mapAddressBook[s.destination].name)); }