Open harding opened 6 years ago
BTW, With the help of the command line, we can see :
1. "inputs" (array, required) A json array of json objects
[
{
"txid":"id", (string, required) The transaction id
"vout":n, (numeric, required) The output number
"sequence":n (numeric, optional) The sequence number
}
,...
]
2. "outputs" (object, required) a json object with outputs
{
"address": x.xxx, (numeric or string, required) The key is the bitcoin address, the numeric value (can be string) is the BTC amount
"data": "hex" (string, required) The key is "data", the value is hex encoded data
,...
}
But it's no pretty clear what it's data
and which step generate it .
@land-pack I think data
from createrawtransaction
is unrelated to this issue, although I agree the help there could be more clear. To clarify, data
is an alternative to address
; it lets you create what most people all an OP_RETURN
output with up to about 80 bytes of arbitrary data you specify that will be added to the block chain if your transaction confirms. You don't ever need to use data
and none of the examples in the documentation currently make use of data
(and data
is completely unrelated to segwit).
This issue is primarily about the amount
field in SignRawTransaction:
$ bitcoin-cli help signrawtransaction | grep amount
"amount": value (numeric, required) The amount spent
Note: this section of the documentation is going to break further with Bitcoin Core 0.18. The signrawtransaction
RPC was deprecated in 0.17 and is removed in 0.18. It is replaced by signrawtransactionwithkey
and signrawtransactionwithwallet
. (Also, if I were to write this section today, I'd definitely use PSBTs instead of rawtransactions.)
Perhaps this section should be removed.
@harding
Ok, thanks.
URL: https://bitcoin.org/en/developer-examples#transactions
The tutorial in this section no longer works with Bitcoin Core 0.16.0 and above because (1) regtest defaults to segwit being activated, (2) Bitcoin Core's built-in wallet defaults to using segwit, and (3) transaction signatures in segwit require signing the amount of the input, which requires passing an additional
amount
parameter tosignrawtransaction
.In addition, some of the examples provided in that section use P2PKH (e.g. addresses starting with 1), whereas with segwit defaulted to enabled, the wallet uses P2SH-wrapped segwit (e.g. addresses starting with 3). That should probably be updated at the same time. Note that, if you do this, you'll probably later need to update to using native segwit addresses (starting with bc1); if you want to switch completely to native segwit now to avoid future update problems, you can specify in the documentation that the user should pass these options to bitcoind:
-addresstype=bech32 -changetype=bech32
and then update all the examples to use native segwit addresses.Edit: I should've mentioned that this confused a user in an unlogged IRC channel this morning who was attempting to follow the documentation.