Using Multisig Outputs with Bitcoin CLI: A Step-by-Step Guide
As a multisignature (MS) wallet user, accessing funds from your descriptor wallet is crucial to managing your funds effectively. In this article, we will guide you through using Bitcoin CLI to use multisig outputs in a financial transaction.
Prerequisites
- You have a descriptor wallet with multiple addresses and multiple signatures enabled.
- You have created a financial transaction «tx1» that contains the desired spending amounts for each address.
Step 1: Create a funding transaction with descriptor results
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 was created by checking the output of "regtest" in the console:
regtest
Step 2: Get the spending amounts for each address
In order 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 '. spend_amounts[]'
This will print a set of spend amounts for each transaction address.
Step 3: Create a descriptor wallet file with multisig descriptions
To use multisig prints, you need to create a descriptor wallet file that contains the multisig descriptions. 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 print a set of multisig descriptors for each funding transaction address.
Step 4: Spend funds from your description wallet
Now that you have the spending amounts and multisig descriptors, you can use the Bitcoin CLI to spend funds from your description wallet. You can do this using the following command:
bitcoind -regtest -quiet -server=0.0.0.0:8332 -config=native -datadir=/path/directory -txindex=0 txout | bitcoin-cli -regtest -quiet -server=0.0.0.0:8332 -config=native -datadir=/path/directory -txindex=0 spend
Replace with the funding transaction hash you created earlier.
Example use case
Let's assume you have a descriptor wallet filedescriptor.conf’ containing the following multisig descriptors:
[
{
"address": "addr1",
"multisig_index": 2,
"spendable_amounts": [
{"amount": 100},
{"amount": 200}
]
},
{
"address": "addr2",
"multisig_index": 3,
"spendable_amounts": [
{"amount": 50},
{"amount": 75}
]
}
]
And a financial transaction `tx1'' containing the desired spending amounts:
« json
{
«txid»: «1234567890abcdef»,
«vout»: [1, 2],
«outpoints»: [
{
«prevout»: null,
«sum_n»: {«n»: 100},
«scriptSig»: [{«pubkey»: {«hash»: «12…»}}, {«pubkey»: {«hash»: «13…»}}, {«pubkey»: {» hash»: «14…»}}],
«sum_out»: {«n»: 200}
},
{
«prevout»: null,
«sum_n»: {«n»: 50},
«scriptSig»: [{«pubkey»: {«hash»: «12…»}}, {«pubkey»: {«hash»: «13…»}}, {«pubkey»: {» hash»: «14…