From 3604cb5b9f5fdbcc2565177a98960b182fd96dc0 Mon Sep 17 00:00:00 2001 From: David Burkett Date: Wed, 13 Apr 2022 17:12:34 -0400 Subject: [PATCH] Including pegouts in transaction info dialog --- src/qt/transactiondesc.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 5f6dd33b5f..f057ca13f1 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -274,6 +274,33 @@ QString TransactionDesc::toHTML_Amounts(interfaces::Wallet& wallet, const interf strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, txout.nValue) + "
"; } + auto pegout_mine = wtx.pegout_is_mine.begin(); + for (const PegOutCoin& pegout : wtx.pegouts) { + isminetype toSelf = *(pegout_mine++); + if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE)) + continue; + + CTxDestination dest; + if (::ExtractDestination(pegout.GetScriptPubKey(), dest)) { + strHTML += "" + tr("To") + ": "; + std::string name; + if (wallet.getAddress( + dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr) && + !name.empty()) + strHTML += GUIUtil::HtmlEscape(name) + " "; + strHTML += GUIUtil::HtmlEscape(::EncodeDestination(dest)); + if (toSelf == ISMINE_SPENDABLE) + strHTML += " (own address)"; + else if (toSelf & ISMINE_WATCH_ONLY) + strHTML += " (watch-only)"; + strHTML += "
"; + } + + strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -pegout.GetAmount()) + "
"; + if (toSelf) + strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, pegout.GetAmount()) + "
"; + } + if (fAllToMe) { // Payment to self CAmount nValue = wtx.credit - wtx.change; @@ -294,6 +321,7 @@ QString TransactionDesc::toHTML_Amounts(interfaces::Wallet& wallet, const interf strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet.getDebit(txin, ISMINE_ALL)) + "
"; } } + mine = wtx.txout_is_mine.begin(); for (const interfaces::WalletTxOut& out : wtx.outputs) { if (*(mine++)) { @@ -301,7 +329,12 @@ QString TransactionDesc::toHTML_Amounts(interfaces::Wallet& wallet, const interf } } - // MW: TODO - Pegouts? + mine = wtx.pegout_is_mine.begin(); + for (const PegOutCoin& pegout : wtx.pegouts) { + if (*(mine++)) { + strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, pegout.GetAmount()) + "
"; + } + } } }