Help with Bitcoinjs-lib

Help with Bitcoinjs-lib

I used a rebased branch(cash402) in bitcoinjs-lib building BCH wallet, 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/2Q1Yc8y

Comments

Popular posts from this blog

Bitcoin Core errors with database block

Bitfinex & Market Synergy To Offer Institutional Calibre Cryptocurrency Connectivity