I am looking for the correct way to spend multisig outputs with descriptor wallet bitcoin-cli.
In regtest, I successfully created a funding transaction tx1
with the following outputs:
out:0 sh(multi(1,KEY1,KEY2))
out:1 wsh(multi(1,KEY3,KEY4,KEY5))
I used bitcoin-cli -regtest deriveaddresses
to get P2SH_ADDRESS
and P2WSH_ADDRESS
from these descriptors and then
bitcoin-cli -regtest -rpcwallet="$WALLET" createrawtransaction '''
[
{
"txid": "'$prev_tx'",
"vout": 0
}
]
''' '''
{
"'$P2SH_ADDRESS'": 3,
"'$P2WSH_ADDRESS'": 2,
"'$CHANGE_ADDRESS'": 18
}
'''
Then I broadcast and mined this transaction.
Now I want to create a spending transaction, that spends both of these inputs, using
PSBT=$( bitcoin-cli -regtest -named createpsbt inputs='''[
{
"txid": "tx1",
"vout": 0
},
{
"txid": "tx1",
"vout": 1
},
]''' outputs='''[
{
"'$ADDRESS1'": 1
},
{
"'$ADDRESS2'": 1
},
{
"$CHANGE_ADDRESS": 4
}
]''')
My main question:
- how do I add input information to this
PSBT
(i.e. redeemScript forinp:0
and witnessScript forinp:1
)? What is the modern correct way to get a redeemScript and a witnessScript given output descriptors?
My second question:
- say
KEY1,KEY3
belong towallet1
, andKEY2,KEY4,KEY5
belong towallet2
. I want to spendout:0
usingKEY1
andout:1
usingKEY4
. I tried to simply sign with both wallets:bitcoin-cli -regtest -rpcwallet=walletN walletprocesspsbt $PSBT
but is it possible to select the specific key (i.e. wallet in this case) betweenKEY1
andKEY2
to spend thesh(multi(1,KEY1,KEY2)) vout:0
, these keys are from the different wallets? And is it even correct to usewalletprocesspsbt
in this case?