mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-07 16:06:26 +00:00
Update 6_3_Sending_an_Automated_Multisig.md
This commit is contained in:
parent
2da8769a4d
commit
fa63eb4e66
@ -1,8 +1,8 @@
|
||||
6.3: Spending & Spending an Automated Multisig
|
||||
# 6.3: Sending & Spending an Automated Multisig
|
||||
|
||||
> **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning.
|
||||
|
||||
The standard technique for creating multisignature addresses and for spending their funds is complex, but is a worthwhile exercise for understanding a bit more about how they work, and how you can manipulate them at a relatively low level. However, Bitcoin Core has made multisigs a little bit easier in new releases.
|
||||
The standard technique for creating multisignature addresses and for spending their funds is complex, but it's a worthwhile exercise for understanding a bit more about how they work, and how you can manipulate them at a relatively low level. However, Bitcoin Core has made multisigs a little bit easier in new releases.
|
||||
|
||||
> **VERSION WARNING:** The `addmultisigaddress` command is available in Bitcoin Core v 0.10 or higher.
|
||||
|
||||
@ -11,7 +11,8 @@ The standard technique for creating multisignature addresses and for spending th
|
||||
In order to make funds sent to multisig addresses easier to spend, you need to have done some prep using the `addmultisigaddress` command. It's probably not what you'd want to do if you were writing multisig wallet programs, but if you were just trying to receive some funds by hand, it might save you some hair-pulling.
|
||||
|
||||
### Collect the Keys
|
||||
You start off creating P2PKH addresses and retrieving public keys as usual for each user who will be part of the multisig:
|
||||
|
||||
You start off creating P2PKH addresses and retrieving public keys as usual, for each user who will be part of the multisig:
|
||||
```
|
||||
machine1$ address3=$(bitcoin-cli getnewaddress)
|
||||
machine1$ echo $address3
|
||||
@ -26,7 +27,7 @@ $ bitcoin-cli -named validateaddress address=$address4 | jq -r '. | .pubkey'
|
||||
030186d2b55de166389aefe209f508ce1fbd79966d9ac417adef74b7c1b5e07776
|
||||
```
|
||||
|
||||
### Create the Address Everywhere
|
||||
### Create the Multisig Address Everywhere
|
||||
|
||||
Next you create the multisig on _each machine that contributes signatures_ using a new command, `addmultisigaddress`, instead of `createmultisig`. This new command saves some of the information into your wallet, making it a lot easier to spend the money afterward.
|
||||
```
|
||||
@ -38,20 +39,22 @@ machine2$ bitcoin-cli -named addmultisigaddress nrequired=2 keys='''["02e7356952
|
||||
```
|
||||
As noted in the previous section, it doesn't matter whether you use addresses or public keys: you'll get the same multisig address. However, you must use the same order. Thus, it's best for the members of the multisig to check amongst themselves to make sure they all got the same result.
|
||||
|
||||
The members of the multisig will still need to run `importaddress` to watch for funds received on the multisig address:
|
||||
### Watch for Funds
|
||||
|
||||
Afterward, the members of the multisig will still need to run `importaddress` to watch for funds received on the multisig address:
|
||||
```
|
||||
machine1$ bitcoin-cli -named importaddress address=2Mzw7WBvh9RAQ4ssKqxyNyP7L9NAojLqSW8
|
||||
|
||||
machine2$ bitcoin-cli -named importaddress address=2Mzw7WBvh9RAQ4ssKqxyNyP7L9NAojLqSW8
|
||||
```
|
||||
|
||||
### Respend with a Fairly Normal Transaction
|
||||
## Respend with an Automated Transaction
|
||||
|
||||
Afterward, you will be able to receive funds on the multisiganture address as normal. The use of `addmultisigaddress` is simply a bureaucratic issue on the part of the recipients: a bit of bookkeeping to make life easier for them.
|
||||
|
||||
But, it makes life a lot easier. Because everything is in the wallet, the signers will be able to resepend the funds sent to the multisignature address exactly the same as any other address ... other than the need to sign on multiple machines.
|
||||
But, it makes life a lot easier. Because everything is in the wallet, the signers will be able to respend the funds sent to the multisignature address exactly the same as any other address ... other than the need to sign on multiple machines.
|
||||
|
||||
To respend from a multisignature address where `addmultisigaddress` has saved the information into your wallet, you start by collecting your variables, but just the normal ones:
|
||||
You start by collecting your variables, but you no longer need to worry about `scriptPubKey` or `redeemScript`:
|
||||
```
|
||||
machine1$ utxo_txid=$(bitcoin-cli listunspent | jq -r '.[1] | .txid')
|
||||
machine1$ utxo_vout=$(bitcoin-cli listunspent | jq -r '.[1] | .vout')
|
||||
@ -78,7 +81,7 @@ machine1$ bitcoin-cli -named signrawtransaction hexstring=$rawtxhex
|
||||
]
|
||||
}
|
||||
```
|
||||
Note that you didn't have to save any other variables or add any other input information to these commands. Most importantly, you didn't make your private keys vulnerable by directly manipulating them. Instead the process was _exactly_ the same as respending a normal UTXO, except that the transaction wasn't fully signed at the end.
|
||||
Note that you no longer had to give `signrawtransaction` extra help, because all of that extra information was already in your wallet. Most importantly, you didn't make your private keys vulnerable by directly manipulating them. Instead the process was _exactly_ the same as respending a normal UTXO, except that the transaction wasn't fully signed at the end.
|
||||
|
||||
### Sign It On Other Machines
|
||||
|
||||
@ -92,3 +95,7 @@ $ bitcoin-cli -named sendrawtransaction hexstring=$signedtx
|
||||
3ce88839ac6165aeadcfb188c490e1b850468eff571b4ca78fac64342751510d
|
||||
```
|
||||
As with the shortcut demonstrated in [4.5: Sending Coints with Automated Raw Transactions](4_5_Sending_Coins_with_Automated_Raw_Transactions.md), the result is a lot easier, but you lose some control in the process.
|
||||
|
||||
## Summary: Sending & Spending an Automated Multisig
|
||||
|
||||
There's an easier way to resepend funds sent to multisig addresses that simply requires use of the `addmultisigaddress` command when you create your address. It doesn't demonstrate the intricacies of P2SH respending, and it doesn't give you expansive control, but if you just want to get your money, this is the way to go.
|
||||
|
Loading…
x
Reference in New Issue
Block a user