Closed assafshomer closed 7 years ago
Bitcoin.open_key(wif)
is invalid. open_key
dose not support wif format.
And ec_key.public_key_hex
is uncompressed pubkey, so verify_input_signature
is fail.
If you write as follows you can sign correctly.
key = Bitcoin::Key.from_base58(wif)
sig = key.sign(tx.signature_hash_for_input(0, prev_tx))
tx.in[0].script_sig = Bitcoin::Script.to_signature_pubkey_script(sig, [key.pub].pack("H*"))
In this example it is shown how to sign a previously unsigned tx. I think something is missing. Here is an example:
Start with signing a tx the standard way with TxBuilder:
We get
as one would expect.
Now let's try to do the same with the method described in the example:
This time the result is false. Changing the wif format doesn't seem to help either
ec_key = Bitcoin.open_key(key.priv)
What am I missing?