Bitcoin m of n transactions
![]()
This is because P2SH addresses have a version byte prefix of 0x05instead of the 0x00 prefix in P2PKH addresses, bitcoin m of n transactions these come out as a '3' and '1' after base58check encoding. Everything else should remain the same. Remember, the destination P2SH address is a hash and doesn't reveal our redeem script.

To fund our multisig address now, we need a funding source of Bitcoins. We will create a 2-of-3 multisignature address, where 2 digital signatures of 3 possible public keys are required to spend funds sent to this address. The transaction above was bitcoin m of n transactions and confirmed as txid 02be35dce7efa0bfb7f4b79c4cdcd3d.

We would at this point pass this address to the sender who is funding our multisig address. This has a number of advantages:. First we need the hex representations of 3 public keys. This puts the responsibility of providing the full redeem script on to the recipient of the P2SH funds. The transaction above was broadcast and confirmed bitcoin m of n transactions txid 02be35dce7efa0bfb7f4b79c4cdcd3d.

The code to do it all in Go is available as go-bitcoin-multsig on GitHub and I'd like to go through how all of this works at the Bitcoin protocol level. A couple of important notes, especially for troubleshooting, on how this raw transaction is created:. The core developers decided that instead of letting senders put in long scripts into their scriptPubKey where spending conditions usually gothey would let each sender put in a hash of their spending conditions instead.

First let's generate another key pair to be our destination where we can send our multisig funds. Now, we specify that we want a 2-of-3 address and provide our 3 public keys to generate our P2SH address:. The code to do it all in Go is available as go-bitcoin-multsig on GitHub and I'd like to go through how all of this works at the Bitcoin protocol level. This bitcoin m of n transactions used to compare the redeem script provided in the spending transaction to the hash in the funding transaction.

Now, this is important: If you'd like to follow along and create a multisig transaction yourself, you'll need to follow the simple build instructions for go-bitcoin-multisig. A valid multisignature redeem script, according to the Bitcoin protocollooks like:.

It contains a hashed redeem script with our chosen public keys and multisig script, but this will not be revealed publicly until the spending transaction, since it has been hashed. Again, the transaction will bitcoin m of n transactions slightly different each time because of the changing nonce in the digital signature, but everything else should look the same. Now, we will need 2 of the 3 private keys of the public keys used to generate our P2SH address.