This is gmaxwell's 2-of-2 escrow example, adapted to Electrum and to a lesser extent, GFM.
Archey wants to pay Bertha 0.001 BTC for a Twitter Platinum invite, but prevent Bertha from cheating him. Archey selects Iceland to act as a neutral mediator in case something unexpected happens.
Each party begins by selecting a new Bitcoin address, and then sharing it with the others. These addresses - three in total - are combined to create a three-pronged Bitcoin address. This three-pronged address will require the consent of two of {Archey, Bertha, Iceland} in order for either Archey or Bertha to withdraw funds from it as per the terms of their agreement. This address will visually differ from normal Bitcoin addresses - it will begin with the number '3' unless testnet is used, in which case it will begin with the number '2'.
The purpose of this document is to demonstrate the Electrum CLI's effectiveness in facilitating safer Bitcoin transactions with multisig.
We're assuming Archey and Bertha have already agreed to the Twitter Platinum invite's terms of sale. By following these instructions, they will both greatly mitigate counterparty risk for little to no cost.
[archey@archey ~]$ electrum -w archey.dat create -o
[archey@archey ~]$ electrum -w archey.dat listaddresses -o
[
"131HaWvMSKCpax1XFrKmDCV5y7CEyjiBTi",
"19Ub8Tsbv1tH1dMff67DfJwCBGvWXXcmak",
"1K1JVF15aRbRefi64NE7nT5e4h31v8EsmT",
"17ZWgLgBQDqspXUg2Q6RjYBLvxvNLgdyiu",
"1DW37u9T2cAGDoaDJsi9pJCTRuV218E8q"
]
getpubkeys
is used to get the pubkey for each address, which is
what we need to create the multisig address.
[archey@archey ~]$ electrum -w archey.dat getpubkeys 131HaWvMSKCpax1XFrKmDCV5y7CEyjiBTi -o
{
"address": "131HaWvMSKCpax1XFrKmDCV5y7CEyjiBTi",
"pubkeys": [
"045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a87"
]
}
[bertha@bertha ~]$ electrum -w bertha.dat create -o
[bertha@bertha ~]$ electrum -w bertha.dat listaddresses -o
[
"17ZuDFwDbToWYXvPsPdp1yrwdqg56Q8849",
"1DZUEifn2fMAMzSFvZMJJ7kskGcacJxjSW",
"1E4e8dkC72cGET9FbmXQKtRmeALiNzw9vr",
"1B6Nj11StLPqTwz4vSCG4QRstX24dbsfz8",
"1MoTBGmxWyZ9hh239mc4btCnEKFQs5Dz33"
]
[bertha@bertha ~]$ electrum -w bertha.dat getpubkeys 17ZuDFwDbToWYXvPsPdp1yrwdqg56Q8849 -o
{
"address": "17ZuDFwDbToWYXvPsPdp1yrwdqg56Q8849",
"pubkeys": [
"048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd"
]
}
[iceland@iceland ~]$ electrum -w iceland.dat create -o
[iceland@iceland ~]$ electrum -w iceland.dat listaddresses -o
[
"1E8NsoUerqMn3MJeddoZiAWZmaifvjVney",
"1NN5fKFebYbRsEDRbmq1FcUu3cBwpC4Y3v",
"1Nsy14Njyqf7LgCR8KYe38AgAXihrpwkL4",
"1QFRWqGLN8jeUeyAFSpcWwGeiorYqmvWW8",
"17n3jcRyDqnChrxUm69RVLryc1C61jPkY7"
]
[iceland@iceland ~]$ electrum -w iceland.dat getpubkeys 1E8NsoUerqMn3MJeddoZiAWZmaifvjVney -o
{
"address": "1E8NsoUerqMn3MJeddoZiAWZmaifvjVney",
"pubkeys": [
"0405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d19"
]
}
$ electrum -w [archey|bertha|iceland].dat createmultisig 2 '["045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a87", "048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd", "0405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d19"]' -o
{
"address": "3QYXGuu38nqYZtJwcc91EqzqKH57ECnGXn",
"redeemScript": "5241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953ae"
}
The above command produces the same output for Archey, Bertha and
Iceland. The multisig address 3QYXGuu38nqYZtJwcc91EqzqKH57ECnGXn
has been created.
The three prongs of this multisig address are:
- Archey:
131HaWvMSKCpax1XFrKmDCV5y7CEyjiBTi
- Bertha:
17ZuDFwDbToWYXvPsPdp1yrwdqg56Q8849
- Iceland:
1E8NsoUerqMn3MJeddoZiAWZmaifvjVney
Now Archey sends 0.001 BTC to the multisig address 3QYXGuu38nqYZtJwcc91EqzqKH57ECnGXn
.
[archey@archey ~]$ electrum -w archey.dat mktx --fromaddr 19Ub8Tsbv1tH1dMff67DfJwCBGvWXXcmak --changeaddr 12FuyWvTuUfFWiJeGkjDaDkCLPfaXvBuTH --fee 0.0001 3QYXGuu38nqYZtJwcc91EqzqKH57ECnGXn 0.001
Password:
{
"complete": true,
"hex": "010000000164684fa0b030db0cf9ee756fe39d3fa20792999de38cf9ba28708a4b1eb46854010000008c493046022100b42e9c06506af9528b58ea0c21540c6c1693f5edb3ea86df84d1f79d558a33a1022100f181f2fa0d7018975c6fa762f4e2a569498b7d8d67f90455a0170feebbd447860141043692aad65e4e4dd9d4a4ca43b58587c4b9de624b81256d73a482576bcccb952c7cbc9d94023d872652882f6da25e94d1006d805569c188c390606aa7001cccb3ffffffff02a08601000000000017a914faafa687e785e6c93894df840013a050b41e418787e0220200000000001976a9140dca2b891dbcb99a207d52859e0e61f75f457b0e88ac00000000"
}
[archey@archey ~]$ electrum -w archey.dat deseed -o
Warning: you are going to create a seedless wallet'
It will be saved in 'archey.dat.seedless'
Are you sure you want to continue? (y/n) y
Done.
[archey@archey ~]$ electrum -w archey.dat.seedless sendrawtransaction 010000000164684fa0b030db0cf9ee756fe39d3fa20792999de38cf9ba28708a4b1eb46854010000008c493046022100b42e9c06506af9528b58ea0c21540c6c1693f5edb3ea86df84d1f79d558a33a1022100f181f2fa0d7018975c6fa762f4e2a569498b7d8d67f90455a0170feebbd447860141043692aad65e4e4dd9d4a4ca43b58587c4b9de624b81256d73a482576bcccb952c7cbc9d94023d872652882f6da25e94d1006d805569c188c390606aa7001cccb3ffffffff02a08601000000000017a914faafa687e785e6c93894df840013a050b41e418787e0220200000000001976a9140dca2b891dbcb99a207d52859e0e61f75f457b0e88ac00000000
Starting daemon [electrum.hachre.de:50002:s]
"f920f38db1b8ef84dc2e3eac23b235521bc48a9ff9e25086ef7b1f6e5863ce3d"
Funds have now been sent into the multisig address.
Bertha can check on the status of the multisig funds; e.g. she may check http://live.insight.is/address/3QYXGuu38nqYZtJwcc91EqzqKH57ECnGXn.
Normally, Bertha would wait until the payment into the escrow had several confirmations, then she'd give Archey the Twitter Platinum invite. If she trusts Archey, she may deliver the invite the moment Bitcoin funds enter the pending stage.
Now we assume the deal is complete to everyone's satisfaction and Bertha wants to take the coins out of escrow.
Bertha drafts a transaction withdrawing the BTC from the multisig address into an address of her choice.
[bertha@bertha ~]$ electrum -w bertha.dat deseed -o
Warning: you are going to create a seedless wallet'
It will be saved in 'bertha.dat.seedless'
Are you sure you want to continue? (y/n) y
Done.
[bertha@bertha ~]$ electrum -w bertha.dat.seedless decoderawtransaction 010000000164684fa0b030db0cf9ee756fe39d3fa20792999de38cf9ba28708a4b1eb46854010000008c493046022100b42e9c06506af9528b58ea0c21540c6c1693f5edb3ea86df84d1f79d558a33a1022100f181f2fa0d7018975c6fa762f4e2a569498b7d8d67f90455a0170feebbd447860141043692aad65e4e4dd9d4a4ca43b58587c4b9de624b81256d73a482576bcccb952c7cbc9d94023d872652882f6da25e94d1006d805569c188c390606aa7001cccb3ffffffff02a08601000000000017a914faafa687e785e6c93894df840013a050b41e418787e0220200000000001976a9140dca2b891dbcb99a207d52859e0e61f75f457b0e88ac00000000 -o
{
"inputs": [
{
"address": "19Ub8Tsbv1tH1dMff67DfJwCBGvWXXcmak",
"is_coinbase": false,
"prevout_hash": "5468b41e4b8a7028baf98ce39d999207a23f9de36f75eef90cdb30b0a04f6864",
"prevout_n": 1,
"pubkeys": [
"043692aad65e4e4dd9d4a4ca43b58587c4b9de624b81256d73a482576bcccb952c7cbc9d94023d872652882f6da25e94d1006d805569c188c390606aa7001cccb3"
],
"sequence": 4294967295,
"signatures": {
"043692aad65e4e4dd9d4a4ca43b58587c4b9de624b81256d73a482576bcccb952c7cbc9d94023d872652882f6da25e94d1006d805569c188c390606aa7001cccb3": "3046022100b42e9c06506af9528b58ea0c21540c6c1693f5edb3ea86df84d1f79d558a33a1022100f181f2fa0d7018975c6fa762f4e2a569498b7d8d67f90455a0170feebbd44786"
}
}
],
"lockTime": 0,
"outputs": [
{
"address": "3QYXGuu38nqYZtJwcc91EqzqKH57ECnGXn",
"is_pubkey": false,
"prevout_n": 0,
"scriptPubKey": "a914faafa687e785e6c93894df840013a050b41e418787",
"value": 100000
},
{
"address": "12FuyWvTuUfFWiJeGkjDaDkCLPfaXvBuTH",
"is_pubkey": false,
"prevout_n": 1,
"scriptPubKey": "76a9140dca2b891dbcb99a207d52859e0e61f75f457b0e88ac",
"value": 140000
}
],
"version": 1
}
[bertha@bertha ~]$ electrum -w bertha.dat.seedless createrawtransaction '[{"txid":"f920f38db1b8ef84dc2e3eac23b235521bc48a9ff9e25086ef7b1f6e5863ce3d","vout":0,"scriptPubKey":"a914faafa687e785e6c93894df840013a050b41e418787","redeemScript":"5241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953ae"}]' '{"1MoTBGmxWyZ9hh239mc4btCnEKFQs5Dz33":0.00099}' -o
{
"complete": false,
"hex": "01000000013dce63586e1f7bef8650e2f99f8ac41b5235b223ac3e2edc84efb8b18df320f90000000000ffffffff01b8820100000000001976a914e42b805fe3d0fee19012e9f9fa0112b9c45e62d288ac00000000",
"input_info": "[{\"prevout_hash\":\"f920f38db1b8ef84dc2e3eac23b235521bc48a9ff9e25086ef7b1f6e5863ce3d\",\"prevout_n\":0}]"
}
[bertha@bertha ~]$ electrum -w bertha.dat dumpprivkey 17ZuDFwDbToWYXvPsPdp1yrwdqg56Q8849 -o
WARNING: ALL your private keys are secret.
Exposing a single private key can compromise your entire wallet!
In particular, DO NOT use 'redeem private key' services proposed by third parties.
Password:
[
"5PRIVATEKEYOFBERTHA"
]
Now Bertha partially signs it using her private key.
[bertha@bertha ~]$ electrum -w bertha.dat signrawtransaction '01000000013dce63586e1f7bef8650e2f99f8ac41b5235b223ac3e2edc84efb8b18df320f90000000000ffffffff01b8820100000000001976a914e42b805fe3d0fee19012e9f9fa0112b9c45e62d288ac00000000' '[{"txid":"f920f38db1b8ef84dc2e3eac23b235521bc48a9ff9e25086ef7b1f6e5863ce3d","vout":0,"scriptPubKey":"a914faafa687e785e6c93894df840013a050b41e418787","redeemScript":"5241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953ae"}]' '["5PRIVATEKEYOFBERTHA"]' -o
Password:
{
"complete": false,
"hex": "01000000013dce63586e1f7bef8650e2f99f8ac41b5235b223ac3e2edc84efb8b18df320f900000000fd150100483045022100d53893ae79ac95c0447565163860dc8132d5cb66788097aba412cf43e313287202206f7995ebfadb9c0a5d7023b9150b39db4bc6f4bfbb92a8ced0a38d73cdfdedb6014cc95241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953aeffffffff01b8820100000000001976a914e42b805fe3d0fee19012e9f9fa0112b9c45e62d288ac00000000",
"input_info": "[{\"redeemScript\":\"5241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953ae\",\"signatures\":{\"048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd\":\"3045022100d53893ae79ac95c0447565163860dc8132d5cb66788097aba412cf43e313287202206f7995ebfadb9c0a5d7023b9150b39db4bc6f4bfbb92a8ced0a38d73cdfdedb6\"},\"prevout_hash\":\"f920f38db1b8ef84dc2e3eac23b235521bc48a9ff9e25086ef7b1f6e5863ce3d\",\"is_coinbase\":false,\"pubkeys\":[\"045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a87\",\"048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd\",\"0405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d19\"],\"prevout_n\":0,\"scriptPubKey\":\"a914faafa687e785e6c93894df840013a050b41e418787\"}]"
}
Bertha has signed it. But it's not complete yet... it still needs Archey's signature.
Archey is happy, so he signs:
[archey@archey ~]$ electrum -w archey.dat dumpprivkey 131HaWvMSKCpax1XFrKmDCV5y7CEyjiBTi -o
WARNING: ALL your private keys are secret.
Exposing a single private key can compromise your entire wallet!
In particular, DO NOT use 'redeem private key' services proposed by third parties.
Password:
[
"5PRIVATEKEYOFARCHEY"
]
[archey@archey ~]$ electrum -w archey.dat signrawtransaction '01000000013dce63586e1f7bef8650e2f99f8ac41b5235b223ac3e2edc84efb8b18df320f900000000fd150100483045022100d53893ae79ac95c0447565163860dc8132d5cb66788097aba412cf43e313287202206f7995ebfadb9c0a5d7023b9150b39db4bc6f4bfbb92a8ced0a38d73cdfdedb6014cc95241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953aeffffffff01b8820100000000001976a914e42b805fe3d0fee19012e9f9fa0112b9c45e62d288ac00000000' '[{"txid":"f920f38db1b8ef84dc2e3eac23b235521bc48a9ff9e25086ef7b1f6e5863ce3d","vout":0,"scriptPubKey":"a914faafa687e785e6c93894df840013a050b41e418787","redeemScript":"5241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953ae","signatures":{"048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd":"3045022100d53893ae79ac95c0447565163860dc8132d5cb66788097aba412cf43e313287202206f7995ebfadb9c0a5d7023b9150b39db4bc6f4bfbb92a8ced0a38d73cdfdedb6"}}]' '["5PRIVATEKEYOFARCHEY"]' -o
Password:
{
"complete": true,
"hex": "01000000013dce63586e1f7bef8650e2f99f8ac41b5235b223ac3e2edc84efb8b18df320f900000000fd5e010048304502206f177ea06872df48b8d52f140f369ca21268072e9d3908446f922438695cf131022100da89647358b337ee0ede5e8bbf840024f829b60dcf2c43bd0589e3c75df4e1d801483045022100d53893ae79ac95c0447565163860dc8132d5cb66788097aba412cf43e313287202206f7995ebfadb9c0a5d7023b9150b39db4bc6f4bfbb92a8ced0a38d73cdfdedb6014cc95241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953aeffffffff01b8820100000000001976a914e42b805fe3d0fee19012e9f9fa0112b9c45e62d288ac00000000"
}
Finally, Archey announces the transaction to the network:
[archey@archey ~]$ electrum -w archey.dat.seedless sendrawtransaction 01000000013dce63586e1f7bef8650e2f99f8ac41b5235b223ac3e2edc84efb8b18df320f900000000fd5e010048304502206f177ea06872df48b8d52f140f369ca21268072e9d3908446f922438695cf131022100da89647358b337ee0ede5e8bbf840024f829b60dcf2c43bd0589e3c75df4e1d801483045022100d53893ae79ac95c0447565163860dc8132d5cb66788097aba412cf43e313287202206f7995ebfadb9c0a5d7023b9150b39db4bc6f4bfbb92a8ced0a38d73cdfdedb6014cc95241045a5713f24ba168d9c9d797ce5b9d7867fb936b7ea632cc1da08a6c4ba08aef8f7427e7ee1cf297212b58898657e3426dc9902d9ffc53e41787f8029804d49a8741048fff4af0894075a46f3abf0b7b51f469e686ede3de2bc70a0bf7767f394362dad564c91ed8808d51aba4238b60b7979c6d805d1e55226d5b8935bdda2e4a47bd410405b4f342460aa8512e28a70393dc98117ebb56b10bb38968f986199ff9c5904bf834ba9fd0b323128127baa0e800b2bb12df4672cace22ac48cf6fa742ed2d1953aeffffffff01b8820100000000001976a914e42b805fe3d0fee19012e9f9fa0112b9c45e62d288ac00000000
Starting daemon [electrum.hachre.de:50002:s]
"5fdc3e1520f5fc8ea084c70c8ff5f42547aacdff81876f593dc8403245953cca"
Done.
Much thanks to: