mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge #17437: rpc: Expose block height of wallet transactions
a5e77959c8ff6a8bffa1621d7ea29ee8603c5a14 rpc: Expose block height of wallet transactions (João Barbosa) Pull request description: Closes #17296. ACKs for top commit: practicalswift: ACK a5e77959c8ff6a8bffa1621d7ea29ee8603c5a14 -- diff looks correct now (good catch @theStack!) theStack: ACK a5e77959c8ff6a8bffa1621d7ea29ee8603c5a14 ryanofsky: Code review ACK a5e77959c8ff6a8bffa1621d7ea29ee8603c5a14. Changes since last review getblockhash python test fixes, and removing the last hardcoded height Tree-SHA512: 57dcd0e4e7083f34016bf9cf8ef578fbfde49e882b6cd8623dd1c64716e096e62f6177a4c2ed94f5de304e751fe23fb9d11cf107a86fbf0a3c5f539cd2844916
This commit is contained in:
parent
05ed3448d0
commit
bdf36f952b
5
doc/release-notes-17437.md
Normal file
5
doc/release-notes-17437.md
Normal file
@ -0,0 +1,5 @@
|
||||
Low-level RPC Changes
|
||||
===
|
||||
|
||||
- The RPC gettransaction, listtransactions and listsinceblock responses now also
|
||||
includes the height of the block that contains the wallet transaction, if any.
|
@ -169,6 +169,7 @@ static void WalletTxToJSON(interfaces::Chain& chain, const CWalletTx& wtx, UniVa
|
||||
if (confirms > 0)
|
||||
{
|
||||
entry.pushKV("blockhash", wtx.m_confirm.hashBlock.GetHex());
|
||||
entry.pushKV("blockheight", wtx.m_confirm.block_height);
|
||||
entry.pushKV("blockindex", wtx.m_confirm.nIndex);
|
||||
int64_t block_time;
|
||||
CHECK_NONFATAL(chain.findBlock(wtx.m_confirm.hashBlock, FoundBlock().time(block_time)));
|
||||
@ -1394,6 +1395,7 @@ static const std::vector<RPCResult> TransactionDescriptionString()
|
||||
{RPCResult::Type::BOOL, "trusted", "Whether we consider the outputs of this unconfirmed transaction safe to spend."},
|
||||
{RPCResult::Type::STR_HEX, "blockhash", "The block hash containing the transaction. Available for 'send' and 'receive'\n"
|
||||
"category of transactions."},
|
||||
{RPCResult::Type::STR_HEX, "blockheight", "The block height containing the transaction."},
|
||||
{RPCResult::Type::NUM, "blockindex", "The index of the transaction in the block that includes it. Available for 'send' and 'receive'\n"
|
||||
"category of transactions."},
|
||||
{RPCResult::Type::NUM_TIME, "blocktime", "The block time expressed in " + UNIX_EPOCH_TIME + "."},
|
||||
|
@ -40,6 +40,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
self.log.info("Test no blockhash")
|
||||
txid = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||
blockhash, = self.nodes[2].generate(1)
|
||||
blockheight = self.nodes[2].getblockheader(blockhash)['height']
|
||||
self.sync_all()
|
||||
|
||||
txs = self.nodes[0].listtransactions()
|
||||
@ -47,6 +48,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
"category": "receive",
|
||||
"amount": 1,
|
||||
"blockhash": blockhash,
|
||||
"blockheight": blockheight,
|
||||
"confirmations": 1,
|
||||
})
|
||||
assert_equal(
|
||||
@ -280,7 +282,8 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
self.sync_all()
|
||||
|
||||
# gettransaction should work for txid1
|
||||
self.nodes[0].gettransaction(txid1)
|
||||
tx1 = self.nodes[0].gettransaction(txid1)
|
||||
assert_equal(tx1['blockheight'], self.nodes[0].getblockheader(tx1['blockhash'])['height'])
|
||||
|
||||
# listsinceblock(lastblockhash) should now include txid1 in transactions
|
||||
# as well as in removed
|
||||
|
@ -26,14 +26,15 @@ class ListTransactionsTest(BitcoinTestFramework):
|
||||
{"txid": txid},
|
||||
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 0})
|
||||
# mine a block, confirmations should change:
|
||||
self.nodes[0].generate(1)
|
||||
blockhash = self.nodes[0].generate(1)[0]
|
||||
blockheight = self.nodes[0].getblockheader(blockhash)['height']
|
||||
self.sync_all()
|
||||
assert_array_result(self.nodes[0].listtransactions(),
|
||||
{"txid": txid},
|
||||
{"category": "send", "amount": Decimal("-0.1"), "confirmations": 1})
|
||||
{"category": "send", "amount": Decimal("-0.1"), "confirmations": 1, "blockhash": blockhash, "blockheight": blockheight})
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"txid": txid},
|
||||
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 1})
|
||||
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 1, "blockhash": blockhash, "blockheight": blockheight})
|
||||
|
||||
# send-to-self:
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 0.2)
|
||||
|
Loading…
Reference in New Issue
Block a user