I am playing with P2SH on regtest and try to understand the logic of creating and signing tx with bitcoin daemon. I am on version 0.15.1, and try to create a tx.

The used scriptPubKey results from a simple if/else/endif statement, not from a standard multisig approach. So I manually created the redeem script, and turned it into an address (beginning with "2"). I then created a transaction, that funds this address. Now I want to spend these funds. While creating the transaction, I discovered that the usage of "scriptPubKey" does not change anything in my output.

Example without "scriptPubKey":

bitcoin-cli -regtest createrawtransaction '''[{"txid":"'b5b67997f36627a461cd5ee1951aa775a68faa0c11c50b8f068ea1c7f4a9b087'","vout":'0'}]''' '''{"'mgpe9b44YYYbhDE1dbWosCSQDPYFkkoHjt'":'9.99995000'}''' 

Example with "scriptPubKey":

bitcoin-cli -regtest createrawtransaction '''[{"txid":"'b5b67997f36627a461cd5ee1951aa775a68faa0c11c50b8f068ea1c7f4a9b087'","vout":'0',"scriptPubKey":"'a914d53c738d730d8623eb2a070833599157beb3f6f687'"}]''' '''{"'mgpe9b44YYYbhDE1dbWosCSQDPYFkkoHjt'":'9.99995000'}'''

The result is exactly the same. When the result is the same, what is the purpose of using this field as a parameter to "createrawtransaction"?


1 Answer 1


Currently, the create raw transaction method only uses the txid and vout parameters from that argument. You can view the relevant part of the source here.

For all practical purposes, you could pass in 00 for the scriptPubKey and still get the same result.

  • 1
    You are right, I've been working with all addresses types and I've never attached it. so yes, it's totally not required. you don't even have to pass anything.
    – Tailer
    Jun 5, 2018 at 8:52
  • Yup, this was also my assumption, based on my tests (and perception). It’s just that I am not good enough in understanding the sources - and I am not comfortable with the „code is documentation“ approach... thx for confirmation! Jun 5, 2018 at 10:57
  • @pebwindcraft Where did you even read about passing a scriptPubKey argument there? As far as I can see this is not mentioned anywhere; not in the code, not in the RPC help, and not on the developer documentation on bitcoin.org. There simply is no such field, expected or used in any way. Jun 5, 2018 at 17:03
  • @PieterWuille Looks like it was mentioned in some issues/examples years ago, and a bunch of tutorials now just copy that: github.com/bitcoin/bitcoin/issues/6483, bitcoin.stackexchange.com/q/35750/7272 Jun 5, 2018 at 17:07
  • @RaghavSood Ah, I see. I think it's just signrawtransaction that need scriptPubKey (when the UTXO is not known to wallet or node), and people simplify things and pass the same argument to createrawtransaction as well - but it has never had any use there. Jun 5, 2018 at 17:29

Your Answer

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

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