2019-12-30 06:39:22 -03:00
// Copyright (c) 2011-2019 The Bitcoin Core developers
2014-12-13 01:09:33 -03:00
// Distributed under the MIT software license, see the accompanying
2013-11-04 12:20:43 -03:00
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2017-11-06 15:12:47 -03:00
# ifdef HAVE_CONFIG_H
# include <config/bitcoin-config.h>
# endif
2017-11-09 21:57:53 -03:00
# include <qt/transactiondesc.h>
2011-06-10 09:05:51 -04:00
2017-11-09 21:57:53 -03:00
# include <qt/bitcoinunits.h>
# include <qt/guiutil.h>
# include <qt/paymentserver.h>
# include <qt/transactionrecord.h>
2013-04-13 02:13:08 -03:00
2017-11-09 21:57:53 -03:00
# include <consensus/consensus.h>
2018-04-07 04:42:02 -03:00
# include <interfaces/node.h>
2019-11-19 07:08:01 -03:00
# include <interfaces/wallet.h>
2017-09-19 22:12:25 -03:00
# include <key_io.h>
2019-11-19 07:08:01 -03:00
# include <policy/policy.h>
2017-11-09 21:57:53 -03:00
# include <script/script.h>
2018-10-22 19:51:11 -03:00
# include <util/system.h>
2019-11-19 07:08:01 -03:00
# include <validation.h>
2019-06-06 03:53:16 -04:00
# include <wallet/ismine.h>
2011-06-10 09:05:51 -04:00
2013-04-13 02:13:08 -03:00
# include <stdint.h>
2013-01-23 17:51:02 -03:00
# include <string>
2021-05-03 04:16:06 -04:00
# include <QLatin1String>
2018-10-23 11:36:46 -03:00
QString TransactionDesc : : FormatTxStatus ( const interfaces : : WalletTx & wtx , const interfaces : : WalletTxStatus & status , bool inMempool , int numBlocks )
2011-06-10 09:05:51 -04:00
{
2017-04-18 17:42:30 -03:00
if ( ! status . is_final )
2011-06-10 09:05:51 -04:00
{
2016-11-11 21:54:51 -03:00
if ( wtx . tx - > nLockTime < LOCKTIME_THRESHOLD )
2017-04-18 17:42:30 -03:00
return tr ( " Open for %n more block(s) " , " " , wtx.tx->nLockTime - numBlocks) ;
2011-06-10 09:05:51 -04:00
else
2016-11-11 21:54:51 -03:00
return tr ( " Open until %1 " ) . arg ( GUIUtil : : dateTimeStr ( wtx . tx - > nLockTime ) ) ;
2011-06-10 09:05:51 -04:00
}
else
{
2017-04-18 17:42:30 -03:00
int nDepth = status . depth_in_main_chain ;
2021-05-03 04:16:06 -04:00
if ( nDepth < 0 ) {
2015-11-30 12:15:15 -03:00
return tr ( " conflicted with a transaction with %1 confirmations " ) . arg ( - nDepth ) ;
2021-05-03 04:16:06 -04:00
} else if ( nDepth = = 0 ) {
const QString abandoned { status . is_abandoned ? QLatin1String ( " , " ) + tr ( " abandoned " ) : QString ( ) } ;
return tr ( " 0/unconfirmed, %1 " ) . arg ( inMempool ? tr ( " in memory pool " ) : tr ( " not in memory pool " ) ) + abandoned ;
} else if ( nDepth < 6 ) {
2011-08-08 11:38:17 -04:00
return tr ( " %1/unconfirmed " ) . arg ( nDepth ) ;
2021-05-03 04:16:06 -04:00
} else {
2011-08-08 11:38:17 -04:00
return tr ( " %1 confirmations " ) . arg ( nDepth ) ;
2021-05-03 04:16:06 -04:00
}
2011-06-10 09:05:51 -04:00
}
}
2019-09-11 04:37:44 -03:00
// Takes an encoded PaymentRequest as a string and tries to find the Common Name of the X.509 certificate
// used to sign the PaymentRequest.
bool GetPaymentRequestMerchant ( const std : : string & pr , QString & merchant )
{
// Search for the supported pki type strings
if ( pr . find ( std : : string ( { 0x12 , 0x0b } ) + " x509+sha256 " ) ! = std : : string : : npos | | pr . find ( std : : string ( { 0x12 , 0x09 } ) + " x509+sha1 " ) ! = std : : string : : npos ) {
// We want the common name of the Subject of the cert. This should be the second occurrence
// of the bytes 0x0603550403. The first occurrence of those is the common name of the issuer.
// After those bytes will be either 0x13 or 0x0C, then length, then either the ascii or utf8
// string with the common name which is the merchant name
size_t cn_pos = pr . find ( { 0x06 , 0x03 , 0x55 , 0x04 , 0x03 } ) ;
if ( cn_pos ! = std : : string : : npos ) {
cn_pos = pr . find ( { 0x06 , 0x03 , 0x55 , 0x04 , 0x03 } , cn_pos + 5 ) ;
if ( cn_pos ! = std : : string : : npos ) {
cn_pos + = 5 ;
if ( pr [ cn_pos ] = = 0x13 | | pr [ cn_pos ] = = 0x0c ) {
cn_pos + + ; // Consume the type
int str_len = pr [ cn_pos ] ;
cn_pos + + ; // Consume the string length
merchant = QString : : fromUtf8 ( pr . data ( ) + cn_pos , str_len ) ;
return true ;
}
}
}
}
return false ;
}
2018-04-07 04:42:02 -03:00
QString TransactionDesc : : toHTML ( interfaces : : Node & node , interfaces : : Wallet & wallet , TransactionRecord * rec , int unit )
2011-06-10 09:05:51 -04:00
{
2017-04-18 17:42:30 -03:00
int numBlocks ;
2018-04-07 04:42:02 -03:00
interfaces : : WalletTxStatus status ;
interfaces : : WalletOrderForm orderForm ;
2017-04-18 17:42:30 -03:00
bool inMempool ;
2018-10-23 11:36:46 -03:00
interfaces : : WalletTx wtx = wallet . getWalletTxDetails ( rec - > hash , status , orderForm , inMempool , numBlocks ) ;
2017-04-18 17:42:30 -03:00
2011-08-08 11:38:17 -04:00
QString strHTML ;
2012-04-06 13:39:12 -03:00
2014-04-15 12:38:25 -03:00
strHTML . reserve ( 4000 ) ;
strHTML + = " <html><font face='verdana, arial, helvetica, sans-serif'> " ;
2017-04-18 17:42:30 -03:00
int64_t nTime = wtx . time ;
CAmount nCredit = wtx . credit ;
CAmount nDebit = wtx . debit ;
2014-04-22 19:46:19 -03:00
CAmount nNet = nCredit - nDebit ;
2014-04-15 12:38:25 -03:00
2018-10-23 11:36:46 -03:00
strHTML + = " <b> " + tr ( " Status " ) + " :</b> " + FormatTxStatus ( wtx , status , inMempool , numBlocks ) ;
2014-04-15 12:38:25 -03:00
strHTML + = " <br> " ;
2011-06-10 09:05:51 -04:00
2014-04-15 12:38:25 -03:00
strHTML + = " <b> " + tr ( " Date " ) + " :</b> " + ( nTime ? GUIUtil : : dateTimeStr ( nTime ) : " " ) + " <br> " ;
2011-06-10 09:05:51 -04:00
2014-04-15 12:38:25 -03:00
//
// From
//
2017-04-18 17:42:30 -03:00
if ( wtx . is_coinbase )
2014-04-15 12:38:25 -03:00
{
strHTML + = " <b> " + tr ( " Source " ) + " :</b> " + tr ( " Generated " ) + " <br> " ;
}
2017-04-18 17:42:30 -03:00
else if ( wtx . value_map . count ( " from " ) & & ! wtx . value_map [ " from " ] . empty ( ) )
2014-04-15 12:38:25 -03:00
{
// Online transaction
2017-04-18 17:42:30 -03:00
strHTML + = " <b> " + tr ( " From " ) + " :</b> " + GUIUtil : : HtmlEscape ( wtx . value_map [ " from " ] ) + " <br> " ;
2014-04-15 12:38:25 -03:00
}
else
{
// Offline transaction
if ( nNet > 0 )
2011-06-10 09:05:51 -04:00
{
2014-04-15 12:38:25 -03:00
// Credit
2017-09-06 17:44:33 -03:00
CTxDestination address = DecodeDestination ( rec - > address ) ;
if ( IsValidDestination ( address ) ) {
2017-04-18 17:42:30 -03:00
std : : string name ;
isminetype ismine ;
2018-04-10 12:50:10 -03:00
if ( wallet . getAddress ( address , & name , & ismine , /* purpose= */ nullptr ) )
2011-06-10 09:05:51 -04:00
{
2014-06-18 19:42:39 -04:00
strHTML + = " <b> " + tr ( " From " ) + " :</b> " + tr ( " unknown " ) + " <br> " ;
strHTML + = " <b> " + tr ( " To " ) + " :</b> " ;
strHTML + = GUIUtil : : HtmlEscape ( rec - > address ) ;
2017-04-18 17:42:30 -03:00
QString addressOwned = ismine = = ISMINE_SPENDABLE ? tr ( " own address " ) : tr ( " watch-only " ) ;
if ( ! name . empty ( ) )
strHTML + = " ( " + addressOwned + " , " + tr ( " label " ) + " : " + GUIUtil : : HtmlEscape ( name ) + " ) " ;
2014-06-18 19:42:39 -04:00
else
strHTML + = " ( " + addressOwned + " ) " ;
strHTML + = " <br> " ;
2011-06-10 09:05:51 -04:00
}
}
}
2014-04-15 12:38:25 -03:00
}
//
// To
//
2017-04-18 17:42:30 -03:00
if ( wtx . value_map . count ( " to " ) & & ! wtx . value_map [ " to " ] . empty ( ) )
2014-04-15 12:38:25 -03:00
{
// Online transaction
2017-04-18 17:42:30 -03:00
std : : string strAddress = wtx . value_map [ " to " ] ;
2014-04-15 12:38:25 -03:00
strHTML + = " <b> " + tr ( " To " ) + " :</b> " ;
2017-08-22 22:02:33 -03:00
CTxDestination dest = DecodeDestination ( strAddress ) ;
2017-04-18 17:42:30 -03:00
std : : string name ;
2018-04-10 12:50:10 -03:00
if ( wallet . getAddress (
dest , & name , /* is_mine= */ nullptr , /* purpose= */ nullptr ) & & ! name . empty ( ) )
2017-04-18 17:42:30 -03:00
strHTML + = GUIUtil : : HtmlEscape ( name ) + " " ;
2014-04-15 12:38:25 -03:00
strHTML + = GUIUtil : : HtmlEscape ( strAddress ) + " <br> " ;
}
2011-06-10 09:05:51 -04:00
2014-04-15 12:38:25 -03:00
//
// Amount
//
2017-04-18 17:42:30 -03:00
if ( wtx . is_coinbase & & nCredit = = 0 )
2014-04-15 12:38:25 -03:00
{
2011-06-10 09:05:51 -04:00
//
2014-04-15 12:38:25 -03:00
// Coinbase
2011-06-10 09:05:51 -04:00
//
2014-04-22 19:46:19 -03:00
CAmount nUnmatured = 0 ;
2017-06-01 21:18:57 -04:00
for ( const CTxOut & txout : wtx . tx - > vout )
2017-04-18 17:42:30 -03:00
nUnmatured + = wallet . getCredit ( txout , ISMINE_ALL ) ;
2014-04-15 12:38:25 -03:00
strHTML + = " <b> " + tr ( " Credit " ) + " :</b> " ;
2017-04-18 17:42:30 -03:00
if ( status . is_in_main_chain )
strHTML + = BitcoinUnits : : formatHtmlWithUnit ( unit , nUnmatured ) + " ( " + tr ( " matures in %n more block(s) " , " " , status . blocks_to_maturity ) + " ) " ;
2014-04-15 12:38:25 -03:00
else
strHTML + = " ( " + tr ( " not accepted " ) + " ) " ;
strHTML + = " <br> " ;
}
else if ( nNet > 0 )
{
2011-06-10 09:05:51 -04:00
//
2014-04-15 12:38:25 -03:00
// Credit
2011-06-10 09:05:51 -04:00
//
2014-05-09 18:50:09 -04:00
strHTML + = " <b> " + tr ( " Credit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , nNet ) + " <br> " ;
2014-04-15 12:38:25 -03:00
}
else
{
2014-07-01 05:00:22 -04:00
isminetype fAllFromMe = ISMINE_SPENDABLE ;
2018-06-18 01:58:28 -04:00
for ( const isminetype mine : wtx . txin_is_mine )
2014-03-29 01:15:28 -03:00
{
if ( fAllFromMe > mine ) fAllFromMe = mine ;
}
2014-04-15 12:38:25 -03:00
2014-07-01 05:00:22 -04:00
isminetype fAllToMe = ISMINE_SPENDABLE ;
2018-06-18 01:58:28 -04:00
for ( const isminetype mine : wtx . txout_is_mine )
2014-03-29 01:15:28 -03:00
{
if ( fAllToMe > mine ) fAllToMe = mine ;
}
2014-04-15 12:38:25 -03:00
if ( fAllFromMe )
2011-06-10 09:05:51 -04:00
{
2015-06-10 03:36:36 -03:00
if ( fAllFromMe & ISMINE_WATCH_ONLY )
2014-03-29 01:15:28 -03:00
strHTML + = " <b> " + tr ( " From " ) + " :</b> " + tr ( " watch-only " ) + " <br> " ;
2011-06-10 09:05:51 -04:00
//
2014-04-15 12:38:25 -03:00
// Debit
2011-06-10 09:05:51 -04:00
//
2017-04-18 17:42:30 -03:00
auto mine = wtx . txout_is_mine . begin ( ) ;
2017-06-01 21:18:57 -04:00
for ( const CTxOut & txout : wtx . tx - > vout )
2011-06-10 09:05:51 -04:00
{
2014-03-29 01:15:28 -03:00
// Ignore change
2017-04-18 17:42:30 -03:00
isminetype toSelf = * ( mine + + ) ;
2014-07-01 05:00:22 -04:00
if ( ( toSelf = = ISMINE_SPENDABLE ) & & ( fAllFromMe = = ISMINE_SPENDABLE ) )
2014-04-15 12:38:25 -03:00
continue ;
2011-06-10 09:05:51 -04:00
2017-04-18 17:42:30 -03:00
if ( ! wtx . value_map . count ( " to " ) | | wtx . value_map [ " to " ] . empty ( ) )
2014-04-15 12:38:25 -03:00
{
// Offline transaction
CTxDestination address ;
if ( ExtractDestination ( txout . scriptPubKey , address ) )
2011-06-10 09:05:51 -04:00
{
2014-04-15 12:38:25 -03:00
strHTML + = " <b> " + tr ( " To " ) + " :</b> " ;
2017-04-18 17:42:30 -03:00
std : : string name ;
2018-04-10 12:50:10 -03:00
if ( wallet . getAddress (
address , & name , /* is_mine= */ nullptr , /* purpose= */ nullptr ) & & ! name . empty ( ) )
2017-04-18 17:42:30 -03:00
strHTML + = GUIUtil : : HtmlEscape ( name ) + " " ;
2017-08-22 22:02:33 -03:00
strHTML + = GUIUtil : : HtmlEscape ( EncodeDestination ( address ) ) ;
2014-07-01 05:00:22 -04:00
if ( toSelf = = ISMINE_SPENDABLE )
2014-03-29 01:15:28 -03:00
strHTML + = " (own address) " ;
2015-06-10 03:36:36 -03:00
else if ( toSelf & ISMINE_WATCH_ONLY )
2014-03-29 01:15:28 -03:00
strHTML + = " (watch-only) " ;
2014-04-15 12:38:25 -03:00
strHTML + = " <br> " ;
2011-06-10 09:05:51 -04:00
}
}
2014-05-09 18:50:09 -04:00
strHTML + = " <b> " + tr ( " Debit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , - txout . nValue ) + " <br> " ;
2014-03-29 01:15:28 -03:00
if ( toSelf )
2014-07-07 17:06:21 -04:00
strHTML + = " <b> " + tr ( " Credit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , txout . nValue ) + " <br> " ;
2011-06-10 09:05:51 -04:00
}
2014-04-15 12:38:25 -03:00
if ( fAllToMe )
2011-06-10 09:05:51 -04:00
{
2014-04-15 12:38:25 -03:00
// Payment to self
2017-04-18 17:42:30 -03:00
CAmount nChange = wtx . change ;
2014-04-22 19:46:19 -03:00
CAmount nValue = nCredit - nChange ;
2014-07-07 17:06:21 -04:00
strHTML + = " <b> " + tr ( " Total debit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , - nValue ) + " <br> " ;
strHTML + = " <b> " + tr ( " Total credit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , nValue ) + " <br> " ;
2011-06-10 09:05:51 -04:00
}
2014-04-15 12:38:25 -03:00
2016-11-11 21:54:51 -03:00
CAmount nTxFee = nDebit - wtx . tx - > GetValueOut ( ) ;
2014-04-15 12:38:25 -03:00
if ( nTxFee > 0 )
2014-05-09 18:50:09 -04:00
strHTML + = " <b> " + tr ( " Transaction fee " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , - nTxFee ) + " <br> " ;
2011-06-10 09:05:51 -04:00
}
2014-04-15 12:38:25 -03:00
else
{
//
// Mixed debit transaction
//
2017-04-18 17:42:30 -03:00
auto mine = wtx . txin_is_mine . begin ( ) ;
for ( const CTxIn & txin : wtx . tx - > vin ) {
if ( * ( mine + + ) ) {
strHTML + = " <b> " + tr ( " Debit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , - wallet . getDebit ( txin , ISMINE_ALL ) ) + " <br> " ;
}
}
mine = wtx . txout_is_mine . begin ( ) ;
for ( const CTxOut & txout : wtx . tx - > vout ) {
if ( * ( mine + + ) ) {
strHTML + = " <b> " + tr ( " Credit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , wallet . getCredit ( txout , ISMINE_ALL ) ) + " <br> " ;
}
}
2014-04-15 12:38:25 -03:00
}
}
2011-06-10 09:05:51 -04:00
2014-05-09 18:50:09 -04:00
strHTML + = " <b> " + tr ( " Net amount " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , nNet , true ) + " <br> " ;
2011-06-10 09:05:51 -04:00
2014-04-15 12:38:25 -03:00
//
// Message
//
2017-04-18 17:42:30 -03:00
if ( wtx . value_map . count ( " message " ) & & ! wtx . value_map [ " message " ] . empty ( ) )
strHTML + = " <br><b> " + tr ( " Message " ) + " :</b><br> " + GUIUtil : : HtmlEscape ( wtx . value_map [ " message " ] , true ) + " <br> " ;
if ( wtx . value_map . count ( " comment " ) & & ! wtx . value_map [ " comment " ] . empty ( ) )
strHTML + = " <br><b> " + tr ( " Comment " ) + " :</b><br> " + GUIUtil : : HtmlEscape ( wtx . value_map [ " comment " ] , true ) + " <br> " ;
2011-06-10 09:05:51 -04:00
2018-03-06 17:22:50 -03:00
strHTML + = " <b> " + tr ( " Transaction ID " ) + " :</b> " + rec - > getTxHash ( ) + " <br> " ;
2016-11-11 21:54:51 -03:00
strHTML + = " <b> " + tr ( " Transaction total size " ) + " :</b> " + QString : : number ( wtx . tx - > GetTotalSize ( ) ) + " bytes<br> " ;
2018-03-01 17:55:01 -03:00
strHTML + = " <b> " + tr ( " Transaction virtual size " ) + " :</b> " + QString : : number ( GetVirtualTransactionSize ( * wtx . tx ) ) + " bytes<br> " ;
2016-03-29 06:17:47 -03:00
strHTML + = " <b> " + tr ( " Output index " ) + " :</b> " + QString : : number ( rec - > getOutputIndex ( ) ) + " <br> " ;
2012-01-10 15:25:02 -03:00
2014-04-15 12:38:25 -03:00
// Message from normal bitcoin:URI (bitcoin:123...?message=example)
2019-09-11 04:37:44 -03:00
for ( const std : : pair < std : : string , std : : string > & r : orderForm ) {
2014-04-15 12:38:25 -03:00
if ( r . first = = " Message " )
strHTML + = " <br><b> " + tr ( " Message " ) + " :</b><br> " + GUIUtil : : HtmlEscape ( r . second , true ) + " <br> " ;
2014-01-21 19:39:29 -03:00
2019-09-11 04:37:44 -03:00
//
// PaymentRequest info:
//
2014-04-15 12:38:25 -03:00
if ( r . first = = " PaymentRequest " )
2013-07-22 02:50:39 -04:00
{
2019-09-11 04:37:44 -03:00
QString merchant ;
if ( ! GetPaymentRequestMerchant ( r . second , merchant ) ) {
merchant . clear ( ) ;
} else {
merchant + = tr ( " (Certificate was not verified) " ) ;
}
if ( ! merchant . isNull ( ) ) {
2014-04-15 12:38:25 -03:00
strHTML + = " <b> " + tr ( " Merchant " ) + " :</b> " + GUIUtil : : HtmlEscape ( merchant ) + " <br> " ;
2019-09-11 04:37:44 -03:00
}
2013-07-22 02:50:39 -04:00
}
2014-04-15 12:38:25 -03:00
}
2013-07-22 02:50:39 -04:00
2017-04-18 17:42:30 -03:00
if ( wtx . is_coinbase )
2014-04-15 12:38:25 -03:00
{
quint32 numBlocksToMaturity = COINBASE_MATURITY + 1 ;
strHTML + = " <br> " + tr ( " Generated coins must mature %1 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \" not accepted \" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours. " ) . arg ( QString : : number ( numBlocksToMaturity ) ) + " <br> " ;
}
2011-06-10 09:05:51 -04:00
2014-04-15 12:38:25 -03:00
//
// Debug view
//
2017-04-18 17:42:30 -03:00
if ( node . getLogCategories ( ) ! = BCLog : : NONE )
2014-04-15 12:38:25 -03:00
{
strHTML + = " <hr><br> " + tr ( " Debug information " ) + " <br><br> " ;
2017-06-01 21:18:57 -04:00
for ( const CTxIn & txin : wtx . tx - > vin )
2017-04-18 17:42:30 -03:00
if ( wallet . txinIsMine ( txin ) )
strHTML + = " <b> " + tr ( " Debit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , - wallet . getDebit ( txin , ISMINE_ALL ) ) + " <br> " ;
2017-06-01 21:18:57 -04:00
for ( const CTxOut & txout : wtx . tx - > vout )
2017-04-18 17:42:30 -03:00
if ( wallet . txoutIsMine ( txout ) )
strHTML + = " <b> " + tr ( " Credit " ) + " :</b> " + BitcoinUnits : : formatHtmlWithUnit ( unit , wallet . getCredit ( txout , ISMINE_ALL ) ) + " <br> " ;
2014-04-15 12:38:25 -03:00
strHTML + = " <br><b> " + tr ( " Transaction " ) + " :</b><br> " ;
2016-11-11 21:54:51 -03:00
strHTML + = GUIUtil : : HtmlEscape ( wtx . tx - > ToString ( ) , true ) ;
2011-06-10 09:05:51 -04:00
2014-04-15 12:38:25 -03:00
strHTML + = " <br><b> " + tr ( " Inputs " ) + " :</b> " ;
strHTML + = " <ul> " ;
2011-06-10 09:05:51 -04:00
2017-06-01 21:18:57 -04:00
for ( const CTxIn & txin : wtx . tx - > vin )
2014-04-15 12:38:25 -03:00
{
COutPoint prevout = txin . prevout ;
2012-04-06 13:39:12 -03:00
2017-04-25 15:29:39 -03:00
Coin prev ;
2017-04-18 17:42:30 -03:00
if ( node . getUnspentOutput ( prevout , prev ) )
2011-06-10 09:05:51 -04:00
{
{
2014-04-15 12:38:25 -03:00
strHTML + = " <li> " ;
2017-04-25 15:29:39 -03:00
const CTxOut & vout = prev . out ;
2014-04-15 12:38:25 -03:00
CTxDestination address ;
if ( ExtractDestination ( vout . scriptPubKey , address ) )
2011-06-10 09:05:51 -04:00
{
2017-04-18 17:42:30 -03:00
std : : string name ;
2018-04-10 12:50:10 -03:00
if ( wallet . getAddress ( address , & name , /* is_mine= */ nullptr , /* purpose= */ nullptr ) & & ! name . empty ( ) )
2017-04-18 17:42:30 -03:00
strHTML + = GUIUtil : : HtmlEscape ( name ) + " " ;
2017-08-22 22:02:33 -03:00
strHTML + = QString : : fromStdString ( EncodeDestination ( address ) ) ;
2011-06-10 09:05:51 -04:00
}
2014-05-09 18:50:09 -04:00
strHTML = strHTML + " " + tr ( " Amount " ) + " = " + BitcoinUnits : : formatHtmlWithUnit ( unit , vout . nValue ) ;
2017-04-18 17:42:30 -03:00
strHTML = strHTML + " IsMine= " + ( wallet . txoutIsMine ( vout ) & ISMINE_SPENDABLE ? tr ( " true " ) : tr ( " false " ) ) + " </li> " ;
strHTML = strHTML + " IsWatchOnly= " + ( wallet . txoutIsMine ( vout ) & ISMINE_WATCH_ONLY ? tr ( " true " ) : tr ( " false " ) ) + " </li> " ;
2011-06-10 09:05:51 -04:00
}
}
}
2014-04-15 12:38:25 -03:00
strHTML + = " </ul> " ;
2011-06-10 09:05:51 -04:00
}
2014-04-15 12:38:25 -03:00
strHTML + = " </font></html> " ;
2011-06-10 09:05:51 -04:00
return strHTML ;
}