Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitcoin cash just like bitcoin and doge coin #902

Open
athamidn opened this issue Aug 22, 2022 · 0 comments
Open

Bitcoin cash just like bitcoin and doge coin #902

athamidn opened this issue Aug 22, 2022 · 0 comments

Comments

@athamidn
Copy link

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:

#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant