How to correctly sign a transaction? Error: 64: scriptsig-not-pushonly

2

I sent a transaction with far too low fee and it's stuck in mempool.

I'm trying to do a double-spend with a higher fee without any luck.

My wallet: 15Zz2KP5iA7oVarmtmBvb9ZHUmQaSFL9M8

Unconfirmed transaction: 0b0177688485922027b336c24e765fdea8dc03d2ad79f87019705f2ca9fb970a

I'm using coinb.in to create, sign and broadcast transaction but I get Error: 64: scriptsig-not-pushonly.

The transaction seems to be valid when I verify it.

Can anyone point my in the right direction for this?

James Jackson

Posted 2017-03-14T16:20:21.897

Reputation: 123

I've added an answer to the specific problem, however, I do not recommend to try to double spend the transaction, since I don't think it will work. If first transaction is already in most of the nodes mempool, the new one will be treated as a double spend and be rejected. The best you can do is either wait, or create a transaction spending from you first one (the one with low fees) and adding a higher fee that new transaction (using what is called Child pays for Parent).sr-gi 2017-03-14T17:05:25.800

Answers

0

You are building an incorrect scriptSig.

Notice that, if you check the scriptSig of every input from the transaction you provided, it looks like:

76a914321d6a0077ddadfcce3d68d302d866ce81405eba88ac

Which has the following structure:

OP_DUP OP_HASH160 <20-byte-hash> OP_EQUALVERIFY OP_CHECKSIG

However, this is not what is expected to be found in a scriptSig, but what will be expected in the scriptPubKey field.

What you have to do is provide the correct script in the scriptSig field of each input of the transaction, that would correspond to the signature of the transaction if you are creating a P2PKH transaction, or the script that matches with the script-hash from the UTXO you are spending, in case you are building a P2SH transaction.

sr-gi

Posted 2017-03-14T16:20:21.897

Reputation: 2 382

I did wonder where the answer went :) . Thanks for the answer. Do you have any suggestions of site's that might be able do make this process easier? coinb.in doesn't seem to have the options I need.James Jackson 2017-03-14T17:15:09.857

I messed up a little with the first answer, since the scripts where like switched and something does not seems right. I preferred to refrase it :P. What are you trying to do?sr-gi 2017-03-14T17:20:08.283

I mean, what do you mean with "this process"?sr-gi 2017-03-14T17:48:57.727

The process of creating the correct transaction. I was using coinb.in because it seemed like it would simplify the process but it's "transaction" generator doesn't seem to do what it needs to do to correctly make this transaction.James Jackson 2017-03-15T16:30:29.657

Well, if you need to create a transaction you will need to manage the keys associated with the Bitcoin addresses where the bitcoins are "stored". In order to sign the transactions in P2PKH transactions or to create the proper scripts in P2SH. What I think is that when you used the coinb.in tools, you forgot to sign the transaction (I'm not used to the tool, so I can be wrong). In conclusion, you will need something more similar to a wallet.sr-gi 2017-03-15T21:22:35.610

Think it's coinb.in not doing what I wanted. I was trying to avoid a wallet but oh well. (Luckily, blockchain.info stopped broadcasting my transaction to allow me me to spend it again.) Thanks for your help.James Jackson 2017-03-16T17:20:28.430

Well, you can allways do it by yourself using one of the multiple libraries available (depending on the programing language you prefer), the fact is that if you need to sign transactions, you need to use your private key, and relaying in some website tool to do so, by importing the key is not the best choice when money comes into play (at least from my point of view).sr-gi 2017-03-16T19:08:14.123

can you give us a clear example of scriptSig, and scriptPubKey fields. Because, I am getting the same error, although i am creating a raw transaction using python.kaliu 2017-03-19T07:42:27.863

@ kaliu For a traditional P2PKH transaction, the structure will be: scriptSig = <signature><pubKey>, and the scriptPubKey will be: OP_DUP OP_HASH160 <hash160_of_pubkey> <OP_EQUALVERIFY><OP_CHECKSIG>. Take into account that the data pushes and the hash_type are not included in this structure, but they are in the serialized representation of the script. If you need an specific example, I think it's better to ask it as a question, since there is not much space in the comment section, nor correct format to correctly respond it.sr-gi 2017-03-20T16:35:41.797