mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #10859: RPC: gettxout: Slightly improve doc and tests
6d2d2eb49
RPC: gettxout: Slightly improve doc and tests (Jorge Timón)
Pull request description:
Slightly related to https://github.com/bitcoin/bitcoin/pull/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
This commit is contained in:
parent
ebfec2218a
commit
74325db11a
@ -1211,9 +1211,10 @@ UniValue gettxout(const JSONRPCRequest& request)
|
||||
"gettxout \"txid\" n ( include_mempool )\n"
|
||||
"\nReturns details about an unspent transaction output.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"txid\" (string, required) The transaction id\n"
|
||||
"2. n (numeric, required) vout number\n"
|
||||
"3. include_mempool (boolean, optional) Whether to include the mempool\n"
|
||||
"1. \"txid\" (string, required) The transaction id\n"
|
||||
"2. \"n\" (numeric, required) vout number\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"
|
||||
"{\n"
|
||||
" \"bestblock\" : \"hash\", (string) the block hash\n"
|
||||
|
@ -58,15 +58,23 @@ class WalletTest(BitcoinTestFramework):
|
||||
assert_equal(len(self.nodes[1].listunspent()), 1)
|
||||
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'], 500)
|
||||
txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=True)
|
||||
assert_equal(txout['value'], 500)
|
||||
|
||||
# Send 210 DASH from 0 to 2 using sendtoaddress call.
|
||||
# Second transaction will be child of first, and will require a fee
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 110)
|
||||
mempool_txid = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 100)
|
||||
|
||||
self.log.info("test gettxout")
|
||||
self.log.info("test gettxout (second part)")
|
||||
# utxo spent in mempool should be visible if you exclude 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)
|
||||
assert_equal(txout['value'], 500)
|
||||
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True)
|
||||
|
Loading…
Reference in New Issue
Block a user