Close #26338.
This PR makes optional the address
field in the response of listtransactions
and listsinceblock
RPC.
And adds two tests that fail on master, but not on this branch.
address
field optional list{transactions, sinceblock}
response
#26349
291@@ -284,6 +292,22 @@ def run_invalid_parameters_test(self):
292 assert_raises_rpc_error(-8, "Negative count", self.nodes[0].listtransactions, count=-1)
293 assert_raises_rpc_error(-8, "Negative from", self.nodes[0].listtransactions, skip=-1)
294
295+ def test_op_return(self):
296+
297+ data = random_bytes(8)
291@@ -284,6 +292,22 @@ def run_invalid_parameters_test(self):
292 assert_raises_rpc_error(-8, "Negative count", self.nodes[0].listtransactions, count=-1)
293 assert_raises_rpc_error(-8, "Negative from", self.nodes[0].listtransactions, skip=-1)
294
295+ def test_op_return(self):
296+
297+ data = random_bytes(8)
298+
299+ tx = CTransaction()
300+ tx.vout = [CTxOut(nValue=2, scriptPubKey=CScript([OP_RETURN, data]))]
createrawtransaction '[]' '[{"data":"aa"}]'
?
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
label
to listsinceblock
by brunoerg)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
560@@ -561,7 +561,7 @@ RPCHelpMan listsinceblock()
561 {RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult>>(
562 {
563 {RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction."},
564- {RPCResult::Type::STR, "address", "The bitcoin address of the transaction."},
565+ {RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address of the transaction."},
Thanks for updating! The spelling linter doesn’t like “ommited”
0src/wallet/rpc/transactions.cpp:450: ommited ==> omitted
1src/wallet/rpc/transactions.cpp:564: ommited ==> omitted
Maybe something like:
“The bitcoin address of the transaction (not returned if the transaction contains OP_RETURN null data).”
458+ signed_tx = self.nodes[2].signrawtransactionwithwallet(funded_tx['hex'])
459+ tx_id = self.nodes[2].sendrawtransaction(signed_tx['hex'])
460+
461+ op_ret_tx = [tx for tx in self.nodes[2].listsinceblock(blockhash=block_hash)["transactions"] if tx['txid'] == tx_id][0]
462+
463+ assert('address' not in op_ret_tx)
In your diff in both test files (see #26257):
0 assert 'address' not in op_ret_tx
This avoids the python linter raising locally and needing to update #26257
0test/functional/wallet_listsinceblock.py:463:15: E275 missing whitespace after keyword
1test/functional/wallet_listtransactions.py:297:15: E275 missing whitespace after keyword
284@@ -284,6 +285,17 @@ def run_invalid_parameters_test(self):
285 assert_raises_rpc_error(-8, "Negative count", self.nodes[0].listtransactions, count=-1)
286 assert_raises_rpc_error(-8, "Negative from", self.nodes[0].listtransactions, skip=-1)
287
288+ def test_op_return(self):
289+ """Test if OP_RETURN outputs will be displayed correctly."""
290+ raw_tx = self.nodes[0].createrawtransaction([],[{'data':'aa'}])
In your diff in both test files, if you retouch
0 raw_tx = self.nodes[0].createrawtransaction([], [{'data': 'aa'}])
446@@ -447,7 +447,7 @@ RPCHelpMan listtransactions()
447 {RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult>>(
448 {
449 {RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction."},
450- {RPCResult::Type::STR, "address", "The bitcoin address of the transaction."},
451+ {RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address of the transaction (not returned if the transaction contains OP_RETURN null data)."},
not returned if the output address cannot be decoded (such as OP_RETURN null data).
ACK eb679a7896ce00e322972a011b023661766923b9
I was able to verify that this PR fixes the original issue by reproducing the crash on master+mainnet (with --enable-debug
) using the following steps:
0$ ./src/bitcoind -blockfilterindex
1$ ./src/bitcoin-cli -named createwallet wallet_name=26349 disable_private_keys=true
2$ ./src/bitcoin-cli -rpcwallet=26349 importdescriptors '[{"desc": "raw(6a20a015693871d8bde65f57ec82f52f6b192e9a11fa26a37e63e17dc3092c6c7fab)#jgvt3p6e", "timestamp": 1516693300}]'
3$ ./src/bitcoin-cli -rpcwallet=26349 listtransactions '*' 500
4error code: -1
5error message:
6Internal bug detected: "std::any_of(m_results.m_results.begin(), m_results.m_results.end(), [&ret](const RPCResult& res) { return res.MatchesType(ret); })"
7rpc/util.cpp:587 (HandleRequest)
8Please report this issue here: https://github.com/bitcoin/bitcoin/issues
Then on this PR:
0$ ./src/bitcoin-cli loadwallet 26349
1$ ./src/bitcoin-cli -rpcwallet=26349 listtransactions '*' 500
2[
3 {
4 "parent_descs": [
5 "raw(6a20a015693871d8bde65f57ec82f52f6b192e9a11fa26a37e63e17dc3092c6c7fab)#jgvt3p6e"
6 ],
7 "category": "receive",
8 "amount": 0.00000000,
9 "vout": 1,
10 "confirmations": 254851,
11 "blockhash": "00000000000000000025a92c80f5c259ca5d9d36d407906dbefbd8075c3ae77b",
12 "blockheight": 505672,
13 "blockindex": 857,
14 "blocktime": 1516693344,
15 "txid": "b6439e1c9eb3915b3cc89871d2c2479f3f1847f0c7bab252c3ebc503b8f6d344",
16 "wtxid": "393cfba86cb0d3274850aa461dab433b5d62c1dce68dc10d43de969b8dec2359",
17 "walletconflicts": [
18 ],
19 "time": 1516693344,
20 "timereceived": 1666874521,
21 "bip125-replaceable": "no"
22 }
23]
w0xlt
maflcko
DrahtBot
hebasto
jonatack
achow101
aureleoules
fanquake
Labels
RPC/REST/ZMQ
Milestone
24.0