I have create a coinbase transaction successfully with the command:

createrawtransaction '[{"txid":"0000000000000000000000000000000000000000000000000000000000000000","vout":0}]' '{"12Evb28oMpkP76HRS2CZ7VjNMD25B84VMv":12.5}'

what give a hex string for the transaction. But when I try signrawtransaction I got this error:

  "hex": "...",
  "complete": false,
  "errors": [
      "txid": "0000000000000000000000000000000000000000000000000000000000000000",
      "vout": 0,
      "scriptSig": "",
      "sequence": ...,
      "error": "Input not found or already spent"

with sendrawtransactions i got:

Missing inputs (code -25)

what I have to do with this transaction after create it?


A coinbase transaction is not one that is signed or broadcast to the network. Rather it should be the first transaction in the block that you are mining. Also, the first 4 bytes of the scriptSig must be the block's height (1 byte for pushdata 3 bytes for the height).

  • The result for the command createrawtransaction above is a hex string. FOr create the block I want broadcast, I think I need a transaction id (txid)? Or am I mistaken? If I am not, how I get the txid for the coinbase transaction? – Kleber Mota Aug 27 '17 at 16:22
  • 1
    The txid is the hash of the bytes of the transaction, so you first need to make the hexstring an array of bytes and then hash that with sha256d. The block also contains that transaction, not the txid (the txid is only part of the merkle root), so your block, when you broadcast it, must also contain the transaction itself. – Andrew Chow Aug 27 '17 at 16:39
  • Do you know how to pack the transaction to append to the block? Just create a array with each field and then hash it with sha256d? – Kleber Mota Aug 27 '17 at 23:47
  • The hash is not included in the block. It is only used for creating the merkle root. The transaction is the hex string that createrawtransaction gives you. You will need to slightly modify it. That hex string is a string representation of the bytes, so you will need to convert it into an array of bytes. Every two characters is one byte. – Andrew Chow Aug 28 '17 at 1:13
  • 1
    You just need the hex of the transaction which you can get by using getrawtransaction. – Andrew Chow Aug 28 '17 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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