1387 | @@ -1388,8 +1388,9 @@ static const std::vector<RPCResult> TransactionDescriptionString()
1388 | {
1389 | return{{RPCResult::Type::NUM, "confirmations", "The number of confirmations for the transaction. Negative confirmations means the\n"
1390 | "transaction conflicted that many blocks ago."},
1391 | - {RPCResult::Type::BOOL, "generated", /* optional */ true, "Only present if transaction only input is a coinbase one."},
1392 | - {RPCResult::Type::BOOL, "trusted", /* optional */ true, "Only present if we consider transaction to be trusted and so safe to spend from."},
1393 | + {RPCResult::Type::BOOL, "generated", /* optional */ true, "Only present if the transaction's only input is a coinbase one."},
1394 | + {RPCResult::Type::BOOL, "trusted", /* optional */ true, "Whether we consider the transaction to be trusted and safe to spend from.\n"
1395 | + "Only present when the transaction has 0 confirmations (or negative confirmations, if conflicted)."},
Noob question, what does it mean to have "negative confirmation"?
"Negative confirmations" are those having a value less than zero, like -1. (Would it be clearer to write "less than zero" instead?)
Negative confirmations signify that the transaction conflicted that many blocks ago.
Code-wise, WalletTxToJSON() in src/wallet/rpcwallet.cpp calls to CWallet::GetTxDepthInMainChain() in wallet.{h,cpp} to fetch the value. In the following line, that function changes the height to a negative value if the transaction is conflicted:
return (GetLastBlockHeight() - wtx.m_confirm.block_height + 1) * (wtx.isConflicted() ? -1 : 1);
#23146 opened today adds testing that explores this behavior.
See also CWallet::MarkConflicted() and its callers, and the documentation in CWallet::transactionRemovedFromMempool().
Ah thanks.. No I think the comment with "negative confirmation" is fine.. I was just curious to understand when it will occur.