mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-05 19:38:54 +02:00
rpc: Expose block height of wallet transactions
This commit is contained in:
@@ -40,6 +40,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
def test_no_blockhash(self):
|
||||
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(
|
||||
@@ -276,7 +278,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
|
||||
|
||||
@@ -40,14 +40,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)
|
||||
|
||||
Reference in New Issue
Block a user