mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-08 08:26:17 +00:00
fixed first example
This commit is contained in:
parent
cff47164c7
commit
8dfbc080b9
@ -12,33 +12,38 @@ Following are three examples, using PSBTs for: multi-sigs, pooling money, and jo
|
|||||||
|
|
||||||
Assume you've created a new multi-sig, just like you did in [§6.3](06_3_Sending_an_Automated_Multisig.md).
|
Assume you've created a new multi-sig, just like you did in [§6.3](06_3_Sending_an_Automated_Multisig.md).
|
||||||
```
|
```
|
||||||
$ bitcoin-cli -named addmultisigaddress nrequired=2 keys='''["'$pubkey1'","'$pubkey2'"]'''
|
machine1$ bitcoin-cli -named addmultisigaddress nrequired=2 keys='''["'$pubkey1'","'$pubkey2'"]'''
|
||||||
{
|
{
|
||||||
"address": "tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0",
|
"address": "tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0",
|
||||||
"redeemScript": "5221038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e2103789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd063652ae",
|
"redeemScript": "5221038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e2103789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd063652ae",
|
||||||
"descriptor": "wsh(multi(2,[d6043800/0'/0'/26']038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e,[be686772]03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636))#07zyayfk"
|
"descriptor": "wsh(multi(2,[d6043800/0'/0'/26']038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e,[be686772]03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636))#07zyayfk"
|
||||||
}
|
}
|
||||||
|
|
||||||
machine1$ bitcoin-cli -named importaddress address="tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0" rescan=false
|
machine1$ bitcoin-cli -named importaddress address="tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0" rescan=false
|
||||||
|
|
||||||
|
machine2$ bitcoin-cli -named addmultisigaddress nrequired=2 keys='''["'$pubkey1'","'$pubkey2'"]'''
|
||||||
|
{
|
||||||
|
"address": "tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0",
|
||||||
|
"redeemScript": "5221038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e2103789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd063652ae",
|
||||||
|
"descriptor": "wsh(multi(2,[d6043800/0'/0'/26']038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e,[be686772]03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636))#07zyayfk"
|
||||||
|
}
|
||||||
machine2$ bitcoin-cli -named importaddress address="tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0" rescan=false
|
machine2$ bitcoin-cli -named importaddress address="tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0" rescan=false
|
||||||
```
|
```
|
||||||
[[NEED TO FINISH REDOING THIS EXAMPLE]]
|
|
||||||
And, you've got some money in it:
|
And, you've got some money in it:
|
||||||
```
|
```
|
||||||
$ bitcoin-cli listunspent
|
$ bitcoin-cli listunspent
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"txid": "25e8a26f60cf485768a1e6953b983675c867b7ab126b02e753c47b7db0c4be5e",
|
"txid": "53ec62c5c2fe8b16ee2164e9699d16c7b8ac30ec53a696e55f09b79704b539b5",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"address": "tb1q92a46jww0e6ne066nlagekhczkl3qa84czl5jk5nm78t2yf0vk4qte328m",
|
"address": "tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0",
|
||||||
"label": "",
|
"label": "",
|
||||||
"witnessScript": "5221033055ec2da9bbb34c2acb343692bfbecdef8fab8d114f0036eba01baec3888aa02103f52980d322acaf084bcef3216f3d84bfb672d1db26ce2861de3ec047bede140d52ae",
|
"witnessScript": "5221038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e2103789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd063652ae",
|
||||||
"scriptPubKey": "00202abb5d49ce7e753cbf5a9ffa8cdaf815bf1074f5c0bf495a93df8eb5112f65aa",
|
"scriptPubKey": "0020224cb503a7f7835799b9c22ee0c3c7d93d090356e30e70015c3ebbfa515a3074",
|
||||||
"amount": 0.01000000,
|
"amount": 0.01999800,
|
||||||
"confirmations": 5,
|
"confirmations": 2,
|
||||||
"spendable": false,
|
"spendable": false,
|
||||||
"solvable": true,
|
"solvable": true,
|
||||||
"desc": "wsh(multi(2,[c1fdfe64]033055ec2da9bbb34c2acb343692bfbecdef8fab8d114f0036eba01baec3888aa0,[d3ed8825/0'/0'/2']03f52980d322acaf084bcef3216f3d84bfb672d1db26ce2861de3ec047bede140d))#5070hfm8",
|
"desc": "wsh(multi(2,[d6043800/0'/0'/26']038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e,[be686772]03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636))#07zyayfk",
|
||||||
"safe": true
|
"safe": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -54,23 +59,23 @@ tb1q3krplahg4ncu523m8h2eephjazs2hf6ur8r6zp
|
|||||||
```
|
```
|
||||||
The first thing we do is create a PSBT on either machine. We need to use `createpsbt` from [§7.1](07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md), not the simpler `walletcreatefundedpsbt`, because we need the extra control of selecting our money protected by the multi-sig
|
The first thing we do is create a PSBT on either machine. We need to use `createpsbt` from [§7.1](07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md), not the simpler `walletcreatefundedpsbt`, because we need the extra control of selecting our money protected by the multi-sig
|
||||||
```
|
```
|
||||||
machine2$ utxo_txid=25e8a26f60cf485768a1e6953b983675c867b7ab126b02e753c47b7db0c4be5e
|
machine1$ utxo_txid=53ec62c5c2fe8b16ee2164e9699d16c7b8ac30ec53a696e55f09b79704b539b5
|
||||||
machine2$ utxo_vout=0
|
machine1$ utxo_vout=0
|
||||||
machine2$ split1=tb1qem5l3q5g5h6fsqv352xh4cy07kzq2rd8gphqma
|
machine1$ split1=tb1qem5l3q5g5h6fsqv352xh4cy07kzq2rd8gphqma
|
||||||
machine2$ split2=tb1q3krplahg4ncu523m8h2eephjazs2hf6ur8r6zp
|
machine1$ split2=tb1q3krplahg4ncu523m8h2eephjazs2hf6ur8r6zp
|
||||||
machine2$ psbt=$(bitcoin-cli -named createpsbt inputs='''[ { "txid": "'$utxo_txid'", "vout": '$utxo_vout' } ]''' outputs='''{ "'$split1'": 0.004999,"'$split2'": 0.0004999 }''')
|
machine1$ psbt=$(bitcoin-cli -named createpsbt inputs='''[ { "txid": "'$utxo_txid'", "vout": '$utxo_vout' } ]''' outputs='''{ "'$split1'": 0.009998,"'$split2'": 0.009998 }''')
|
||||||
```
|
```
|
||||||
You then need to send that $psbt to everyone signing:
|
You then need to send that $psbt to everyone for signing:
|
||||||
```
|
```
|
||||||
machine2$ echo $psbt
|
machine1$ echo $psbt
|
||||||
cHNidP8BAHECAAAAAV6+xLB9e8RT5wJrEqu3Z8h1Npg7leahaFdIz2BvouglAAAAAAD/////ArygBwAAAAAAFgAUzun4goil9JgBkaKNeuCP9YQFDadGwwAAAAAAABYAFI2GH/borPHKKjs91ZyG8uigq6dcAAAAAAAAAAA=
|
cHNidP8BAHECAAAAAbU5tQSXtwlf5ZamU+wwrLjHFp1p6WQh7haL/sLFYuxTAAAAAAD/////AnhBDwAAAAAAFgAUzun4goil9JgBkaKNeuCP9YQFDad4QQ8AAAAAABYAFI2GH/borPHKKjs91ZyG8uigq6dcAAAAAAAAAAA=
|
||||||
```
|
```
|
||||||
Just once! And you do it simulataneously.
|
But you just have to send once! And you do it simulataneously.
|
||||||
|
|
||||||
Here's the result on the second machine, where I generated the PSBT:
|
Here's the result on the first machine, where I generated the PSBT:
|
||||||
```
|
```
|
||||||
machine2$ psbt_p1=$(bitcoin-cli walletprocesspsbt $psbt | jq -r '.psbt')
|
machine1$ psbt_p1=$(bitcoin-cli walletprocesspsbt $psbt | jq -r '.psbt')
|
||||||
machine2$ bitcoin-cli decodepsbt $psbt_p1
|
machine1$ bitcoin-cli decodepsbt $psbt_p1
|
||||||
{
|
{
|
||||||
"tx": {
|
"tx": {
|
||||||
"txid": "1687e89fcb9dd3067f75495b4884dc1d4d1cf05a6c272b783cfe29eb5d22e985",
|
"txid": "1687e89fcb9dd3067f75495b4884dc1d4d1cf05a6c272b783cfe29eb5d22e985",
|
||||||
@ -146,31 +151,106 @@ machine2$ bitcoin-cli decodepsbt $psbt_p1
|
|||||||
"pubkey": "033055ec2da9bbb34c2acb343692bfbecdef8fab8d114f0036eba01baec3888aa0",
|
"pubkey": "033055ec2da9bbb34c2acb343692bfbecdef8fab8d114f0036eba01baec3888aa0",
|
||||||
"master_fingerprint": "c1fdfe64",
|
"master_fingerprint": "c1fdfe64",
|
||||||
"path": "m"
|
"path": "m"
|
||||||
|
{
|
||||||
|
"tx": {
|
||||||
|
"txid": "ee82d3e0d225e0fb919130d68c5052b6e3c362c866acc54d89af975330bb4d16",
|
||||||
|
"hash": "ee82d3e0d225e0fb919130d68c5052b6e3c362c866acc54d89af975330bb4d16",
|
||||||
|
"version": 2,
|
||||||
|
"size": 113,
|
||||||
|
"vsize": 113,
|
||||||
|
"weight": 452,
|
||||||
|
"locktime": 0,
|
||||||
|
"vin": [
|
||||||
|
{
|
||||||
|
"txid": "53ec62c5c2fe8b16ee2164e9699d16c7b8ac30ec53a696e55f09b79704b539b5",
|
||||||
|
"vout": 0,
|
||||||
|
"scriptSig": {
|
||||||
|
"asm": "",
|
||||||
|
"hex": ""
|
||||||
|
},
|
||||||
|
"sequence": 4294967295
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"vout": [
|
||||||
|
{
|
||||||
|
"value": 0.00999800,
|
||||||
|
"n": 0,
|
||||||
|
"scriptPubKey": {
|
||||||
|
"asm": "0 cee9f88288a5f4980191a28d7ae08ff584050da7",
|
||||||
|
"hex": "0014cee9f88288a5f4980191a28d7ae08ff584050da7",
|
||||||
|
"reqSigs": 1,
|
||||||
|
"type": "witness_v0_keyhash",
|
||||||
|
"addresses": [
|
||||||
|
"tb1qem5l3q5g5h6fsqv352xh4cy07kzq2rd8gphqma"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pubkey": "03f52980d322acaf084bcef3216f3d84bfb672d1db26ce2861de3ec047bede140d",
|
"value": 0.00999800,
|
||||||
"master_fingerprint": "d3ed8825",
|
"n": 1,
|
||||||
"path": "m/0'/0'/2'"
|
"scriptPubKey": {
|
||||||
|
"asm": "0 8d861ff6e8acf1ca2a3b3dd59c86f2e8a0aba75c",
|
||||||
|
"hex": "00148d861ff6e8acf1ca2a3b3dd59c86f2e8a0aba75c",
|
||||||
|
"reqSigs": 1,
|
||||||
|
"type": "witness_v0_keyhash",
|
||||||
|
"addresses": [
|
||||||
|
"tb1q3krplahg4ncu523m8h2eephjazs2hf6ur8r6zp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unknown": {
|
||||||
|
},
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"witness_utxo": {
|
||||||
|
"amount": 0.01999800,
|
||||||
|
"scriptPubKey": {
|
||||||
|
"asm": "0 224cb503a7f7835799b9c22ee0c3c7d93d090356e30e70015c3ebbfa515a3074",
|
||||||
|
"hex": "0020224cb503a7f7835799b9c22ee0c3c7d93d090356e30e70015c3ebbfa515a3074",
|
||||||
|
"type": "witness_v0_scripthash",
|
||||||
|
"address": "tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"partial_signatures": {
|
||||||
|
"038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e": "3044022040aae4f2ba37b1526524195f4a325d97d1317227b3c82aea55c5abd66810a7ec0220416e7c03e70a31232044addba454d6b37b6ace39ab163315d3293e343ae9513301"
|
||||||
|
},
|
||||||
|
"witness_script": {
|
||||||
|
"asm": "2 038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e 03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636 2 OP_CHECKMULTISIG",
|
||||||
|
"hex": "5221038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e2103789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd063652ae",
|
||||||
|
"type": "multisig"
|
||||||
|
},
|
||||||
|
"bip32_derivs": [
|
||||||
|
{
|
||||||
|
"pubkey": "03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636",
|
||||||
|
"master_fingerprint": "be686772",
|
||||||
|
"path": "m"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pubkey": "038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e",
|
||||||
|
"master_fingerprint": "d6043800",
|
||||||
|
"path": "m/0'/0'/26'"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"bip32_derivs": [
|
"bip32_derivs": [
|
||||||
{
|
{
|
||||||
"pubkey": "0349cc43324f7ad94bb407a9bf12bc50afd9e7b430a472572f1b63cb555034f52a",
|
"pubkey": "02fce26085452d07abc63bd389cb7dba9871e79bbecd08039291226be8232a9000",
|
||||||
"master_fingerprint": "d3ed8825",
|
"master_fingerprint": "d6043800",
|
||||||
"path": "m/0'/0'/3'"
|
"path": "m/0'/0'/24'"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fee": 0.00450110
|
"fee": 0.00000200
|
||||||
}
|
}
|
||||||
$ bitcoin-cli analyzepsbt $psbt_p1
|
machine1$ bitcoin-cli analyzepsbt $psbt_p1
|
||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@ -179,37 +259,38 @@ $ bitcoin-cli analyzepsbt $psbt_p1
|
|||||||
"next": "signer",
|
"next": "signer",
|
||||||
"missing": {
|
"missing": {
|
||||||
"signatures": [
|
"signatures": [
|
||||||
"c1fdfe6454aade5ffea5539a02e51b3418cf5416"
|
"be6867729bcc35ed065bb4c937557d371218a8e2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"estimated_vsize": 168,
|
"estimated_vsize": 168,
|
||||||
"estimated_feerate": 0.02679226,
|
"estimated_feerate": 0.00001190,
|
||||||
"fee": 0.00450110,
|
"fee": 0.00000200,
|
||||||
"next": "signer"
|
"next": "signer"
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
We can see that even though the UTXO information has been imported, and even though we have a _partial signature_, the signing of the single input is still not complete.
|
We can see that even though the UTXO information has been imported, and even though we have a _partial signature_, the signing of the single input is still not complete.
|
||||||
|
|
||||||
Here's the same thing on the other machine:
|
Here's the same thing on the other machine:
|
||||||
```
|
```
|
||||||
machine1$ psbt=cHNidP8BAHECAAAAAV6+xLB9e8RT5wJrEqu3Z8h1Npg7leahaFdIz2BvouglAAAAAAD/////ArygBwAAAAAAFgAUzun4goil9JgBkaKNeuCP9YQFDadGwwAAAAAAABYAFI2GH/borPHKKjs91ZyG8uigq6dcAAAAAAAAAAA=
|
machine2$ psbt=cHNidP8BAHECAAAAAbU5tQSXtwlf5ZamU+wwrLjHFp1p6WQh7haL/sLFYuxTAAAAAAD/////AnhBDwAAAAAAFgAUzun4goil9JgBkaKNeuCP9YQFDad4QQ8AAAAAABYAFI2GH/borPHKKjs91ZyG8uigq6dcAAAAAAAAAAA=
|
||||||
machine1$ psbt_p2=$(bitcoin-cli walletprocesspsbt $psbt | jq -r '.psbt')
|
machine2$ psbt_p2=$(bitcoin-cli walletprocesspsbt $psbt | jq -r '.psbt')
|
||||||
machine1$ echo $psbt_p2
|
machine3$ echo $psbt_p2
|
||||||
cHNidP8BAHECAAAAAV6+xLB9e8RT5wJrEqu3Z8h1Npg7leahaFdIz2BvouglAAAAAAD/////ArygBwAAAAAAFgAUzun4goil9JgBkaKNeuCP9YQFDadGwwAAAAAAABYAFI2GH/borPHKKjs91ZyG8uigq6dcAAAAAAABAStAQg8AAAAAACIAICq7XUnOfnU8v1qf+oza+BW/EHT1wL9JWpPfjrURL2WqIgIDMFXsLam7s0wqyzQ2kr++ze+Pq40RTwA266AbrsOIiqBHMEQCIHpLvl8fmC+Qc6sjuHKjnmpZpIAqXnqrd/ZiG/WKMC7ZAiBI9tptilK6G6+uc3ZFMAeeXoIhwxw7mjfHVdrKdkUaogEBBUdSIQMwVewtqbuzTCrLNDaSv77N74+rjRFPADbroBuuw4iKoCED9SmA0yKsrwhLzvMhbz2Ev7Zy0dsmzihh3j7AR77eFA1SriIGAzBV7C2pu7NMKss0NpK/vs3vj6uNEU8ANuugG67DiIqgENYEOAAAAACAAAAAgBcAAIAiBgP1KYDTIqyvCEvO8yFvPYS/tnLR2ybOKGHePsBHvt4UDQT/G/OxACICAvziYIVFLQerxjvTict9uphx55u+zQgDkpEia+gjKpAAENYEOAAAAACAAAAAgBgAAIAAAA==
|
cHNidP8BAHECAAAAAbU5tQSXtwlf5ZamU+wwrLjHFp1p6WQh7haL/sLFYuxTAAAAAAD/////AnhBDwAAAAAAFgAUzun4goil9JgBkaKNeuCP9YQFDad4QQ8AAAAAABYAFI2GH/borPHKKjs91ZyG8uigq6dcAAAAAAABASu4gx4AAAAAACIAICJMtQOn94NXmbnCLuDDx9k9CQNW4w5wAVw+u/pRWjB0IgIDeJ9UNCNnDhaWZ/9+Hy2iqX3xsJEicuFC1YJFGs69BjZHMEQCIDJ71isvR2We6ym1QByLV5SQ+XEJD0SAP76fe1JU5PZ/AiB3V7ejl2H+9LLS6ubqYr/bSKfRfEqrp2FCMISjrWGZ6QEBBUdSIQONc63yx+oz+dw0t3titZr0M8HenHYzMtp56D4VX5YDDiEDeJ9UNCNnDhaWZ/9+Hy2iqX3xsJEicuFC1YJFGs69BjZSriIGA3ifVDQjZw4Wlmf/fh8toql98bCRInLhQtWCRRrOvQY2ENPtiCUAAACAAAAAgAYAAIAiBgONc63yx+oz+dw0t3titZr0M8HenHYzMtp56D4VX5YDDgRZu4lPAAAiAgNJzEMyT3rZS7QHqb8SvFCv2ee0MKRyVy8bY8tVUDT1KhDT7YglAAAAgAAAAIADAACAAA==
|
||||||
```
|
```
|
||||||
Now note that the way we managed this multi-sig was that we generated a PSBT with the correct UTXOs, where data was held in the wallets of both systems, then we allowed both of the users to process that PSBT on their own, adding UTXOs and signatures. As a result, we have two PSBTs each of which contain one signature and not the other. That wouldn't work in the classic multi-sig scenario, because all the signatures have to be sequential. Here, instead, we can make use of the Combiner role to mush those together.
|
Now note that we managed this multi-sig by generating a totally unsigned PSBT with the correct UTXOs, then we allowed each of the users to process that PSBT on their own, adding UTXOs and signatures. As a result, we have two PSBTs each of which contain one signature and not the other. That wouldn't work in the classic multi-sig scenario, because all the signatures have to be sequential. Here, instead, we can make use of the Combiner role to mush those together.
|
||||||
|
|
||||||
We again go to either machine, and make sure we have both PSBTs in variables, then we combine them:
|
We again go to either machine, and make sure we have both PSBTs in variables, then we combine them:
|
||||||
```
|
```
|
||||||
machine2$ psbt_p2="cHNidP8BAHECAAAAAV6+xLB9e8RT5wJrEqu3Z8h1Npg7leahaFdIz2BvouglAAAAAAD/////ArygBwAAAAAAFgAUzun4goil9JgBkaKNeuCP9YQFDadGwwAAAAAAABYAFI2GH/borPHKKjs91ZyG8uigq6dcAAAAAAABAStAQg8AAAAAACIAICq7XUnOfnU8v1qf+oza+BW/EHT1wL9JWpPfjrURL2WqIgIDMFXsLam7s0wqyzQ2kr++ze+Pq40RTwA266AbrsOIiqBHMEQCIHpLvl8fmC+Qc6sjuHKjnmpZpIAqXnqrd/ZiG/WKMC7ZAiBI9tptilK6G6+uc3ZFMAeeXoIhwxw7mjfHVdrKdkUaogEBBUdSIQMwVewtqbuzTCrLNDaSv77N74+rjRFPADbroBuuw4iKoCED9SmA0yKsrwhLzvMhbz2Ev7Zy0dsmzihh3j7AR77eFA1SriIGAzBV7C2pu7NMKss0NpK/vs3vj6uNEU8ANuugG67DiIqgENYEOAAAAACAAAAAgBcAAIAiBgP1KYDTIqyvCEvO8yFvPYS/tnLR2ybOKGHeP
|
machine1$ $ psbt_p2="cHNidP8BAHECAAAAAbU5tQSXtwlf5ZamU+wwrLjHFp1p6WQh7haL/sLFYuxTAAAAAAD/////AnhBDwAAAAAAFgAUzun4goil9JgBkaKNeuCP9YQFDad4QQ8AAAAAABYAFI2GH/borPHKKjs91ZyG8uigq6dcAAAAAAABAIcCAAAAAtu5pTheUzdsTaMCEPj3XKboMAyYzABmIIeOWMhbhTYlAAAAAAD//////uSTLbibcqSd/Z9ieSBWJ2psv+9qvoGrzWEa60rCx9cAAAAAAP////8BuIMeAAAAAAAiACAiTLUDp/eDV5m5wi7gw8fZPQkDVuMOcAFcPrv6UVowdAAAAAAAACICA0nMQzJPetlLtAepvxK8UK/Z57QwpHJXLxtjy1VQNPUqENPtiCUAAACAAAAAgAMAAIAA"
|
||||||
machine2$ psbt_c=$(bitcoin-cli combinepsbt '''["'$psbt_p1'", "'$psbt_p2'"]''')
|
machine2$ psbt_c=$(bitcoin-cli combinepsbt '''["'$psbt_p1'", "'$psbt_p2'"]''')
|
||||||
machine2$ bitcoin-cli decodepsbt $psbt_c
|
$ bitcoin-cli decodepsbt $psbt_c
|
||||||
{
|
{
|
||||||
"tx": {
|
"tx": {
|
||||||
"txid": "1687e89fcb9dd3067f75495b4884dc1d4d1cf05a6c272b783cfe29eb5d22e985",
|
"txid": "ee82d3e0d225e0fb919130d68c5052b6e3c362c866acc54d89af975330bb4d16",
|
||||||
"hash": "1687e89fcb9dd3067f75495b4884dc1d4d1cf05a6c272b783cfe29eb5d22e985",
|
"hash": "ee82d3e0d225e0fb919130d68c5052b6e3c362c866acc54d89af975330bb4d16",
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"size": 113,
|
"size": 113,
|
||||||
"vsize": 113,
|
"vsize": 113,
|
||||||
@ -217,7 +298,7 @@ machine2$ bitcoin-cli decodepsbt $psbt_c
|
|||||||
"locktime": 0,
|
"locktime": 0,
|
||||||
"vin": [
|
"vin": [
|
||||||
{
|
{
|
||||||
"txid": "25e8a26f60cf485768a1e6953b983675c867b7ab126b02e753c47b7db0c4be5e",
|
"txid": "53ec62c5c2fe8b16ee2164e9699d16c7b8ac30ec53a696e55f09b79704b539b5",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"scriptSig": {
|
"scriptSig": {
|
||||||
"asm": "",
|
"asm": "",
|
||||||
@ -228,7 +309,7 @@ machine2$ bitcoin-cli decodepsbt $psbt_c
|
|||||||
],
|
],
|
||||||
"vout": [
|
"vout": [
|
||||||
{
|
{
|
||||||
"value": 0.00499900,
|
"value": 0.00999800,
|
||||||
"n": 0,
|
"n": 0,
|
||||||
"scriptPubKey": {
|
"scriptPubKey": {
|
||||||
"asm": "0 cee9f88288a5f4980191a28d7ae08ff584050da7",
|
"asm": "0 cee9f88288a5f4980191a28d7ae08ff584050da7",
|
||||||
@ -241,7 +322,7 @@ machine2$ bitcoin-cli decodepsbt $psbt_c
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 0.00049990,
|
"value": 0.00999800,
|
||||||
"n": 1,
|
"n": 1,
|
||||||
"scriptPubKey": {
|
"scriptPubKey": {
|
||||||
"asm": "0 8d861ff6e8acf1ca2a3b3dd59c86f2e8a0aba75c",
|
"asm": "0 8d861ff6e8acf1ca2a3b3dd59c86f2e8a0aba75c",
|
||||||
@ -260,33 +341,33 @@ machine2$ bitcoin-cli decodepsbt $psbt_c
|
|||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"witness_utxo": {
|
"witness_utxo": {
|
||||||
"amount": 0.01000000,
|
"amount": 0.01999800,
|
||||||
"scriptPubKey": {
|
"scriptPubKey": {
|
||||||
"asm": "0 2abb5d49ce7e753cbf5a9ffa8cdaf815bf1074f5c0bf495a93df8eb5112f65aa",
|
"asm": "0 224cb503a7f7835799b9c22ee0c3c7d93d090356e30e70015c3ebbfa515a3074",
|
||||||
"hex": "00202abb5d49ce7e753cbf5a9ffa8cdaf815bf1074f5c0bf495a93df8eb5112f65aa",
|
"hex": "0020224cb503a7f7835799b9c22ee0c3c7d93d090356e30e70015c3ebbfa515a3074",
|
||||||
"type": "witness_v0_scripthash",
|
"type": "witness_v0_scripthash",
|
||||||
"address": "tb1q92a46jww0e6ne066nlagekhczkl3qa84czl5jk5nm78t2yf0vk4qte328m"
|
"address": "tb1qyfxt2qa877p40xdecghwps78my7sjq6kuv88qq2u86al5526xp6qfqjud0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"partial_signatures": {
|
"partial_signatures": {
|
||||||
"033055ec2da9bbb34c2acb343692bfbecdef8fab8d114f0036eba01baec3888aa0": "304402207a4bbe5f1f982f9073ab23b872a39e6a59a4802a5e7aab77f6621bf58a302ed9022048f6da6d8a52ba1bafae73764530079e5e8221c31c3b9a37c755daca76451aa201",
|
"038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e": "3044022040aae4f2ba37b1526524195f4a325d97d1317227b3c82aea55c5abd66810a7ec0220416e7c03e70a31232044addba454d6b37b6ace39ab163315d3293e343ae9513301",
|
||||||
"03f52980d322acaf084bcef3216f3d84bfb672d1db26ce2861de3ec047bede140d": "304402203abb95d1965e4cea630a8b4890456d56698ff2dd5544cb79303cc28cb011cbb40220701faa927f8a19ca79b09d35c78d8d0a2187872117d9308805f7a896b07733f901"
|
"03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636": "30440220327bd62b2f47659eeb29b5401c8b579490f971090f44803fbe9f7b5254e4f67f02207757b7a39761fef4b2d2eae6ea62bfdb48a7d17c4aaba761423084a3ad6199e901"
|
||||||
},
|
},
|
||||||
"witness_script": {
|
"witness_script": {
|
||||||
"asm": "2 033055ec2da9bbb34c2acb343692bfbecdef8fab8d114f0036eba01baec3888aa0 03f52980d322acaf084bcef3216f3d84bfb672d1db26ce2861de3ec047bede140d 2 OP_CHECKMULTISIG",
|
"asm": "2 038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e 03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636 2 OP_CHECKMULTISIG",
|
||||||
"hex": "5221033055ec2da9bbb34c2acb343692bfbecdef8fab8d114f0036eba01baec3888aa02103f52980d322acaf084bcef3216f3d84bfb672d1db26ce2861de3ec047bede140d52ae",
|
"hex": "5221038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e2103789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd063652ae",
|
||||||
"type": "multisig"
|
"type": "multisig"
|
||||||
},
|
},
|
||||||
"bip32_derivs": [
|
"bip32_derivs": [
|
||||||
{
|
{
|
||||||
"pubkey": "033055ec2da9bbb34c2acb343692bfbecdef8fab8d114f0036eba01baec3888aa0",
|
"pubkey": "03789f543423670e169667ff7e1f2da2a97df1b0912272e142d582451acebd0636",
|
||||||
"master_fingerprint": "c1fdfe64",
|
"master_fingerprint": "be686772",
|
||||||
"path": "m"
|
"path": "m"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pubkey": "03f52980d322acaf084bcef3216f3d84bfb672d1db26ce2861de3ec047bede140d",
|
"pubkey": "038d73adf2c7ea33f9dc34b77b62b59af433c1de9c763332da79e83e155f96030e",
|
||||||
"master_fingerprint": "d3ed8825",
|
"master_fingerprint": "d6043800",
|
||||||
"path": "m/0'/0'/2'"
|
"path": "m/0'/0'/26'"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -311,9 +392,9 @@ machine2$ bitcoin-cli decodepsbt $psbt_c
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fee": 0.00450110
|
"fee": 0.00000200
|
||||||
}
|
}
|
||||||
machine2$ bitcoin-cli analyzepsbt $psbt_c
|
$ bitcoin-cli analyzepsbt $psbt_c
|
||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@ -323,8 +404,8 @@ machine2$ bitcoin-cli analyzepsbt $psbt_c
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"estimated_vsize": 168,
|
"estimated_vsize": 168,
|
||||||
"estimated_feerate": 0.02679226,
|
"estimated_feerate": 0.00001190,
|
||||||
"fee": 0.00450110,
|
"fee": 0.00000200,
|
||||||
"next": "finalizer"
|
"next": "finalizer"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -332,7 +413,7 @@ It worked! We just finalize and send and we're done:
|
|||||||
```
|
```
|
||||||
machine2$ psbt_c_hex=$(bitcoin-cli finalizepsbt $psbt_c | jq -r '.hex')
|
machine2$ psbt_c_hex=$(bitcoin-cli finalizepsbt $psbt_c | jq -r '.hex')
|
||||||
standup@btctest2:~$ bitcoin-cli -named sendrawtransaction hexstring=$psbt_c_hex
|
standup@btctest2:~$ bitcoin-cli -named sendrawtransaction hexstring=$psbt_c_hex
|
||||||
1687e89fcb9dd3067f75495b4884dc1d4d1cf05a6c272b783cfe29eb5d22e985
|
ee82d3e0d225e0fb919130d68c5052b6e3c362c866acc54d89af975330bb4d16
|
||||||
```
|
```
|
||||||
Obviously, there wasn't a big improvement in using this method over multiply signing a transaction for a 2-of-2 multisig when everyone was using `bitcoin-cli`. We could have passed a raw transaction with partial signatures from one user to the other just as easily as that PSBT. But there nonetheless are big advantages to this methodology. First of all, it's platform independent. As long as everyone is using a service that supports Bitcoin Core 0.17, they'll all be able to sign this transaction, which isn't true when multi-sigs are being passed around. But more notably, it's a lot more scalable. Consider a 3-of-5 multisig. Under the old methodology it would have to passed from person to person, greatly increasing the problems if any single link in the chain breaks. Here, other users just have to send the PSBTs back to the Creator, and as soon as she has enough, she can generate the final transaction.
|
Obviously, there wasn't a big improvement in using this method over multiply signing a transaction for a 2-of-2 multisig when everyone was using `bitcoin-cli`. We could have passed a raw transaction with partial signatures from one user to the other just as easily as that PSBT. But there nonetheless are big advantages to this methodology. First of all, it's platform independent. As long as everyone is using a service that supports Bitcoin Core 0.17, they'll all be able to sign this transaction, which isn't true when multi-sigs are being passed around. But more notably, it's a lot more scalable. Consider a 3-of-5 multisig. Under the old methodology it would have to passed from person to person, greatly increasing the problems if any single link in the chain breaks. Here, other users just have to send the PSBTs back to the Creator, and as soon as she has enough, she can generate the final transaction.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user