07/18/14

Speaking at the NYC Bitcoin Center -HD-BIP32 Multi-sig Business Wallet

gAtO - will be Ringing the Trading Bell and presenting his HD-BIP32 Multi-sig Business wallet at the NYC Bitcoin Center with my good friend Dr. Nicolas T. Courtois from the University College London on Monday July 21 2014. If anyone is in the NYC area and wants to come on down for the show and after do a little Bitcoin trading – Come on Down. - gAtO oUt

poster_NYC

06/14/14

How To Bitcoin Multi Signature Address -Wallet

multi-sig-01gAtO ThInK – Multi-Sig will help Bitcoins, but it’s all about the blockchain since it is the one that keeps the Multi-sig Address and the release of the funds by 2 of the 3 signing of the escrow transaction and recording it in the blockchain and it get’s confirmed by the miners like all good Bitcoin transactions so try and give the miners a little fee in any transactions.

Multi-Sig TX

Multi-Sig TX

BUT it’s kinda complicated and most wallets do not support Multi-Sig. The few that do allow Multi-Sig almost require you to be a programmer of sort to even generate the Multi-Sig Address yet alone spend your money once you have them in the wallet.

  1. - First thing is to generate the Multi-sig Wallet address: 
  2. - Register the wallet in the blockchain by sending some money to this address to verify it is working.   
  3. - To get you money out of a Multi-Sig address you need to: signrawtransaction
  4. - We have to get 2 of the 3 to sign the transaction and submit it to the blockchain. – Of course 1 ? 2 – or 3 privateKeys too authorize the transaction. Depending on how you set it up in the first place.   
    • RedeemScript
    • TXid
    • ScriptPubKey
  5. Spend you Bitcoins

So let’s try to decode all this horse-play and do some Multi-Sig Wallet Stuff— BEFORE YOU BEGIN Questions— Pre-Multi-sig Wallet Creation – How many users must sign to release the coins in this Multi-sig wallet – 1 ? 2 ? 3 – make sure you have access to the PrivateKeys of these. You must have access to the PrivateKey of the wallet address you use. Because of the Version of Bitcoin code you can only create a 1 ? 2 or 3 user Multi-Sig wallet- the code will not support a more complex Multi-Sig structure right now, in the future you will be able to create 5 of 7 or 8 of 15 or what ever weird way you want to release your  money from these Multi-Sig Wallets. Todays code only allows 1-2 or 3 signatures to release funds. So once you have this figured out we can begin to generate the NEW Wallet ADDRESS:

Pay to Script

Pay to Script code’s it all and delivers it to the blockchain

PRE-Multi-Sig Address Generation: For our example below I will use 3 different Wallets I generate for this test, these are throw away addresses but you can use them to test it your self.

  1. 1Pum4jukypYddQDywoQDcgdkz7NMKKHXGR
  2. 1L7xm1TrwpsNBCrAaNUw8eBwD115Tr7tpC
  3. 145dwy7fvmRJwMpXDVzuZpNSd6UwEbabk2

I am assuming that you are running BitcoinD on your server – if you run Bitcoin-qt you will have access to this command. You can use the “CreateMultiSig” or the “AddMultiSigAddress” commands // they  will generate the Multi-Sig Bitcoin Address, but “CreateMultiSig” is the only one that will give you back the  – “redeemScript” –  and you need this script to get your Bitcoins out of the Multi-Sig address wallet. (Bitcoin Ver 8.9)

1.createmultisig <nrequired> <‘[“key,”key”]’> Creates a multi-signature address and returns a json object “redeemScript”

 

2. addmultisigaddress <nrequired> <‘[“key”,”key”]’> [account] Add a nrequired-to-sign multisignature address to the wallet. Each key is a bitcoin address or hex-encoded public key. If [account] is specified, assign address to [account]. ”NO-redeemScript”

Step 1 – Generate Bitcoin Wallet Address //  It will starts with a number “3”. nRequired you need 1, 2 or 3 signatures to release the funds I have chosen any 2 of the 3 Bitcoin Address listed in the command below can release the coins in the NEW Multi-Sig address—

CREATEMULTISIG

COMMAND:

bitcoind createmultisig 2 ‘[“1Pum4jukypYddQDywoQDcgdkz7NMKKHXGR“, “1L7xm1TrwpsNBCrAaNUw8eBwD115Tr7tpC“, “145dwy7fvmRJwMpXDVzuZpNSd6UwEbabk2“]’

OUTPUT: {     “address” : “3DLwoeBuoQRMUDvqvbwQCiYnpauxwC1i71″,    

redeemScript” : “5221022934c1f3ddc25426fc057ca706d66d818f63f00f3bb4ad4762947ec23b8c316e210343e871878f6a66728c2a8bec2ae0bffbd4c862968e20280526645f4157de7fca21022a453e7eea23207f87c46881b2e63f56c5ec2e59b30fe887ef29bd21ed67c15d53ae” }

So now you can give this new Multi-Sig address to people – 3DLwoeBuoQRMUDvqvbwQCiYnpauxwC1i71 –  Now you have your NEW Bitcoin Multi-Sig address and people can start to send money to this wallet address. I sent some Bitcoins to this NEW Multi-Sig address from my Wallet . Then I went to my Bitcoin console and typed in:

GETRECEIVEBYADDRESS

COMMAND: bitcoind getreceivedbyaddress 3DLwoeBuoQRMUDvqvbwQCiYnpauxwC1i71

OUTPUT: 0.00300000

Now I know my NEW Multi-Sig Wallet is in working order and registered in the blockchain remember if it not registered in the blockchain then it nothing NADA-one zip. Rules of the Muliti-Signature Wallet

  • All MultiSig address start with the number “3” a regular Bitcoin address start with the number “1”.
  • You can only have a 1-2 or 3 part Multi-Sig wallet. We cannot do a 5 or 7 part Multi-sig transaction today do to the core Bitcoin CODE.

So now I have a NEW Bitcoin Address —3DLwoeBuoQRMUDvqvbwQCiYnpauxwC1i71  —  and now people can send Bitcoins to that address as much as they want and it acts just like a normal Bitcoin Wallet.

Step 2 – GET MONEY OUT of a Multi-Sig address Wallet — So now i can look at my Multi-sig wallet and check to see if I have any money in my account

LISTUNSPENT COMMAND:

bitcoind listunspent OUTPUT:     {        

txid” : “c45c8c00243c703412e207646d51bf6878444537c37372528012f412f552b9cd”,        

“vout” : 0,        

“address” : “3DLwoeBuoQRMUDvqvbwQCiYnpauxwC1i71″,        

“account” : “”,        

scriptPubKey” : “a9147fd5c07649707498b47a50039bdcadc703e7e85e87″,        

redeemScript” : “5221022934c1f3ddc25426fc057ca706d66d818f63f00f3bb4ad4762947ec23b8c316e210343e871878f6a66728c2a8bec2ae0bffbd4c862968e20280526645f4157de7fca21022a453e7eea23207f87c46881b2e63f56c5ec2e59b30fe887ef29bd21ed67c15d53ae”,        

“amount” : 0.00300000,        

“confirmations” : 1,        

“spendable” : true     }

As you can see by the output and remember this is all in the blockchain  https://blockchain.info/tx/c45c8c00243c703412e207646d51bf6878444537c37372528012f412f552b9cd

SINGRAWTRANSACTION Now we need to sign the release of funds from this address with the

signrawtransaction COMMAND this is the syntax but if you look carefully you will see txid scriptPubKey”, redeemScript and if you look above OUTPUT: with my LISTUNSPENT command you will see this information.

Now you just need the PrivateKey to sign the transaction. signrawtransaction <hex string> [{“txid“:txid,”vout”:n,”scriptPubKey“:hex,”redeemScript“:hex},…] [<privatekey1>,…] [sighashtype=”ALL”]

  • Sign inputs for raw transaction (serialized, hex-encoded).
  • Second optional argument (may be null) is an array of previous transaction outputs that this transaction depends on but may not yet be in the block chain.
  • Third optional argument (may be null) is an array of base58-encoded private keys that, if given, will be the only keys used to sign the transaction.
  • Fourth optional argument is a string that is one of six values; ALL, NONE, SINGLE or ALL|ANYONECANPAY, NONE|ANYONECANPAY, SINGLE|ANYONECANPAY.
  • Returns json object with keys:
    • hex : raw transaction with signature(s) (hex-encoded string)
    • complete : 1 if transaction has a complete set of signature (0 if not)

SENDRAWTRANSACTION  Once all signed the TX it will produce a HEX string – we take that info and add it to

SENDRAWTRANSACTION and I will finally get my Bitcoins and spend them from my Multi-sig wallet. You can keep putting money into this wallet and just have them signed and you can keep getting money out forever- this is just another  Bitcoin wallet address with a few gatekeepers, it harder but more secure in the long run. hope this helps a little – In my new BIP32 wallet I have all this out in a nice GUI to Keep it simple but still have the power of an escrow Multi-sig Wallet- gAtO OuT

3. signrawtransaction <hexstring> [{“txid”:txid,”vout”:n,”scriptPubKey”:hex},…] [<privatekey1>,…] version 0.7 Adds signatures to a raw transaction and returns the resulting raw transaction. Y/N

 

sendrawtransaction <hexstring> version 0.7 Submits raw transaction (serialized, hex-encoded) to local node and network. N

 

4. createrawtransaction [{“txid”:txid,”vout”:n},…] {address:amount,…} version 0.7 Creates a raw transaction spending given inputs. N

 

decoderawtransaction <hex string> version 0.7 Produces a human-readable JSON object for a raw transaction. N

 

listunspent [minconf=1] [maxconf=999999] version 0.7 Returns array of unspent transaction inputs in the wallet.

 

listlockunspent version 0.8 Returns list of temporarily unspendable outputs

 

lockunspent <unlock?> [array-of-objects] version 0.8 Updates list of temporarily unspendable outputs

https://gist.github.com/gavinandresen/3966071