github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/website/gocoin_manual_multisig.html (about) 1 <html> 2 <head> 3 <link rel="stylesheet" href="style.css" type="text/css"> 4 </head> 5 <body> 6 <h1>Multi-signature</h1> 7 Support for a multiple signature (otherwise known as multisig) addresses is a very useful feature of the existing Bitcoin protocol, though it requires some background knowledge in order to use it.<br><br> 8 <br> 9 Most of the existing bitcoin wallets have no problems with sending money to multisig addresses, even if they don't support spending money from such. Gocoin can handle both.<br> 10 <br> 11 <b>What a multisig address is</b><br> 12 A multisig address defines a set of public keys that are authorized to spend money from it and the minimum number of signatures needed to spend the money.<br> 13 Obviously each of these needed signatures must be made with a different key from the predefined set.<br> 14 Saying otherwise: multisig address states how many of the keys must sign a specific transaction, in order for it to be valid.<br> 15 Multisig address looks just like a regular bitcoin address, except that it doesn't start with 1, but (usually) with 3.<br> 16 <br> 17 18 <b>Escrow</b><br> 19 An example user case for a multisig address would be an escrow transaction.<br> 20 Alice wants to send some coins to Bob, but only after Bob delivers a certain thing. So they find a third person who would act as the escrow judge - let's call him Carl.<br> 21 They need a multisig address that requires 2 signatures out of 3 addresses.<br> 22 So each of the three parties provides a public key from its private wallet: pubA, pubB, pubC - and they make a multisig address out of these 3 keys, that requires 2 signatures.<br> 23 Now Alice sends coins to this address and waits for Bob to deliver the certain thing...<br> 24 What is important here is that any two of the three can spend the money from this multisig address.<br> 25 So if Alice and Bob do not want to bother Carl - they can just finalize the transaction by themselves.<br> 26 But if either Alice or Bob would not be willing to cooperate any further - the other person can still spend the coins, deposited at the escrow address, if only Carl helps by providing his signature.<br> 27 <br> 28 29 <b>Multiple authentications</b><br> 30 Another useful feature of the multisig addresses is a possibility to protect coins with several different wallets.<br> 31 The simplest scenario would be 2 signatures out of 2 addresses - both are needed in order to spend the coins.<br> 32 You have one wallet on one device (e.g. your PC) and a second wallet on a different device (a smartphone) - to spend the money you must sign the transaction with both your wallets.<br> 33 So if a wallet on any of the two devices gets stolen, or otherwise compromised, your coins should still be safe because the attacker needs both the wallets to spend the money.<br> 34 You can also think of combinations like 2 out of of 3, or even 3 out of 5 - making it not only more secure, but also safer for you in case if you'd loose access to one of the wallets.<br> 35 Multiple authentications can be of course also applied to different people holding the wallets - e.g. employees of a certain organization.<br> 36 <br> 37 38 39 <h2>Make multisig address</h2> 40 To create a multisig address you are going to need the public keys which will be entitled to spend a money from it.<br> 41 Obviously each of the keys would come from a different wallet (otherwise using multisig doesn't make any sense).<br> 42 <br> 43 44 <b>Gather the public keys</b><br> 45 Below we describe how to extract a public key from a Gocoin wallet, but of course a public key can come from any wallet software, not necessarily the one that is a part of Gocoin.<br> 46 To fetch a public key from an existing Gocoin wallet, just execute:<br> 47 <code> wallet -pub 1EqUmBY4wHQ5TmrPqWRCU5Etf6jo9yLwnu</code><br> 48 This will print you a line like this:<br> 49 <code> 1EqUmBY4wHQ5TmrPqWRCU5Etf6jo9yLwnu => 0361e5c0bff39f18621693da42cd343d60e3e14b4e9eb46b220eb310a484fcebab</code><br> 50 <i>(0361e5c0bff39f18621693da42cd343d60e3e14b4e9eb46b220eb310a484fcebab - this is the public key)</i><br> 51 Now repeat the "-pub <address>" operation, for each of the wallets that you want to participate in the multisig address, writing down each public key it returned.<br> 52 <br> 53 54 <b>Create multisig address</b><br> 55 Having all the public keys (each as a hexdump) just bring them all together and use the <b>mkmulti</b> tool (tools/mkmulti.go) to crate the multisig address:<br> 56 <code> mkmulti <number_of_sigs_needed_for_spending> <pubkey1> <pubkey2> <pubkey3> ...</code><br> 57 <i>(for testnet, just use a negative number)</i><br> 58 For example:<br> 59 <code> mkmulti 2 0361e5c0bff39f18621693da42cd343d60e3e14b4e9eb46b220eb310a484fcebab 032ff4e2041a4525404ec76bb6f2328f906d28b6222344771c991659d0efc79b58 \</code><br> 60 <code> 0263e98b52afddeeb81c7e6e0bcb89e1c23c12c809da7f6cb16d899eda8554ec1b</code><br> 61 This will create a file named 3DAHwsGVN5wQnhR3Ax9AXw5czZbk83z2CV.json containing all kind of useful info.<br> 62 Store this file for the future. It doesn't contain big secrets (just the public keys), so you should not need to hide it quite much.<br> 63 This address (3DAHwsGVN5wQnhR3Ax9AXw5czZbk83z2CV) is an actual bitcoin address and you can send money to it.<br> 64 <br> 65 66 67 <h2>Add multisig address to your wallet</h2> 68 You can add multisig addresses to the client's wallets, just like any other address.<br> 69 To do this use the <b>Edit</b> button on the <b>Wallet</b> page of the WebUI.<br> 70 Like with the regular addresses you can also append a label to multisig address, after a space.<br> 71 <br> 72 <i><b>Note</b>: in order to use Gocoin for spending anything from a multisig address, you will need to have the address added to your currently selected wallet file.</i><br> 73 <br> 74 75 <h2>Spend from your multisig address</h2> 76 Make sure that the currently selected wallet has the multisig address in it and the address itself has some unspent coins.<br> 77 Now go to <b>MakeTx</b> tab of the WebUI.<br> 78 <br> 79 You will need to pass your transaction through all the parties/wallets that are supposed to sign it. The output transaction from one party/wallet becomes an input transaction for the next one. The output from the last wallet should already be a sufficiently signed transaction that only needs to be sent to the network. Send it out using the same way as for regular (non multisig) transactions.<br> 80 <br> 81 At any moment when signing your transaction it may be useful to look inside it by executing:<br> 82 <code> wallet -d 012345678.txt</code><br> 83 <br> 84 85 <i><b>Note</b>: Singing of multisig inputs does not require the balance folder. You only need to pass a raw transaction file through the multisig signing wallets.<br> 86 </i> 87 <br> 88 <br> 89 90 Select the input you want to spend In <b>MakeTx</b> page. You can select several inputs from the same address, but do not mix different addresses here.<br> 91 Fill in the payment details as usually and download the <b>payment.zip</b><br> 92 What you need at this moment is just the <b>tx2sign.txt</b> from the zip.<br> 93 <br> 94 95 Now take the value (the hexdump) of "redeemScript" from the .json file describing the address that you are spending money from (created before with 96 <code>mkmulti</code>).<br> 97 It doesn't quite matter on which PC you would execute this command:<br> 98 <code> wallet -raw tx2sign.txt -p2sh <hexdump_value_of_redeemScript></code><br> 99 This command should produce file <b><code>multi2sign.txt</code></b> - that is the file you will need to sing now.<br> 100 <br> 101 102 So take <code>multi2sign.txt</code> to your first wallet machine and execute:<br> 103 <code> wallet -raw multi2sign.txt</code><br> 104 105 106 This should create a new raw transaction file (named like 107 <code>01234567.txt</code>) that already has the fist required signature inside.<br> 108 If you need more signatures, just keep repeating the "<code>wallet -raw <txfile.txt></code>" command at other wallets that are entitled to sign it. Remember to always use the most recently created raw transaction file.<br> 109 110 <br> 111 112 <i><b>Note:</b> You can specify a specific signing key by adding <code>-msign <addr></code> switch. Otherwise all keys known to the wallet will be used.</i> 113 </body> 114 </html>