Skip to content

Commit 91e49c5

Browse files
author
MarcoFalke
committed
Merge #10859: RPC: gettxout: Slightly improve doc and tests
6d2d2eb RPC: gettxout: Slightly improve doc and tests (Jorge Timón) Pull request description: Slightly related to bitcoin/bitcoin#10822 in the sense that I felt the documentation and testing wasn't as good as it could be while writing it. Ping @sipa since we discussed this on IRC. Tree-SHA512: a0b3ffdac65245a0429e772fc2d8bcc1e829b02c70fb2af6ee0b7578cae46683f6c51a824b4d703d4dc3f99b6f03a658d6bbc818bf32981516f24124249a211d
2 parents 60dd9cc + 6d2d2eb commit 91e49c5

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/rpc/blockchain.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,10 @@ UniValue gettxout(const JSONRPCRequest& request)
944944
"gettxout \"txid\" n ( include_mempool )\n"
945945
"\nReturns details about an unspent transaction output.\n"
946946
"\nArguments:\n"
947-
"1. \"txid\" (string, required) The transaction id\n"
948-
"2. n (numeric, required) vout number\n"
949-
"3. include_mempool (boolean, optional) Whether to include the mempool\n"
947+
"1. \"txid\" (string, required) The transaction id\n"
948+
"2. \"n\" (numeric, required) vout number\n"
949+
"3. \"include_mempool\" (boolean, optional) Whether to include the mempool. Default: true."
950+
" Note that an unspent output that is spent in the mempool won't appear.\n"
950951
"\nResult:\n"
951952
"{\n"
952953
" \"bestblock\" : \"hash\", (string) the block hash\n"

test/functional/wallet.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ def run_test(self):
5656
assert_equal(len(self.nodes[1].listunspent()), 1)
5757
assert_equal(len(self.nodes[2].listunspent()), 0)
5858

59+
self.log.info("test gettxout")
60+
confirmed_txid, confirmed_index = utxos[0]["txid"], utxos[0]["vout"]
61+
# First, outputs that are unspent both in the chain and in the
62+
# mempool should appear with or without include_mempool
63+
txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=False)
64+
assert_equal(txout['value'], 50)
65+
txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=True)
66+
assert_equal(txout['value'], 50)
67+
5968
# Send 21 BTC from 0 to 2 using sendtoaddress call.
6069
# Locked memory should use at least 32 bytes to sign each transaction
6170
self.log.info("test getmemoryinfo")
@@ -65,10 +74,9 @@ def run_test(self):
6574
memory_after = self.nodes[0].getmemoryinfo()
6675
assert(memory_before['locked']['used'] + 64 <= memory_after['locked']['used'])
6776

68-
self.log.info("test gettxout")
77+
self.log.info("test gettxout (second part)")
6978
# utxo spent in mempool should be visible if you exclude mempool
7079
# but invisible if you include mempool
71-
confirmed_txid, confirmed_index = utxos[0]["txid"], utxos[0]["vout"]
7280
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False)
7381
assert_equal(txout['value'], 50)
7482
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True)

0 commit comments

Comments
 (0)