Bit-Wasp / bitcoin-php

Bitcoin implementation in PHP
The Unlicense
1.05k stars 419 forks source link

how can I sign it using bitcoin-php version 1.0? #835

Open afk11 opened 4 years ago

afk11 commented 4 years ago

Having the raw transaction (non-signed), how can I sign it using bitcoin-php version 1.0?

Originally posted by @Gwinest in https://github.com/Bit-Wasp/bitcoin-php/issues/166#issuecomment-588584875

afk11 commented 4 years ago

Decode a transaction https://github.com/Bit-Wasp/bitcoin-php/blob/1.0/examples/doc/tx/005_create_tx_from_hex.php Sign a P2SH multisig transaction. There are examples of other address types. Just delete the part that builds the spend transaction, and call TransactionFactory::fromHex instead. https://github.com/Bit-Wasp/bitcoin-php/blob/1.0/examples/tx.spend.p2sh.multisig.php

Gwinest commented 4 years ago

It still does not work, I'm using the following scripts from the examples folder: transactionBuilder.php tx.sighash.single.bug.php

I'm uniting both of them to build the Transaction and sign in.

But it gives me an error: Uncaught BitWasp\Bitcoin\Exceptions\ScriptQualificationError: Invalid script signature - must be PUSHONLY.

afk11 commented 4 years ago

Unfortunately I can't debug your code without seeing it. Based on the error, you probably put the redeem or output script in the scriptSig instead of pushing it..

Gwinest commented 4 years ago

Your assumption was correct, indeed. It worked.