How could I have figured that out without asking? The available docs/help don't make any mention of that
Yes it does. The help text for
walletprocesspsbt states:
walletprocesspsbt "psbt" ( sign "sighashtype" bip32derivs )
Update a PSBT with input information from our wallet and then sign inputs
that we can sign for.
Arguments:
1. psbt (string, required) The transaction base64 string
2. sign (boolean, optional, default=true) Also sign the transaction when updating
3. sighashtype (string, optional, default=ALL) The signature hash type to sign with if not specified by the PSBT. Must be one of
"ALL"
"NONE"
"SINGLE"
"ALL|ANYONECANPAY"
"NONE|ANYONECANPAY"
"SINGLE|ANYONECANPAY"
4. bip32derivs (boolean, optional, default=false) If true, includes the BIP 32 derivation paths for public keys if we know them
...
It clearly says that the second parameter named
sign is a boolean whose default value is
true. Because it is a boolean, the value you can use for it are
true or
false.
If you have any suggestions on how this can be clearer, then please let us know. The way that this help text is written follows the way that we have been writing help texts for a long time.
And perhaps I'm getting the conceptual details wrong again, but that doesn't change the result of decodepsbt, I get an array of inputs but no outputs.
(yes, the wallet for the inputs is loaded in the machine I'm using)
It is not an array of outputs, it is an array of output
metadata. If your wallet does not own those outputs, then no
output metadata will be given. The outputs are specified in the actual transaction at the top.
Using the same inputs as I used for
createpsbt, I'm getting:
error code: -4
error message:
Signing transaction failed
(again, the wallet containing the inputs is loaded on the machine I'm using)
Are the inputs standard inputs (i.e. ones that Bitcoin Core can sign for)? Do you have all of the information for the inputs in the wallet (e.g. redeemScripts, witnessScripts, etc.)?
maybe I should specify exactly what I want to do
Either:
A. Receiver creates a .psbt file, with no inputs specified, but 1 or more outputs that pay to a custom ScriptPubKey (details of doing that are ot for this thread). Payer takes the .psbt, adds their input, signs it, broadcast
or if that's not possible...
B. Receiver creates the ScriptPubKey they wish to be paid to, Payer takes that and creates the .psbt themself, using that/those outputs, adds their own inputs, signs, broadcasts
Which (if either) of these is possible?
B is possible under specific circumstances.
First of all, what you want to do in A is not what PSBT is supposed to be used for. PSBT is not for the step where you choose the inputs and outputs of a transaction. It is for the step where you have already chosen the inputs and outputs and now need to sign the transaction and otherwise make it complete for broadcast. When the BIP says anything along the lines of "add input and output information" it means adding the input and output metadata. The inputs and outputs are already chosen, but their metadata is not necessarily available to the person who created the PSBT, so each participant in the transaction needs to add the metadata for their inputs.
B is possible if the scriptPubKey is an address. Bitcoin Core does not allow you to use custom scriptPubKeys, although you can achieve that by using P2SH/P2WSH addresses.
What you do is use
walletcreatefundedpsbt, then
walletprocesspsbt, then
finalizepsbt. Your command should look something like this:
walletcreatefundedpsbt '[]' '[{"":walletprocesspsbt ""
finalizepbt ""
If you really want to use sighash single, then you use the command I gave you earlier.