Browse Source

RPC: gettxout: Slightly improve doc and tests

0.16
Jorge Timón 7 years ago
parent
commit
6d2d2eb493
No known key found for this signature in database
GPG Key ID: 8866C18EA1C944A2
  1. 7
      src/rpc/blockchain.cpp
  2. 12
      test/functional/wallet.py

7
src/rpc/blockchain.cpp

@ -944,9 +944,10 @@ UniValue gettxout(const JSONRPCRequest& request)
"gettxout \"txid\" n ( include_mempool )\n" "gettxout \"txid\" n ( include_mempool )\n"
"\nReturns details about an unspent transaction output.\n" "\nReturns details about an unspent transaction output.\n"
"\nArguments:\n" "\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n" "1. \"txid\" (string, required) The transaction id\n"
"2. n (numeric, required) vout number\n" "2. \"n\" (numeric, required) vout number\n"
"3. include_mempool (boolean, optional) Whether to include the mempool\n" "3. \"include_mempool\" (boolean, optional) Whether to include the mempool. Default: true."
" Note that an unspent output that is spent in the mempool won't appear.\n"
"\nResult:\n" "\nResult:\n"
"{\n" "{\n"
" \"bestblock\" : \"hash\", (string) the block hash\n" " \"bestblock\" : \"hash\", (string) the block hash\n"

12
test/functional/wallet.py

@ -56,6 +56,15 @@ class WalletTest(BitcoinTestFramework):
assert_equal(len(self.nodes[1].listunspent()), 1) assert_equal(len(self.nodes[1].listunspent()), 1)
assert_equal(len(self.nodes[2].listunspent()), 0) assert_equal(len(self.nodes[2].listunspent()), 0)
self.log.info("test gettxout")
confirmed_txid, confirmed_index = utxos[0]["txid"], utxos[0]["vout"]
# First, outputs that are unspent both in the chain and in the
# mempool should appear with or without include_mempool
txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=False)
assert_equal(txout['value'], 50)
txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=True)
assert_equal(txout['value'], 50)
# Send 21 BTC from 0 to 2 using sendtoaddress call. # Send 21 BTC from 0 to 2 using sendtoaddress call.
# Locked memory should use at least 32 bytes to sign each transaction # Locked memory should use at least 32 bytes to sign each transaction
self.log.info("test getmemoryinfo") self.log.info("test getmemoryinfo")
@ -65,10 +74,9 @@ class WalletTest(BitcoinTestFramework):
memory_after = self.nodes[0].getmemoryinfo() memory_after = self.nodes[0].getmemoryinfo()
assert(memory_before['locked']['used'] + 64 <= memory_after['locked']['used']) assert(memory_before['locked']['used'] + 64 <= memory_after['locked']['used'])
self.log.info("test gettxout") self.log.info("test gettxout (second part)")
# utxo spent in mempool should be visible if you exclude mempool # utxo spent in mempool should be visible if you exclude mempool
# but invisible if you include mempool # but invisible if you include mempool
confirmed_txid, confirmed_index = utxos[0]["txid"], utxos[0]["vout"]
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False) txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False)
assert_equal(txout['value'], 50) assert_equal(txout['value'], 50)
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True) txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True)

Loading…
Cancel
Save