Please can someone help with Bitcoinjs-lib?

Please can someone help with Bitcoinjs-lib?

I used a rebased branch(cash402) in bitcoinjs-lib In github for building a BCH wallet, I have been trying to get this to work here's my code. Would anybody point out what i might possibly be missing.

let tx = new bitcoincashjs.TransactionBuilder(network)

let root = bip32.fromSeed(mnemonic, network)

let account = root.derivePath("m/44/145'/1'/1")

let wif = account.toWIF()

let keyPair = bitcoincashjs.ECPair.fromWIF(wif, network)

let pk = keyPair.publicKey

let spk = bitcoincashjs.payments.p2pk({ pubkey : pk }).output

tx.addInput(txid, vout, bitcoincashjs.Transaction.DEFAULT_SEQUENCE, spk)

tx.addOutput(cashAddr.toLegacyAddress(receiving_address), sending_amount_sat)

tx.addOutput(cashAddr.toLegacyAddress(change_address.address), change_amount)

tx.enableBitcoinCash()

tx.setVersion(2)

let hashType = bitcoincashjs.Transaction.SIGHASH_ALL | bitcoincashjs.Transaction.SIGHASH_BITCOINCASHBIP143

tx.sign(0, keyPair, null, hashType, sending_amount_sat)

let tx_hex = tx.build().toHex()

https://ift.tt/2PqkrrO

Comments

Popular posts from this blog

bitcoin node: what is the difference between simnet and regtest?

How to check if Electrum is masking my IP with the Tor proxy?

Need help to recover blpckchain.info wallet, my wife forgot her password and the brute force with btcrecover is not catching the password