1

I would like to create a Bitcoin transaction with a single input and a single 2-of-3 multisig output that pays 1 BTC to any 2 of the following 3 keys: 02983a79d2de8e504d00ddd2343b582acef7e17ed91b308ade8dff027a92e7716d, 03548ca1916957bc06dd1c6e3639ebf7b2c3c8b1715915433c1d37cab56fb26ef0, and 0218a240a599ba437cb1458966eb456d9f848e5bdef45ea0ee4ec31fc40aa4ffa8.

I just want a syntactically valid transaction, the reference to the UTXO does not have to exist.

Could you please guide me through the steps?

4
  • are you using the Bitcoin Core cli, or looking for a step by step in terms of how it is done?
    – JBaczuk
    Jul 26, 2019 at 13:08
  • Thank you for answering. I tried with bitcoin-cli but I could not continue. I have done this: createmultisig 2 '["02983a79d2de8e504d00ddd2343b582acef7e17ed91b308ade8dff027a92e7716d","03548ca1916957bc06dd1c6e3639ebf7b2c3c8b1715915433c1d37cab56fb26ef0","0218a240a599ba437cb1458966eb456d9f848e5bdef45ea0ee4ec31fc40aa4ffa8"]'......./bitcoind createrawtransaction '[{"txid" : "d6f72aab8ff86ff6289842a0424319bf2ddba85dc7c52757912297f948286389","vout":0}]' '{"3DjMQ5f21bGg2LBhxwHAMW1MzoKH8TJ8eS":1}' Jul 26, 2019 at 13:30
  • that should work, what is the issue?
    – JBaczuk
    Jul 26, 2019 at 13:45
  • I do not know how to continue. I have to sign it then I think but I cannot use signrawtransaction. I have to use another one but I got stuck. Jul 26, 2019 at 14:00

1 Answer 1

1

You almost have it, you just need to make sure you are creating a transaction with an output that your wallet can sign.

Example (on regtest)

bitcoin-cli -regtest addmultisigaddress 2 '["02983a79d2de8e504d00ddd2343b582acef7e17ed91b308ade8dff027a92e7716d","03548ca1916957bc06dd1c6e3639ebf7b2c3c8b1715915433c1d37cab56fb26ef0","0218a240a599ba437cb1458966eb456d9f848e5bdef45ea0ee4ec31fc40aa4ffa8"]'

{
  "address": "2NA1HC31wqFexbpp8bGB6rsMR5Lz9SrUKkt",
  "redeemScript": "522102983a79d2de8e504d00ddd2343b582acef7e17ed91b308ade8dff027a92e7716d2103548ca1916957bc06dd1c6e3639ebf7b2c3c8b1715915433c1d37cab56fb26ef0210218a240a599ba437cb1458966eb456d9f848e5bdef45ea0ee4ec31fc40aa4ffa853ae"
}

bitcoin-cli -regtest getnewaddress

2NAsEawSCjsjJjtAZcpP9jhXojqNUevjo63

bitcoin-cli -regtest generatetoaddress 110 2NAsEawSCjsjJjtAZcpP9jhXojqNUevjo63

[
  "7e974615714bdcee6f4c69ea158b92fe2c0b728742110737e7ff13d9e8eb49ad",
  ...
]

bitcoin-cli -regtest listunspent

[
  ...
  {
    "txid": "9c9298a5d7ceca73f657110c0222ee606324263694d59722a2194b22ccc8b0ff",
    "vout": 0,
    "address": "2NAsEawSCjsjJjtAZcpP9jhXojqNUevjo63",
    "label": "",
    "redeemScript": "0014821824c23b9c82fa639789bc3314194d1e44ec4a",
    "scriptPubKey": "a914c1499c99d26f5bb7101f1213747bf730c4b9346287",
    "amount": 50.00000000,
    "confirmations": 102,
    "spendable": true,
    "solvable": true,
    "desc": "sh(wpkh([29b8db74/0'/0'/0']03557ff8751b55175307c0550460694dfe3c84598672fe5b9c53dca71bcb9122ee))#25k8n2ql",
    "safe": true
  }
]

bitcoin-cli -regtest createrawtransaction '[{"txid" : "9c9298a5d7ceca73f657110c0222ee606324263694d59722a2194b22ccc8b0ff","vout":0}]' '{"2NA1HC31wqFexbpp8bGB6rsMR5Lz9SrUKkt":49.999}'

0200000001ffb0c8cc224b19a22297d5943626246360ee22020c1157f673caced7a598929c0000000000ffffffff01606b042a0100000017a914b7d6fcff0fe015a393f8baee424ba82c4e18c6d48700000000

bitcoin-cli -regtest signrawtransactionwithwallet 0200000001ffb0c8cc224b19a22297d5943626246360ee22020c1157f673caced7a598929c0000000000ffffffff01606b042a0100000017a914b7d6fcff0fe015a393f8baee424ba82c4e18c6d48700000000

{
  "hex": "02000000000101ffb0c8cc224b19a22297d5943626246360ee22020c1157f673caced7a598929c0000000017160014821824c23b9c82fa639789bc3314194d1e44ec4affffffff01606b042a0100000017a914b7d6fcff0fe015a393f8baee424ba82c4e18c6d487024730440220249224a99d24a0ae1d91328ea2e8da0936916ea31a28e35013de003af72f658d02201c48618283ac00a8c5b362e8ade530f4cfacd396a99ab78081cea2d18ad8d165012103557ff8751b55175307c0550460694dfe3c84598672fe5b9c53dca71bcb9122ee00000000",
  "complete": true
}

bitcoin-cli -regtest sendrawtransaction 02000000000101ffb0c8cc224b19a22297d5943626246360ee22020c1157f673caced7a598929c0000000017160014821824c23b9c82fa639789bc3314194d1e44ec4affffffff01606b042a0100000017a914b7d6fcff0fe015a393f8baee424ba82c4e18c6d487024730440220249224a99d24a0ae1d91328ea2e8da0936916ea31a28e35013de003af72f658d02201c48618283ac00a8c5b362e8ade530f4cfacd396a99ab78081cea2d18ad8d165012103557ff8751b55175307c0550460694dfe3c84598672fe5b9c53dca71bcb9122ee00000000

8b0cd4413dad3e1f02f7344236ba4b3d1994c3cd3bbdda1acc9b2d2c0e184453
4
  • Thank you very much!! Could you please also tell me what would I do differently if I did not want P2SH but a simple locking script? Jul 26, 2019 at 16:23
  • no problem! I don't think there is a built-in way to do that in Bitcoin Core, you'll have to use createrawtransaction but instead of using address in the output section, use raw hex data that you've created with the raw scripts: bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/…
    – JBaczuk
    Jul 26, 2019 at 16:37
  • so it will be something like this: bitcoin-cli -regtest createrawtransaction "[{\"txid\":\"9c9298a5d7ceca73f657110c0222ee606324263694d59722a2194b22ccc8b0ff\",\"vout\":0}]" "[{\"data\":hex}]". Do you also know how would I state the amount of BTC spent and what is this hexadecimal value? Again thank you so much! Jul 26, 2019 at 16:56
  • Yeah, but that's a lot more involved, you could search for how a transaction is built and how multisig scripts are built
    – JBaczuk
    Jul 26, 2019 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.