MultiSig (Multisignature)

From Terracoin Wiki
Revision as of 01:53, 21 March 2018 by Clockuniverse (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Multisignature Example

This document presents a worked example to demonstrate multisig functionality in TerracoinCore. While the transactions are no longer visible on the current testnet blockchain and some address formats or RPC responses may differ slightly from the version shown here, the principle and commands are the same.

Step 1: Create three addresses

Seller

 seller@testnet03:~$ ./terracoin-cli getnewaddress n18cPEtj4ZfToPZxRszUz2XPts4eGsxiPk
 seller@testnet03:~$ ./terracoin-cli validateaddress n18cPEtj4ZfToPZxRszUz2XPts4eGsxiPk
 {
   "isvalid" : true,
   "address" : "n18cPEtj4ZfToPZxRszUz2XPts4eGsxiPk",
   "ismine" : true,
   "isscript" : false,
   "pubkey" : "02a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e",
   "iscompressed" : true,
   "account" : ""
 }
 seller@testnet03:~$ ./terracoin-cli dumpprivkey n18cPEtj4ZfToPZxRszUz2XPts4eGsxiPk cVQVgBr8sW4FTPYz16BSCo1PcAfDhpJArgMPdLxKZQWcVFwMXRXx


Buyer

 buyer@testnet03:~$ ./terracoin-cli getnewaddress mp5orHuaFaHCXFSCeYvUPL7H16JU8fKG6u
 buyer@testnet03:~$ ./terracoin-cli validateaddress mp5orHuaFaHCXFSCeYvUPL7H16JU8fKG6u
 {
   "isvalid" : true,
   "address" : "mp5orHuaFaHCXFSCeYvUPL7H16JU8fKG6u",
   "ismine" : true,
   "isscript" : false,
   "pubkey" : "0315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c",
   "iscompressed" : true,
   "account" : ""
 }
 buyer@testnet03:~$ ./terracoin-cli dumpprivkey mp5orHuaFaHCXFSCeYvUPL7H16JU8fKG6u cP9DFmEDb11waWbQ8eG1YUoZCGe59BBxJF3kk95PTMXuG9HzcxnU

Arbiter

 arbiter@testnet03:~$ ./terracoin-cli getnewaddress n1cZSyQXhach5rrj2tm5wg6JC7uZ3qPNiN
 arbiter@testnet03:~$ ./terracoin-cli validateaddress n1cZSyQXhach5rrj2tm5wg6JC7uZ3qPNiN
 {
   "isvalid" : true,
   "address" : "n1cZSyQXhach5rrj2tm5wg6JC7uZ3qPNiN",
   "ismine" : true,
   "isscript" : false,
   "pubkey" : "0287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce",
   "iscompressed" : true,
   "account" : ""
 }
 arbiter@testnet03:~$ ./terracoin-cli dumpprivkey n1cZSyQXhach5rrj2tm5wg6JC7uZ3qPNiN cUbDFL81a2w6urAGZf7ecGbdzM82pdHLeCaPXdDp71s96SzDV49M

Result: Three keypairs (public/private)

 seller:    02a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e / cVQVgBr8sW4FTPYz16BSCo1PcAfDhpJArgMPdLxKZQWcVFwMXRXx
 buyer:     0315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c / cP9DFmEDb11waWbQ8eG1YUoZCGe59BBxJF3kk95PTMXuG9HzcxnU
 arbiter:   0287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce / cUbDFL81a2w6urAGZf7ecGbdzM82pdHLeCaPXdDp71s96SzDV49M

Step 2: Create multisig address

The createmultisig command takes as variables the number n signatures of m keys (supplied as json array) required. In this example, 2 of 3 keys are required to sign the transaction.

Note: The address can be created by anyone, as long as the public keys and their sequence are known (resulting address and redeemScript are identical, see below).

Seller

 seller@testnet03:~$ ./terracoin-cli createmultisig 2 
'["02a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e","0315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c","0287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce"]'
 {
   "address" : "2MuEQCZh7VB8pNrT4bj1CFZQh2oK7XZYLQf",
   "redeemScript" : 
"522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b7
 10af9e9ce53ae"
 }

Buyer

buyer@testnet03:~$ ./terracoin-cli createmultisig 2 '["02a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e","0315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c","0287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce"]'
 {
   "address" : "2MuEQCZh7VB8pNrT4bj1CFZQh2oK7XZYLQf",
   "redeemScript" : "522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce53ae"
 }

Arbiter

arbiter@testnet03:~$ ./terracoin-cli createmultisig 2 
'["02a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e","0315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c","0287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af
9e9ce"]'
 {
   "address" : "2MuEQCZh7VB8pNrT4bj1CFZQh2oK7XZYLQf",
   "redeemScript" : 
"522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b7
10af9e9ce53ae"
 }

Step 3: The buyer funds the multisig address

This works the same as a usual transaction:

Buyer

 buyer@testnet03:~$ ./terracoin-cli sendtoaddress 2MuEQCZh7VB8pNrT4bj1CFZQh2oK7XZYLQf 777.77 a8b3bf5bcace91a8dbbddbf9b7eb027efb9bd001792f043ecf7b558aaa3cb951

The seller/arbiter can trace the transaction by its txid in the testnet block explorer → https://testnet-insight.dashevo.org/insight/tx/a8b3bf5bcace91a8dbbddbf9b7eb027efb9bd001792f043ecf7b558aaa3cb951

Or from the console:

Seller/Arbiter

 seller@testnet03:~$ ./terracoin-cli getrawtransaction a8b3bf5bcace91a8dbbddbf9b7eb027efb9bd001792f043ecf7b558aaa3cb951 1
 {
   "hex" : 
"010000001a2e514dd90f666e3de4cddd22682ae1ca7225988656369d98228c742482fee16b010000006b48304502200ea8dddd404aac644fd382d3089480f2c9a6ce753a3c4fc0b12ac81afe8ffa3b022100d88f698a0d9fefbbf76240790530fe7
e23bf6b354a1feedb4effa99813405b00012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff3181c52614be8742c36665b6a287a2d6c7970494b0a341ff9595c1c9a8f23aa2010000006b483045022041ee
176da4df13adc782c9ff2afdb24c4e1b61b450895486388431bf1a88b81f02210082be1b3bd20d3f121c971fb745cba52523f6b8093ec93df5987c9beb302c19ac012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a661717
2689ffffffff332356f7d5e4264302ca4cc0f38d2a75a9b4c1df4bc4f94044f8a8fab81b7e1b010000006b483045022100dc322074961ae5e2e8cb11828301b1e083eff9ed6078aa064c52ed70d52737410220776b99c8552bbc2e644c7450ef8502d3
497c3de7196b176f1c49cca18d1ff09f012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff388b56a8a74338ce10e931dc198ed25fa4cb7213e0ea9905d32a3e902366661f010000006b48304502206d2cd
fe9af498e9e46f88d0bd881746bf2dae182664d03f7a635ff599bdee84b022100bf3a7b88ed80b30d8915a2ae34d546defbc9a660ebf941afb4aa29461e0b4c95012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172
689ffffffff44578d7579bef2a204359f8c878993480b306193d954ee735c53f8b3e076c3ea010000006c4930460221008a67da5764934392437fa9e05483e4b29204fd5d78dea01f744d4a23c403881b022100c77e58307f58953b578de568138659
b4efd2fadaec51917c2270fab0bd4a57a6012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff4a3b7b666ce8f249ef4f253b7f718fb5cc2f21f899608d319bcc04c75ec47353010000006b48304502203ca5a
0559647ee0d1790714296396ca0bca27a3ef3e68f76706c63da9cd3684f0221008c9529f7a54d89440f8dca89c1c47725821012670d05a70681b57f182b069a74012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a66171
72689ffffffff4ab5d98908e4424929bfdba3d6402e6b45db60a622b4df8c73da1b37bdb949a4010000006b48304502210094da4e007ba94cdb47a8c4805dab4b93dc475a44340a9b6f6d7956d49749e3d3022077b94861995ffe3f59429bf5b87391
4d3c1157f23f018697650bc3bd2dc2de1f012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff4cd58c1ad5b0ffd8556deff402854d94a79222799916be8e0f88d0cca3c38c85010000006b483045022030e7
2eec0386c83489efff8f3c71aed8eec0265565cddeb1492aab6644cc63220221008d6df06656dae12dae573b860d65045f088e4df5e2127902231d8edd4196ef1d012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a66171
72689ffffffff501ff2345fc47b9b7749afcc32e790fdbe5d22fd96b2c5d0522d4cad0cd5566f010000006a47304402204e9bc23796974fdf323c49399ca7db76e2238630add4c617631549f4595af4a80220658038b14884c1a0d730de79c7e2769d4d
28135ed7896e7aff01ca94c8edf7bb012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff5020fe72d4c1038213cc3e1b99f5b313c4b2d57f1e0d9abba90860dc5c38630a010000006a473044022071b7cca
6a7d72fef4b46ad425c23c37f28c72501e5e61821f00e022c4c8ef49502200d8ba406fe336d64a8ae909cad20d0ffe302cd977900013ea72b37c488550625012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689f
fffffff59f32023d4225cc193182e81444f00f6d95652a9458daa08f4324ab4bdac7bed010000006b4830450221009e0f701840c01c2c37e2baec0ea2c43d517126107ef874c3d68f32dfa2e4f05f02206d1306dee274267598d5ab8d7c4c26346d25d
8118b30a6921b9b238307916d6e012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff05b5b8ecaf7bcbd5fdfc64fd7dbd6ebfee18dcaf57e00b6711ba0abe4329eb23010000006a47304402200515822e6
d9641c72f1af7968ba63d47463caffeca03733750b0866ef123fe00022071fd40bac12aa1d36244fc5391162b70ec306a5ed2dffef3a3d4995524317a10012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff
09cc372e4409bcbacd85adb17918ca5b20427dc280b44bd4f234fb698ac07fc6010000006b483045022051e5c430110e8b0d85693c421031f14abf89bee1a14702e6655a1eaa2663927c0221009a54781fddd4093032507f12fe8a97ce926a7438
51a1a56c2ca70026ce98b7e6012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff0963f2cc80666835ae8c5939ac3011d2962ae88e872cdc13257cfb0188f83c7a010000006b483045022032fd819b1cdb
8f506e27f26b3e46330c498b965386c3e96c34dceeff2a517cf7022100a4c34d77ed25116dc05ca7d783bd6cb91c1e38db0541878dac72f2d63d4b7c11012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689fffffff
f14cff38ccbdd840ffc491614e9b5167edb6ad6b9eeaf8e3dc30feaeefa39d820010000006c493046022100f4d6dfce7778acee6bdcf9f2ec39dbf902b6ca977b8622c886eadddefa01bf5502210089b3c2d23b5fc5b03d2d6ea4bf28f04b98342b02dd
7d2020a6466bddd85c3d50012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff63750bbce93657a59fe3472fce714eafa09791fcf7f687f30a923162f2ba5196010000006c493046022100bbbf84829fcc2ec
70bc6d77cfc69f512c1a14359958eee46243001908dc2a0ab0221008f1fbda61fcfccb78fe6d4e6385e8f508035676ef82654425bb704727f1e59b4012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff6466
da482404f4a719f7eb16798d05878af2c36ad7174e2b68964693f39e954b010000006a47304402204d57344da5a1a29ea800215d19ada89787b1026f7e47c2f2f1ea0ef82bec5b6d02203039bd98546843a99d9e6749819875a4d996a682c57a1
92d9e5cef9b694a028b012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff8b0b4a84522fded19446eef3fdd94cc0f7449c71b6e0080837d5f240c78ce03b010000006c493046022100c152177ec49bb572
d70976b53c10d0c4be55584975d657c43e87fbaac8c081ec0221009dd150697257cf769c3e90afbde88fbbe5f95c17c561883546537644ed628f6f012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff8d7
078622b75fc2c3ea1094d07099b0e460a7f7a4c53cf225d066f919f17daf6010000006b483045022100e440d404867748cfba792119faae12d286b265a185cec86215fe2737ec1e7ca402207770447154f81564f7022b375943c2b7eaf3d05a3281c
6f5c70328b098423d7d012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff98c23cc59412943bfedba3b4a48bb2f97f58c119946e5c492031c43a36dd576e010000006c493046022100910cf6fb057269e5
e02fa44fc2ba03925d9e0e3232d3d5a66aac440db9627f9f022100b656d982dec47000de616f21a331b1fb5e19d1ab312c5845f5f1538dac4dd301012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff9d4
851f00e3c2fa22816adc55703fcb539ae0fe218f369f23af079964a6225fc020000006c4930460221009918ee137e4aead4760c79dbe940556ae1ecb7935a653543b486f4198f16cc6a022100f82e04cd970f2c5fd8dd48813e38f87c10ed8fa7b45e
ec1854562948f9d43a1b012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffffa13c3221f0e08289657208bccf7b466ea5795c591751065a20b16f00892bd598010000006b483045022073d9fed13def14a6
55fd423f5c4fa63e46eeea76668cdf8bb89d96630890760d022100f70edce3513c9cbc671f92dc0b4d97c5edc0d9d26f4e726bb2d66776a3b9e411012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffffcac4
f229bd19c47cd15ee9355af8383531a960ba0e0f3e8e4fa0a607ab2000d9010000006b483045022100967624e60a7670e849eb7500cf185620fd65de10d1e5f7cef9131d3c6403cb5f022005182af16fba1b7dbdd27a8935205b439c6034d566c6f
14950aba6bb328cbf79012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffffcbf8cb94ee2bcda1c9ceb54feaf6815441f722b70c4f7569525cc9dee7cbbdc2010000006b4830450221008cfcfdc62f0a398e24
19ebd56cf067e2abadf8116936250939b9fa763dd428680220052c6d316189d5f7164d2423aae99e97d05165f3e5c7d138e2858f0adab4ebba012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffffdbad6d
a5900987f77e5bcf714c935889fbea2d3ff388586a331fe42e0a82efe0010000006c493046022100e80d73130bcd25faa73764f4ff6c05e1b401f3960b7ef30b4244daaf5fce953a022100b99a55caaaa312df54c7d743791052c3e8392725becf91d2
aa886d2e8259af10012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689fffffffffdc2d56fd131ae16837fc86e3015c9e78077dd36b6a2591cf1d500c584bbcc6a010000006b483045022100d13e5a55a4a71e0396
03bd2d3d76a757c63b1d199bcf340e3f2eeb5bed10897c022046a43ecc6cd8295981bde38c34c29708e402db59fc93e657196fc3032858d967012103954bfa8b6b1b0f1f5624ea2925b18cd1477fde2087eada1a51323a6617172689ffffffff0240d6
de1b1200000017a91415c85c2472f5941b60a49462a2cfd0d17ab49d1c87c02fdf67000000001976a914b8d899f7193a7b3278be037b006c8f08998ebef388ac00000000",
   "txid" : "a8b3bf5bcace91a8dbbddbf9b7eb027efb9bd001792f043ecf7b558aaa3cb951",
   "version" : 1,
   "locktime" : 0,
 [...]
   "vout" : [
       {
           "value" : 777.77000000,
           "n" : 0,
           "scriptPubKey" : {
               "asm" : "OP_HASH160 15c85c2472f5941b60a49462a2cfd0d17ab49d1c OP_EQUAL",
               "hex" : "a91415c85c2472f5941b60a49462a2cfd0d17ab49d1c87",
               "reqSigs" : 1,
               "type" : "scripthash",
               "addresses" : [
                   "2MuEQCZh7VB8pNrT4bj1CFZQh2oK7XZYLQf"
               ]
           }
       },
 [...]
   ],
   "blockhash" : "000000034def806f348cadf6a80660aed1cfc30ccbd1492a8ea87062800ea94d",
   "confirmations" : 3,
   "time" : 1409224896,
   "blocktime" : 1409224896
 }

Step 4: Spending the multisig

Now we assume the deal is complete, the buyer got the goods and everyone is happy. Now the seller wants to get his TRC. As a 2-of-3 multisig was used, the transaction must be signed by 2 parties (seller + buyer or arbiter). The seller creates a transaction (we will reuse his public address from above):

seller seller@testnet03:~$ ./terracoin-cli createrawtransaction '[{"txid":"a8b3bf5bcace91a8dbbddbf9b7eb027efb9bd001792f043ecf7b558aaa3cb951","vout":0}]' '{"n18cPEtj4ZfToPZxRszUz2XPts4eGsxiPk":777.77}' 010000000151b93caa8a557bcf3e042f7901d09bfb7e02ebb7f9dbbddba891ceca5bbfb3a80000000000ffffffff0140d6de1b120000001976a914d728be76cd74b5d148eba2a49246b80dac12f73e88ac00000000 and partially signs it, using the redeemScript, scriptPubKey and his private Key

seller seller@testnet03:~$ ./terracoin-cli signrawtransaction '010000000151b93caa8a557bcf3e042f7901d09bfb7e02ebb7f9dbbddba891ceca5bbfb3a80000000000ffffffff0140d6de1b120000001976a914d728be76cd74b5d148eba2a49246b80dac12f73e88ac00000000' '[{"txid":"a8b3bf5bcace91a8dbbddbf9b7eb027efb9bd001792f043ecf7b558aaa3cb951","vout":0,"scriptPubKey":"a91415c85c2472f5941b60a49462a2cfd0d17ab49d1c87","redeemScript":"522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce53ae"}]' '["cVQVgBr8sW4FTPYz16BSCo1PcAfDhpJArgMPdLxKZQWcVFwMXRXx"]' {

   "hex" : "010000000151b93caa8a557bcf3e042f7901d09bfb7e02ebb7f9dbbddba891ceca5bbfb3a800000000b500483045022051a7f0e95a5066859ce37fe64a6e7ab6e30bfe9a68d9d3f1453064052eab5625022100c0067a33d2ee02478d89fc1a71f3a93c883db022e970886181c50ca9afc3dfa4014c69522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce53aeffffffff0140d6de1b120000001976a914d728be76cd74b5d148eba2a49246b80dac12f73e88ac00000000",
   "complete" : false

} Note that the output hex is getting longer, but complete flag is "false" as the transaction needs another signature. So now either the buyer or the arbiter can complete the signature of the transaction, using the output from above and their private key. Let's assume the buyer is completing the signature.

buyer buyer@testnet03:~$ ./terracoin-cli signrawtransaction '010000000151b93caa8a557bcf3e042f7901d09bfb7e02ebb7f9dbbddba891ceca5bbfb3a800000000b500483045022051a7f0e95a5066859ce37fe64a6e7ab6e30bfe9a68d9d3f1453064052eab5625022100c0067a33d2ee02478d89fc1a71f3a93c883db022e970886181c50ca9afc3dfa4014c69522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce53aeffffffff0140d6de1b120000001976a914d728be76cd74b5d148eba2a49246b80dac12f73e88ac00000000' '[{"txid":"a8b3bf5bcace91a8dbbddbf9b7eb027efb9bd001792f043ecf7b558aaa3cb951","vout":0,"scriptPubKey":"a91415c85c2472f5941b60a49462a2cfd0d17ab49d1c87","redeemScript":"522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce53ae"}]' '["cP9DFmEDb11waWbQ8eG1YUoZCGe59BBxJF3kk95PTMXuG9HzcxnU"]' {

   "hex" : "010000000151b93caa8a557bcf3e042f7901d09bfb7e02ebb7f9dbbddba891ceca5bbfb3a800000000fdff0000483045022051a7f0e95a5066859ce37fe64a6e7ab6e30bfe9a68d9d3f1453064052eab5625022100c0067a33d2ee02478d89fc1a71f3a93c883db022e970886181c50ca9afc3dfa401493046022100dc3f61fdb7b8ea7ec729682d355646c922f5512054c4985534e6b91040c5bd660221008b48c117ec95814f573d33bca981cb703fdd9fa6e52aa8fe67423e06cad87215014c69522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce53aeffffffff0140d6de1b120000001976a914d728be76cd74b5d148eba2a49246b80dac12f73e88ac00000000",
   "complete" : true

} The signature is complete now, and either of the parties can transmit the transaction to the network:

buyer buyer@testnet03:~$ ./terracoin-cli sendrawtransaction 010000000151b93caa8a557bcf3e042f7901d09bfb7e02ebb7f9dbbddba891ceca5bbfb3a800000000fdff0000483045022051a7f0e95a5066859ce37fe64a6e7ab6e30bfe9a68d9d3f1453064052eab5625022100c0067a33d2ee02478d89fc1a71f3a93c883db022e970886181c50ca9afc3dfa401493046022100dc3f61fdb7b8ea7ec729682d355646c922f5512054c4985534e6b91040c5bd660221008b48c117ec95814f573d33bca981cb703fdd9fa6e52aa8fe67423e06cad87215014c69522102a862b412ff9e3afd01a2873a02622897f6df92e3fc85597788b898309fec882e210315617694c9d93f0ce92769e050a6868ffc74d229077379c0af8bfb193c3d351c210287ce6cf69b85593ce7db801874c9a2fb1b653dbe5dd9ebfa73e98b710af9e9ce53aeffffffff0140d6de1b120000001976a914d728be76cd74b5d148eba2a49246b80dac12f73e88ac00000000 cf1a75672006a05b38d94acabb783f81976c9e83a8de4da9cbec0de711cf2d71 Again, this transaction can be traced in the explorer → https://testnet-insight.dashevo.org/insight/tx/cf1a75672006a05b38d94acabb783f81976c9e83a8de4da9cbec0de711cf2d71

And the seller is happy to receive his coins at his public address:

seller seller@testnet03:~$ terracoin-cli listtransactions "" 1 [

   {
       "account" : "",
       "address" : "n18cPEtj4ZfToPZxRszUz2XPts4eGsxiPk",
       "category" : "receive",
       "amount" : 777.77000000,
       "confirmations" : 17,
       "blockhash" : "000000067a13e9bd5c1d5ff48cb4b9f8414a6adcc470656262731bfd013510dd",
       "blockindex" : 9,
       "blocktime" : 1409228449,
       "txid" : "cf1a75672006a05b38d94acabb783f81976c9e83a8de4da9cbec0de711cf2d71",
       "time" : 1409227887,
       "timereceived" : 1409227887
   }

] Credits: This example is based on:

https://people.xiph.org/~greg/escrowexample.txt

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

https://bitcoin.org/en/developer-examples#p2sh-multisig

Complex Multisignature Example

This example is based on the process described in the multisignature example and also uses a 2 of 3 multisig address (two of the three signatories need to sign any transaction). Instead of doing an escrow transaction with one input and one output of the same size, this example shows a more complex transaction with more than one input and the amount to send is different to the sum of the inputs, thus creating change/second output.

Unlike in the other example, I will be introducing the commands in the console (Tools > Debug console) of the Terracoin Core wallet. Of course, the results will be same if you follow the procedure from the command line. You just need to add ./terracoin-cli before every command, but if you are using the wallet through the command line you already know that.

I've done this example in mainnet to show things exactly as they are, but please practice in testnet before playing with this yourself. The wallets used are all empty now and won't be used again ever. Never, never, never, ever share your private keys! I only do it here to illustrate the example.

0. Addresses used to sign the multisig Each of the parties involved in the multisig needs to use a regular address under their control to sign the multisig address. Once the address is chosen, each party need to get the public and private key of that address. The first one will be used to create the multisig. The second one will be used to sign the transactions.

What you need:

Valid Terracoin address Command 1:

validateaddress <terracoin address> Result 1:

A block of information in which one of the lines says pubkey: '<pubkey>' Command 2:

dumpprivkey <terracoin address> Result 2:

<private key> Keep the private key in a secure place. With it and the address anyone could take control of that address.

Example:

We'll use three different addresses and get their public and private keys for later usage.

Address 1 Address 1 is XvCxqiSj7AULnZNXYJ5zeASstW7gz52Lj8

>validateaddress XvCxqiSj7AULnZNXYJ5zeASstW7gz52Lj8 >{ "isvalid" : true, "address" : "XvCxqiSj7AULnZNXYJ5zeASstW7gz52Lj8", "ismine" : true, "isscript" : false, "pubkey" : "026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe09", "iscompressed" : true, "account" : "" }

>dumpprivkey XvCxqiSj7AULnZNXYJ5zeASstW7gz52Lj8 >XJ2BYs6CXzU6iyNXpiKdNn5MJRaFMd3C8ZxG4MJcvumnFUb4LCsN Address 2 Address 2 is XiVQMztV7UmeubeJxJpbXn8Da3cPXc5urv

>validateaddress XiVQMztV7UmeubeJxJpbXn8Da3cPXc5urv >{ "isvalid" : true, "address" : "XiVQMztV7UmeubeJxJpbXn8Da3cPXc5urv", "ismine" : true, "isscript" : false, "pubkey" : "032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a1", "iscompressed" : true, "account" : "" }


>dumpprivkey XiVQMztV7UmeubeJxJpbXn8Da3cPXc5urv >XEAEtxdUsHb77hDXLoPPsc9qxtzyqBzxbdVh5cJsuERpf1opopYu Address 3 Address 3 is XhUCZ4KHjZatLKKiKMpZDCs7oRADRm9eSC

>validateaddress XhUCZ4KHjZatLKKiKMpZDCs7oRADRm9eSC >{ "isvalid" : true, "address" : "XhUCZ4KHjZatLKKiKMpZDCs7oRADRm9eSC", "ismine" : true, "isscript" : false, "pubkey" : "03893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a", "iscompressed" : true, "account" : "" }

>dumpprivkey XhUCZ4KHjZatLKKiKMpZDCs7oRADRm9eSC >XJ6eMaQQaXB6x5z6NpSHjgdqcECskNaVpMqA12CnmUqQSdGqZGub


1. Creation of the multisig address This can be done by any of the parts involved.

What you need:

Public keys of the addresses associated with the multisig. Command:

createmultisig 2 '["<pubkey1>", "<pubkey2>", "<pubkey3>"]' The '2' is the number of signatures required to sign any transaction. It is possible to use more public keys and a different number of signatures, with the maximum at 30 addresses and 15 signatures.

Result:

<mulisig address> <redeemption script> If the order of the public keys is the same, the result will be the same, no matter who does this step.

It is extremely important to keep the redemption script because it is needed to do any transaction. Multisig addresses don't reside in a wallet and have private/public keys, they live in the blockchain and have a redemption script.

Example:

We'll create the multisig address using the three public keys obtained in the previous step. Two signatures will be required.

Creation of multisig address >createmultisig 2 '["026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe09", "032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a1", "03893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a"]' >{ "address" : "359N4Eq8EDv2ePhcFshWa8NeZMTCBWmaCL", "redeemScript" : "5221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53ae" }


2. Funding the multisig A multisig works exactly as a regular address to receive funds. Anyone can send without any special procedure. Some exchanges or services may produce an error when trying to send to a multisig if they are running an old version of the daemon, but this is very unlikely. If you find one of those instances, please report and send from another wallet.

In this case, I'll do two different transactions to have two inputs to use later.

You'll need to keep track of the transaction ids because you'll need them later to spend from the multisig.

Example:

First transaction id: 50f96b51bf594b0998babb9fe7a4f3399b6c04c3836c1a7cde0e4a2413b29784 Vout: 1 Amount: 1.2 TRC

Second transaction id: 60bfdb8aaf9fda189fcd2fce086da97bfb3e7fd3cb586f435e7ff1eb3f3041bc Vout: 1 Amount: 1.397 TRC

You can always get this information from the blockchain explorer because the transactions look exactly as any other transaction.



3. Sending from the multisig The process to send from a multisig is tedious because it can't be done from the GUI of the wallet and it has a few steps:

Signatory 1 creates of a raw transaction Signatory 1 signs the raw transaction Signatory 1 sends the information to signatory 2 Signatory 2 signs the raw transaction Signatory 2 broadcasts the raw transaction to the network 3.1 Creation of the raw transaction Any of the signatories can do this, but the usual thing will be that the first signatory do it.

What you need:

Transaction ids of the outputs of transactions to the multisig that are going to be used, with their amount and output index number (vout). You can get all data from the blockchain explorer Addresses to be paid and amounts The amounts of the outputs used (now inputs) need to be the same as the amounts paid. If there is any difference, it will be considered fee, so you need to check that numbers to avoid paying a huge fee by mistake. This means that you need to create the change of the transaction manually if there is any. In the case of a multisig, there are no other addresses in the same wallet to receive the change, so you'll need to pay the change to the multisig address.

You can manually calculate the fee by calculating the size of the transaction. Multisig transactions are bigger than standard transactions and vary in size because of the script they carry (maximum size allowed is 520 bytes), so calculating the size of the transaction is not easy. Also, if you are dealing with very small outputs, it is possible that you'll need to include another output to pay the fee and that will change the size again and may change the fee. To avoid spending a lot of time with this calculations I recommend paying a higher fee than usual, let's say 0.002 TRC, and that will solve almost every case. If you get a code 22 error when broadcasting the transaction you'll know it is because the fee is not enough and you will need to recalculate.

Command:

createrawtransaction '[{"txid":"<transaction id>","vout":<output index number>}, {"txid":"<transaction id>","vout":<output index number>}...]' '{"<Address to pay>":<amount>, "<Address to pay>":<amount>...}' Notice how in the first part of the command we have the outputs, with the data of each output inside curly brackets and each output separated with commas. And how in the second part we have the addresses paid with their amounts, separated with commas. The ellipsis are not needed, they simply represent that you could keep introducing inputs/outputs in the same way.

Result:

<long hex of the transaction> Example:

We'll send 1.8 TRC to the address Xcy4V4iAugosK9eWt82y6HKmEmZu4TuD5X. We'll pay a fee of 0.002 TRC and send the change (0.795 TRC) back to the multisig address.

Create raw transaction >createrawtransaction '[{"txid":"50f96b51bf594b0998babb9fe7a4f3399b6c04c3836c1a7cde0e4a2413b29784","vout":1}, {"txid":"60bfdb8aaf9fda189fcd2fce086da97bfb3e7fd3cb586f435e7ff1eb3f3041bc","vout":1}]' '{"Xcy4V4iAugosK9eWt82y6HKmEmZu4TuD5X":1.8, "359N4Eq8EDv2ePhcFshWa8NeZMTCBWmaCL":0.795}'

>01000000028497b213244a0ede7c1a6c83c3046c9b39f3a4e79fbbba98094b59bf516bf9500100000000ffffffffbc41303febf17f5e436f58cbd37f3efb7ba96d08ce2fcd9f18da9faf8adbbf600100000000ffffffff020095ba0a000000001976a914190177df014c749fb3ecad30e9e286988135165988ace012bd040000000017a91425e3ff8ede18aeeacc948d17e641af482ac693d28700000000


3.2 Signature of the raw transaction This will usually be done by the creator of the transaction.

What you need:

Hex of the transaction created in the previous step Private key of the address used to sign by signatory 1 Transaction ids of the outputs of transactions to the multisig that are going to be used, with their output index number (vout) and scriptPubKey hex. Most of the data you'll have from the previous step. To obtain the scriptPubKey hex you only need to type in the console:

getrawtransaction <transaction id> 1 Don't forget the '1' at the end or you'll get a crazy block of data instead of an array. You'll get a lot of information for every vout in that transaction. The one you need is the hex string of the vout you are using.

Command:

signrawtransaction '<long hex of the transaction obtained in the previous step>' '[{"txid":"<transaction id>","vout":<output index number>,"scriptPubKey":"<scriptPubKey hex>","redeemScript":"<redeemScript>"}, {"txid":"<transaction id>","vout":<output index number>,"scriptPubKey":"<scriptPubKey hex>","redeemScript":"<redeemScript>"}...]' '["<signatory private key>"]' Result:

Array with <even longer hex of the transation> and a 'false' statement that indicates that the transaction is not yet fully signed. Example:

The owner of address 1 will sign the transaction. First he'll get the scriptPubKey from the transactions received using the command getrawtransaction.

Get raw transactions data >getrawtransaction 50f96b51bf594b0998babb9fe7a4f3399b6c04c3836c1a7cde0e4a2413b29784 1 >{ "hex" : "01000000019d4b4e841753700cb255bd622e1b91074bfc19db1eb87fcdd7c534cf6d6f7b13000000006a47304402207a2aa961bea5e652a7856f50918326ab952f229d32499b047dd47cfe9a8fe26402202f4e56ab50e29cb94f92ea378442b80295ddf5712e5a1e186cacaecfeed45d9701210381a58e09f94aada16b331307fb53c88196e5ed427e42d9d4d6ae3473187a8903ffffffff02c087b70a000000001976a914c0cf8285d89ab0d7d650d14762b0c54b60a806cc88ac000e27070000000017a91425e3ff8ede18aeeacc948d17e641af482ac693d28700000000", "txid" : "50f96b51bf594b0998babb9fe7a4f3399b6c04c3836c1a7cde0e4a2413b29784", "version" : 1, "locktime" : 0, "vin" : [ { "txid" : "137b6f6dcf34c5d7cd7fb81edb19fc4b07911b2e62bd55b20c705317844e4b9d", "vout" : 0, "scriptSig" : { "asm" : "304402207a2aa961bea5e652a7856f50918326ab952f229d32499b047dd47cfe9a8fe26402202f4e56ab50e29cb94f92ea378442b80295ddf5712e5a1e186cacaecfeed45d9701 0381a58e09f94aada16b331307fb53c88196e5ed427e42d9d4d6ae3473187a8903", "hex" : "47304402207a2aa961bea5e652a7856f50918326ab952f229d32499b047dd47cfe9a8fe26402202f4e56ab50e29cb94f92ea378442b80295ddf5712e5a1e186cacaecfeed45d9701210381a58e09f94aada16b331307fb53c88196e5ed427e42d9d4d6ae3473187a8903" }, "sequence" : 4294967295 } ], "vout" : [ { "value" : 1.79800000, "n" : 0, "scriptPubKey" : { "asm" : "OP_DUP OP_HASH160 c0cf8285d89ab0d7d650d14762b0c54b60a806cc OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a914c0cf8285d89ab0d7d650d14762b0c54b60a806cc88ac", "reqSigs" : 1, "type" : "pubkeyhash", "addresses" : [ "XtGLA83wYYYyhiENCwLYj32t8VDRJHWbcP" ] } }, { "value" : 1.20000000, "n" : 1, "scriptPubKey" : { "asm" : "OP_HASH160 25e3ff8ede18aeeacc948d17e641af482ac693d2 OP_EQUAL", "hex" : "a91425e3ff8ede18aeeacc948d17e641af482ac693d287", "reqSigs" : 1, "type" : "scripthash", "addresses" : [ "359N4Eq8EDv2ePhcFshWa8NeZMTCBWmaCL" ] } } ], "blockhash" : "0000000000025959d4dccb43857cdb806380353f5cf42e698d284b79f712d972", "confirmations" : 44, "time" : 1417558942, "blocktime" : 1417558942 }


>getrawtransaction 60bfdb8aaf9fda189fcd2fce086da97bfb3e7fd3cb586f435e7ff1eb3f3041bc 1 >{ "hex" : "01000000018497b213244a0ede7c1a6c83c3046c9b39f3a4e79fbbba98094b59bf516bf950000000006b4830450220732a8ff7341551cd21eb098f901ff553aeaaf7e8f34cbdd1f2befced5396d683022100e885ca09fe3e8fbd3cf55cf19c1763cdce234d819702fa191aa8e39554c501d30121037673d7a1055dc51a64660ba578b49dab6a23fd950a4d9906ee713412fd2169dbffffffff02005a6202000000001976a9144005d5f5156a45bfdf016204e8fdaa950304b95988ac20a753080000000017a91425e3ff8ede18aeeacc948d17e641af482ac693d28700000000", "txid" : "60bfdb8aaf9fda189fcd2fce086da97bfb3e7fd3cb586f435e7ff1eb3f3041bc", "version" : 1, "locktime" : 0, "vin" : [ { "txid" : "50f96b51bf594b0998babb9fe7a4f3399b6c04c3836c1a7cde0e4a2413b29784", "vout" : 0, "scriptSig" : { "asm" : "30450220732a8ff7341551cd21eb098f901ff553aeaaf7e8f34cbdd1f2befced5396d683022100e885ca09fe3e8fbd3cf55cf19c1763cdce234d819702fa191aa8e39554c501d301 037673d7a1055dc51a64660ba578b49dab6a23fd950a4d9906ee713412fd2169db", "hex" : "4830450220732a8ff7341551cd21eb098f901ff553aeaaf7e8f34cbdd1f2befced5396d683022100e885ca09fe3e8fbd3cf55cf19c1763cdce234d819702fa191aa8e39554c501d30121037673d7a1055dc51a64660ba578b49dab6a23fd950a4d9906ee713412fd2169db" }, "sequence" : 4294967295 } ], "vout" : [ { "value" : 0.40000000, "n" : 0, "scriptPubKey" : { "asm" : "OP_DUP OP_HASH160 4005d5f5156a45bfdf016204e8fdaa950304b959 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a9144005d5f5156a45bfdf016204e8fdaa950304b95988ac", "reqSigs" : 1, "type" : "pubkeyhash", "addresses" : [ "XgXN51N5BBYa8dd6xBQwZqjG6mRSotj3oX" ] } }, { "value" : 1.39700000, "n" : 1, "scriptPubKey" : { "asm" : "OP_HASH160 25e3ff8ede18aeeacc948d17e641af482ac693d2 OP_EQUAL", "hex" : "a91425e3ff8ede18aeeacc948d17e641af482ac693d287", "reqSigs" : 1, "type" : "scripthash", "addresses" : [ "359N4Eq8EDv2ePhcFshWa8NeZMTCBWmaCL" ] } } ], "blockhash" : "0000000000025959d4dccb43857cdb806380353f5cf42e698d284b79f712d972", "confirmations" : 44, "time" : 1417558942, "blocktime" : 1417558942 }

First signature of transaction >signrawtransaction '01000000028497b213244a0ede7c1a6c83c3046c9b39f3a4e79fbbba98094b59bf516bf9500100000000ffffffffbc41303febf17f5e436f58cbd37f3efb7ba96d08ce2fcd9f18da9faf8adbbf600100000000ffffffff020095ba0a000000001976a914190177df014c749fb3ecad30e9e286988135165988ace012bd040000000017a91425e3ff8ede18aeeacc948d17e641af482ac693d28700000000' '[{"txid":"50f96b51bf594b0998babb9fe7a4f3399b6c04c3836c1a7cde0e4a2413b29784","vout":1,"scriptPubKey":"a91425e3ff8ede18aeeacc948d17e641af482ac693d287","redeemScript":"5221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53ae"}, {"txid":"60bfdb8aaf9fda189fcd2fce086da97bfb3e7fd3cb586f435e7ff1eb3f3041bc","vout":1,"scriptPubKey":"a91425e3ff8ede18aeeacc948d17e641af482ac693d287","redeemScript":"5221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53ae"}]' '["XJ2BYs6CXzU6iyNXpiKdNn5MJRaFMd3C8ZxG4MJcvumnFUb4LCsN"]' >{ "hex" : "01000000028497b213244a0ede7c1a6c83c3046c9b39f3a4e79fbbba98094b59bf516bf95001000000b4004730440220282a525d4254babb991853ca55cc7ffe6a2dbdc76771e34cf6c05f2ae7ab5caa022069698132015411873be76a727c5dcf47895f1439076f62b013f14558db93efdb014c695221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53aeffffffffbc41303febf17f5e436f58cbd37f3efb7ba96d08ce2fcd9f18da9faf8adbbf6001000000b500483045022100b8c2d316a855f56b196c27925162769987b323f99072b6f199919519e350a08e02205387d8bf0deaa9965384f4648adfe4edb73b72ed0d834a2be79574bbb6493a05014c695221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53aeffffffff020095ba0a000000001976a914190177df014c749fb3ecad30e9e286988135165988ace012bd040000000017a91425e3ff8ede18aeeacc948d17e641af482ac693d28700000000", "complete" : false }



3.3 Signatory 1 sends the information to signatory 2 Signatory 1 will need to send the crazy long hex to signatory 2. Aside of that, it is useful if he also sends the data of outputs used in the transaction so he doesn't have to look for them.

3.4 Signatory 2 signs the transaction What you need:

Hex of the transaction sent by signatory 1 Private key of the address used to sign by signatory 2 Transaction ids of the outputs of transactions to the multisig that are going to be used, with their output index number (vout) and scriptPubKey hex. Signatory 1 can provide this. Command:

signrawtransaction '<hex of the transaction sent by signatory 1>' '[{"txid":"<transaction id>","vout":<output index number>,"scriptPubKey":"<scriptPubKey hex>","redeemScript":"<redeemScript>"}, {"txid":"<transaction id>","vout":<output index number>,"scriptPubKey":"<scriptPubKey hex>","redeemScript":"<redeemScript>"}...]' '["<signatory private key>"]' Result:

Array with <hilariously long hex of the transation> and a 'true' statement that indicates that the transaction is now fully signed. Example:

The owner of address 2 signs the transaction.

Second signature of transaction >signrawtransaction '01000000028497b213244a0ede7c1a6c83c3046c9b39f3a4e79fbbba98094b59bf516bf95001000000b4004730440220282a525d4254babb991853ca55cc7ffe6a2dbdc76771e34cf6c05f2ae7ab5caa022069698132015411873be76a727c5dcf47895f1439076f62b013f14558db93efdb014c695221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53aeffffffffbc41303febf17f5e436f58cbd37f3efb7ba96d08ce2fcd9f18da9faf8adbbf6001000000b500483045022100b8c2d316a855f56b196c27925162769987b323f99072b6f199919519e350a08e02205387d8bf0deaa9965384f4648adfe4edb73b72ed0d834a2be79574bbb6493a05014c695221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53aeffffffff020095ba0a000000001976a914190177df014c749fb3ecad30e9e286988135165988ace012bd040000000017a91425e3ff8ede18aeeacc948d17e641af482ac693d28700000000' '[{"txid":"50f96b51bf594b0998babb9fe7a4f3399b6c04c3836c1a7cde0e4a2413b29784","vout":1,"scriptPubKey":"a91425e3ff8ede18aeeacc948d17e641af482ac693d287","redeemScript":"5221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53ae"}, {"txid":"60bfdb8aaf9fda189fcd2fce086da97bfb3e7fd3cb586f435e7ff1eb3f3041bc","vout":1,"scriptPubKey":"a91425e3ff8ede18aeeacc948d17e641af482ac693d287","redeemScript":"5221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53ae"}]' '["XEAEtxdUsHb77hDXLoPPsc9qxtzyqBzxbdVh5cJsuERpf1opopYu"]' >{ "hex" : "01000000028497b213244a0ede7c1a6c83c3046c9b39f3a4e79fbbba98094b59bf516bf95001000000fc004730440220282a525d4254babb991853ca55cc7ffe6a2dbdc76771e34cf6c05f2ae7ab5caa022069698132015411873be76a727c5dcf47895f1439076f62b013f14558db93efdb0147304402207725bec0286380d6ec91ed786f5dc766d4555d2e9a3b7e02e088ebf01d74387702201377d7a5e2e357bd5d5c156422850df3ecd006ce9c0614504b034aa774c6fa96014c695221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53aeffffffffbc41303febf17f5e436f58cbd37f3efb7ba96d08ce2fcd9f18da9faf8adbbf6001000000fdfd0000483045022100b8c2d316a855f56b196c27925162769987b323f99072b6f199919519e350a08e02205387d8bf0deaa9965384f4648adfe4edb73b72ed0d834a2be79574bbb6493a0501473044022065a7abab6bf28a7b9047639da02d651e260d036c40fe25eec0e79dd7f9c4fdba0220386155b9318b2b8fd3bc715cf022c54d2dfacc984cac4937bca117253e659ee5014c695221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53aeffffffff020095ba0a000000001976a914190177df014c749fb3ecad30e9e286988135165988ace012bd040000000017a91425e3ff8ede18aeeacc948d17e641af482ac693d28700000000", "complete" : true }


3.5 Broadcast of the transaction This will usually be done by signatory 2, but once it is fully signed anyone could do it. This is the easiest step.

What you need:

Hilariously long hex of the transation from the previous step Command:

sendrawtransaction <hilariously long hex of the transation> Result:

<transaction id> And it is done. Sit down, relax and watch this beautiful transaction get included in a block.

Example:

The owner of address 2 sends the transaction to the network and gets the transaction id.

Transaction broadcast >sendrawtransaction 01000000028497b213244a0ede7c1a6c83c3046c9b39f3a4e79fbbba98094b59bf516bf95001000000fc004730440220282a525d4254babb991853ca55cc7ffe6a2dbdc76771e34cf6c05f2ae7ab5caa022069698132015411873be76a727c5dcf47895f1439076f62b013f14558db93efdb0147304402207725bec0286380d6ec91ed786f5dc766d4555d2e9a3b7e02e088ebf01d74387702201377d7a5e2e357bd5d5c156422850df3ecd006ce9c0614504b034aa774c6fa96014c695221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53aeffffffffbc41303febf17f5e436f58cbd37f3efb7ba96d08ce2fcd9f18da9faf8adbbf6001000000fdfd0000483045022100b8c2d316a855f56b196c27925162769987b323f99072b6f199919519e350a08e02205387d8bf0deaa9965384f4648adfe4edb73b72ed0d834a2be79574bbb6493a0501473044022065a7abab6bf28a7b9047639da02d651e260d036c40fe25eec0e79dd7f9c4fdba0220386155b9318b2b8fd3bc715cf022c54d2dfacc984cac4937bca117253e659ee5014c695221026c80e3efcdd4247ee29ee73829023aa3bcd464b709879128085d661c5a24fe0921032840e4d6aa1bea14d964e559f7b0ac01eac27274a03333d19faae8bee33c28a12103893120d3e2bac81f5bb6dbd320feed1f57ca39dd57a8c1266b9372acae45de8a53aeffffffff020095ba0a000000001976a914190177df014c749fb3ecad30e9e286988135165988ace012bd040000000017a91425e3ff8ede18aeeacc948d17e641af482ac693d28700000000 >a2d087c1423532abce2f439d2f3278ae260ea48c87778dffb9fe79e1a7042e40 Credits and more info Multisignature example by Holger Schinzel

Escrow example by Gavin Adresen

BIP0016 - Pay to Script Hash by Gavin Adresen

Bitcoin developer examples - P2SH Multisig

Transaction fees in Bitcoin wiki

Transactions in Bitcoin wiki