You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fac7013 rpc: Update createrawtransaction examples (MarcoFalke)
fa06dfc [rpc] createrawtransaction: Accept sorted outputs (MarcoFalke)
8acd25d rpc: Allow typeAny in RPCTypeCheck (MarcoFalke)
Pull request description:
The second parameter of the `createrawtransaction` is a dictionary of the outputs. This comes with at least two drawbacks:
* In case of duplicate keys, either of them might silently disappear, with no user feedback at all. A user needs to make other mistakes, but this could eventually lead to abnormal tx fees.
* A dictionary does not guarantee that keys are sorted. Again, a user needs to keep this in mind, as it could eventually lead to excessive tx fees.
Even though my scenario of loss-of-funds is unlikely to happen, I see it as a inconvenience that should be fixed.
Tree-SHA512: cd562f34f7f9f79c7d3433805971325c388c2035611be283980f4049066a622df4f0afdc11d7ac96662260ec0115147cb65e1ab5268f5a1b063242f3fe425f77
Copy file name to clipboardExpand all lines: doc/release-notes.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,8 @@ RPC changes
61
61
62
62
### Low-level changes
63
63
64
-
- The `fundrawtransaction` rpc will reject the previously deprecated `reserveChangeKey` option.
64
+
- The `createrawtransaction` RPC will now accept an array or dictionary (kept for compatibility) for the `outputs` parameter. This means the order of transaction outputs can be specified by the client.
65
+
- The `fundrawtransaction` RPC will reject the previously deprecated `reserveChangeKey` option.
"1. \"inputs\" (array, required) A json array of json objects\n"
330
331
" [\n"
331
332
" {\n"
332
-
"\"txid\":\"id\", (string, required) The transaction id\n"
333
+
"\"txid\":\"id\", (string, required) The transaction id\n"
333
334
"\"vout\":n, (numeric, required) The output number\n"
334
335
"\"sequence\":n (numeric, optional) The sequence number\n"
335
336
" } \n"
336
337
" ,...\n"
337
338
" ]\n"
338
-
"2. \"outputs\" (object, required) a json object with outputs\n"
339
+
"2. \"outputs\" (array, required) a json array with outputs (key-value pairs)\n"
340
+
" [\n"
339
341
" {\n"
340
-
"\"address\": x.xxx, (numeric or string, required) The key is the bitcoin address, the numeric value (can be string) is the " + CURRENCY_UNIT + " amount\n"
341
-
"\"data\": \"hex\" (string, required) The key is \"data\", the value is hex encoded data\n"
342
-
" ,...\n"
342
+
"\"address\": x.xxx, (obj, optional) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " + CURRENCY_UNIT + "\n"
343
+
" },\n"
344
+
" {\n"
345
+
"\"data\": \"hex\" (obj, optional) A key-value pair. The key must be \"data\", the value is hex encoded data\n"
343
346
" }\n"
347
+
" ,... More key-value pairs of the above form. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
348
+
" accepted as second parameter.\n"
349
+
" ]\n"
344
350
"3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n"
345
351
"4. replaceable (boolean, optional, default=false) Marks this transaction as BIP125 replaceable.\n"
346
352
" Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.\n"
347
353
"\nResult:\n"
348
354
"\"transaction\" (string) hex string of the transaction\n"
assert_raises_rpc_error(-5, "The genesis block coinbase is not considered an ordinary transaction", self.nodes[0].getrawtransaction, block['merkleroot'])
65
69
70
+
self.log.info('Check parameter types and required parameters of createrawtransaction')
assert_raises_rpc_error(-8, "Invalid parameter, key-value pair must contain exactly one key", self.nodes[0].createrawtransaction, [], [{'a': 1, 'b': 2}])
102
+
assert_raises_rpc_error(-8, "Invalid parameter, key-value pair not an object as expected", self.nodes[0].createrawtransaction, [], [['key-value pair1'], ['2']])
92
103
93
104
# Test `createrawtransaction` invalid `locktime`
94
105
assert_raises_rpc_error(-3, "Expected type number", self.nodes[0].createrawtransaction, [], {}, 'foo')
@@ -98,9 +109,38 @@ def run_test(self):
98
109
# Test `createrawtransaction` invalid `replaceable`
99
110
assert_raises_rpc_error(-3, "Expected type bool", self.nodes[0].createrawtransaction, [], {}, 0, 'foo')
100
111
101
-
#########################################
102
-
# sendrawtransaction with missing input #
103
-
#########################################
112
+
self.log.info('Check that createrawtransaction accepts an array and object as outputs')
0 commit comments