19#include <validation.h>
24#include <QLatin1String>
34 return tr(
"conflicted with a transaction with %1 confirmations").arg(-depth);
35 }
else if (depth == 0) {
41 s = tr(
"0/unconfirmed, in memory pool");
46 s = tr(
"0/unconfirmed, not in memory pool");
52 s += QLatin1String(
", ") + tr(
"abandoned");
55 }
else if (depth < 6) {
60 return tr(
"%1/unconfirmed").arg(depth);
65 return tr(
"%1 confirmations").arg(depth);
74 if (pr.find(std::string({0x12, 0x0b}) +
"x509+sha256") != std::string::npos || pr.find(std::string({0x12, 0x09}) +
"x509+sha1") != std::string::npos) {
79 size_t cn_pos = pr.find({0x06, 0x03, 0x55, 0x04, 0x03});
80 if (cn_pos != std::string::npos) {
81 cn_pos = pr.find({0x06, 0x03, 0x55, 0x04, 0x03}, cn_pos + 5);
82 if (cn_pos != std::string::npos) {
84 if (pr[cn_pos] == 0x13 || pr[cn_pos] == 0x0c) {
86 int str_len = pr[cn_pos];
88 merchant = QString::fromUtf8(pr.data() + cn_pos, str_len);
103 std::vector<std::string> payment_requests;
108 strHTML.reserve(4000);
109 strHTML +=
"<html><font face='verdana, arial, helvetica, sans-serif'>";
111 int64_t nTime = wtx.
time;
114 CAmount nNet = nCredit - nDebit;
116 strHTML +=
"<b>" + tr(
"Status") +
":</b> " +
FormatTxStatus(status, inMempool);
126 strHTML +=
"<b>" + tr(
"Source") +
":</b> " + tr(
"Generated") +
"<br>";
127 }
else if (wtx.
from) {
140 if (
wallet.getAddress(address, &
name,
nullptr))
142 strHTML +=
"<b>" + tr(
"From") +
":</b> " + tr(
"unknown") +
"<br>";
143 strHTML +=
"<b>" + tr(
"To") +
":</b> ";
145 QString addressOwned = tr(
"own address");
149 strHTML +=
" (" + addressOwned +
")";
162 strHTML +=
"<b>" + tr(
"To") +
":</b> ";
166 dest, &
name,
nullptr) && !
name.empty())
180 for (
const CTxOut& txout : wtx.
tx->vout)
181 nUnmatured +=
wallet.getCredit(txout);
182 strHTML +=
"<b>" + tr(
"Credit") +
":</b> ";
186 strHTML +=
"(" + tr(
"not accepted") +
")";
206 for (
const CTxOut& txout : wtx.
tx->vout)
209 bool toSelf = *(mine++);
210 if (toSelf && all_from_me)
218 strHTML +=
"<b>" + tr(
"To") +
":</b> ";
221 address, &
name,
nullptr) && !
name.empty())
225 strHTML +=
" (" + tr(
"own address") +
")";
239 CAmount nValue = nCredit - nChange;
244 CAmount nTxFee = nDebit - wtx.
tx->GetValueOut();
254 for (
const CTxIn& txin : wtx.
tx->vin) {
260 for (
const CTxOut& txout : wtx.
tx->vout) {
280 strHTML +=
"<b>" + tr(
"Transaction ID") +
":</b> " + rec->
getTxHash() +
"<br>";
281 strHTML +=
"<b>" + tr(
"Transaction total size") +
":</b> " + QString::number(wtx.
tx->ComputeTotalSize()) +
" bytes<br>";
283 strHTML +=
"<b>" + tr(
"Output index") +
":</b> " + QString::number(rec->
getOutputIndex()) +
"<br>";
290 for (
const std::string& req : payment_requests) {
295 merchant = tr(
"%1 (Certificate was not verified)").arg(merchant);
297 if (!merchant.isNull()) {
305 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>";
313 strHTML +=
"<hr><br>" + tr(
"Debug information") +
"<br><br>";
314 for (
const CTxIn& txin : wtx.
tx->vin)
315 if(
wallet.txinIsMine(txin))
317 for (
const CTxOut& txout : wtx.
tx->vout)
318 if(
wallet.txoutIsMine(txout))
321 strHTML +=
"<br><b>" + tr(
"Transaction") +
":</b><br>";
324 strHTML +=
"<br><b>" + tr(
"Inputs") +
":</b>";
327 for (
const CTxIn& txin : wtx.
tx->vin)
331 if (
auto prev{
node.getUnspentOutput(prevout)}) {
334 const CTxOut& vout = prev->out;
344 strHTML = strHTML +
" IsMine=" + (
wallet.txoutIsMine(vout) ? tr(
"true") : tr(
"false")) +
"</li>";
352 strHTML +=
"</font></html>";
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
int64_t CAmount
Amount in satoshis (Can be negative)
static QString formatHtmlWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as HTML string (with unit)
An outpoint - a combination of a transaction hash and an index n into its vout.
An input of a transaction.
An output of a transaction.
static QString FormatTxStatus(const interfaces::WalletTxStatus &status, bool inMempool)
static QString toHTML(interfaces::Node &node, interfaces::Wallet &wallet, TransactionRecord *rec, BitcoinUnit unit)
UI model for a transaction.
int getOutputIndex() const
Return the output index of the subtransaction
QString getTxHash() const
Return the unique identifier for this transaction (part)
Top-level interface for a bitcoin node (bitcoind process).
Interface for accessing a wallet.
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
std::string EncodeDestination(const CTxDestination &dest)
QString HtmlEscape(const QString &str, bool fMultiLine)
QString dateTimeStr(const QDateTime &date)
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
std::vector< bool > txin_is_mine
std::optional< std::string > comment
std::optional< std::string > comment_to
std::vector< bool > txout_is_mine
std::optional< std::string > message
std::optional< std::string > from
Updated transaction status.
bool GetPaymentRequestMerchant(const std::string &pr, QString &merchant)