Spending Multisig Outputs with Bitcoin-CLI: A Step-by-Step Guide
As a multisignature (MS) wallet user, spending funds from your descriptor wallet is crucial to managing your assets effectively. In this article, we’ll walk you through the process of using Bitcoin-CLI to spend multisig outputs in a funding transaction.
Prerequisites
- You have a descriptor wallet with multiple addresses and multisignatures enabled.
- You have created a funding transaction
tx1
that includes the desired spending amounts for each address.
Step 1: Create a funding transaction with descriptor outputs
To create a funding transaction, you can use the following Bitcoin-CLI command:
bitcoind -regtest -quiet -server=0.0.0.0:8332 -config=native -datadir=/path/to/directory -txindex=0 txout
Replace
with the path to your descriptor wallet file (e.g., descriptor.conf
).
This will create a new funding transaction in Regtest mode. You can verify that the transaction has been created by checking the regtest
console output:
regtest
Step 2: Get the spending amounts for each address
To spend funds from your descriptor wallet, you need to get the spending amounts for each address. You can do this using the following command:
bitcoind -regtest -quiet -server=0.0.0.0:8332 -config=native -datadir=/path/to/directory -txindex=0 txout | jq '. expendable_amounts[]'
This will output an array of spending amounts for each address in the funding transaction.
Step 3: Create a descriptor wallet file with multisig descriptors
To use multisig outputs, you need to create a descriptor wallet file that includes multisig descriptors. You can do this using the following command:
bitcoind -regtest -quiet -server=0.0.0.0:8332 -config=native -datadir=/path/to/directory -txindex=0 txout | jq '. multisig_descriptors[]'
This will output an array of multisig descriptors for each address in the funding transaction.
Step 4: Spend funds from your descriptor wallet
Now that you have the spending amounts and multisig descriptors, you can use Bitcoin-CLI to spend funds from your descriptor wallet. You can do this using the following command:
bitcoind -regtest -quiet -server=0.0.0.0:8332 -config=native -datadir=/path/to/directory -txindex=0 txout | bitcoin-cli -regtest -quiet -server=0.0.0.0:8332 -config=native -datadir=/path/to/directory -txindex=0 spend
Replace
with the hash of the funding transaction you created earlier.
Example Use Case
Suppose you have a descriptor wallet file descriptor.conf
that includes the following multisig descriptors:
[
{
"address": "addr1".
"multisign_index": 2,
"spendable_amounts":[
{"amount": 100},
{"amount": 200}
]
},
{
"address": "addr2".
"multisignal_index": 3,
"spendable_amounts":[
{"amount": 50},
{"amount": 75}
]
} }
]
And a funding transaction tx1
that includes the desired spending amounts:
“`json
{
“txid”: “1234567890abcdef”
“vote”: [1, 2],
“outpoints”:
{
“prevote”: null,
“amount_n”: {“n”: 100},
“scriptSig”: [{“pubkey”: {“hash”: “12…”}}, {“pubkey”: {“hash”: “13…”}}, {“pubkey”: {“hash”: “14…”}}],
“amount_out”: {“n”:200}
},
{
“prevote”: null,
“amount_n”:{“n”:50},
“scriptSig”: [{“pubkey”: {“hash”: “12…”}}, {“pubkey”:{“hash”:”13…”}}, {“pubkey”:{“hash”: