Skip to content

Commit d95913f

Browse files
committed
rpc: fix "trusted" description in TransactionDescriptionString
The helps for RPCs gettransaction, listtransactions, and listsinceblock returned by TransactionDescriptionString() state that the "trusted" boolean field is only present if the transaction is trusted and safe to spend from. The "trusted" boolean field is in fact returned by WalletTxToJSON() when the transaction has 0 confirmations, or negative confirmations, if conflicted, and it can be true or false. This commit updates TransactionDescriptionString() to a more accurate description for "trusted" and updates the existing line of test coverage to fail more helpfully.
1 parent efa227f commit d95913f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,8 @@ static const std::vector<RPCResult> TransactionDescriptionString()
13891389
return{{RPCResult::Type::NUM, "confirmations", "The number of confirmations for the transaction. Negative confirmations means the\n"
13901390
"transaction conflicted that many blocks ago."},
13911391
{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."},
1392+
{RPCResult::Type::BOOL, "trusted", /* optional */ true, "Whether we consider the transaction to be trusted and safe to spend from.\n"
1393+
"Only present when the transaction has 0 confirmations (or negative confirmations, if conflicted)."},
13931394
{RPCResult::Type::STR_HEX, "blockhash", /* optional */ true, "The block hash containing the transaction."},
13941395
{RPCResult::Type::NUM, "blockheight", /* optional */ true, "The block height containing the transaction."},
13951396
{RPCResult::Type::NUM, "blockindex", /* optional */ true, "The index of the transaction in the block that includes it."},
@@ -1407,7 +1408,7 @@ static const std::vector<RPCResult> TransactionDescriptionString()
14071408
{RPCResult::Type::NUM_TIME, "timereceived", "The time received expressed in " + UNIX_EPOCH_TIME + "."},
14081409
{RPCResult::Type::STR, "comment", /* optional */ true, "If a comment is associated with the transaction, only present if not empty."},
14091410
{RPCResult::Type::STR, "bip125-replaceable", "(\"yes|no|unknown\") Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n"
1410-
"may be unknown for unconfirmed transactions not in the mempool"}};
1411+
"may be unknown for unconfirmed transactions not in the mempool."}};
14111412
}
14121413

14131414
static RPCHelpMan listtransactions()

test/functional/wallet_import_rescan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def check(self, txid=None, amount=None, confirmation_height=None):
9999
assert_equal(tx["label"], self.label)
100100
assert_equal(tx["txid"], txid)
101101
assert_equal(tx["confirmations"], 1 + current_height - confirmation_height)
102-
assert_equal("trusted" not in tx, True)
102+
assert "trusted" not in tx
103103

104104
address, = [ad for ad in addresses if txid in ad["txids"]]
105105
assert_equal(address["address"], self.address["address"])

0 commit comments

Comments
 (0)