Open athamidn opened 2 years ago
I'm using version 1 of this package. Now I can create transaction in Bitcoin, Dogecoin, Litecoin But I can't crate a transaction in Bitcoin cash just in this way:
$network = \Btccom\BitcoinCash\Network\NetworkFactory::bitcoinCash(); $ecAdapter = Bitcoin::getEcAdapter(); $addrCreator = new AddressCreator(); $privFactory = new PrivateKeyFactory($ecAdapter); $builder = TransactionFactory::build()->version(1)->locktime(0); //calculate fee $fee = 1000; $userRequestedAmount = 12397616; //input $builder->input("....b8815e827291bff4bc49d7d5bf.................................", 0); //output $sendTo = "1HemG43iWsbu3KwpaVK....3SUR15z........"; $builder->payToAddress($userRequestedAmount, $addrCreator->fromString($sendTo, $network)); $changeAddress = "1HemG43iWsbu3KwpaVKoY83S.............."; $unsigned = $builder->get(); $signer = new Signer($unsigned, $ecAdapter); $privPer = ".....dtSUN........G1ZMSNahoSkYtCRG...."; $privateKey = $privFactory->fromWif($privPer, $network); $txOut = new TransactionOutput(12399616 , ScriptFactory::scriptPubKey()->payToPubKeyHash($privateKey->getPublicKey()->getPubKeyHash())); $signer->sign(0, $privateKey, $txOut); $signed = $signer->get(); dd($signed->getHex());
error in broadcast:
Invalid transaction. Error: mandatory-script-verify-flag-failed (Signature must use SIGHASH_FORKID) (code 16)
. I checked the previous issue in this link:
https://github.com/Bit-Wasp/bitcoin-php/issues/609
also I checked this sample:
https://github.com/btccom/bitwasp-bitcoin-bch-addon/blob/master/test/Transaction/Factory/SignerTest.php
but none of them doesn't work.
I'm using version 1 of this package. Now I can create transaction in Bitcoin, Dogecoin, Litecoin But I can't crate a transaction in Bitcoin cash just in this way:
error in broadcast:
Invalid transaction. Error: mandatory-script-verify-flag-failed (Signature must use SIGHASH_FORKID) (code 16)
. I checked the previous issue in this link:
https://github.com/Bit-Wasp/bitcoin-php/issues/609
also I checked this sample:
https://github.com/btccom/bitwasp-bitcoin-bch-addon/blob/master/test/Transaction/Factory/SignerTest.php
but none of them doesn't work.