I used the bitcoin-cli createrawtransaction to create the txhex.
And it can be signed by using: bitcoin-cli signrawtransactionwithkey.
I can use TransactionBuilder from bitcoinjs-lib to sign the txhex as well:
var txhex = '0200000001b1 xxxxx xxxxxx 00000'; // too long to past here.
const BTC_TESTNET = bitcoin.networks.testnet;
var txb = bitcoin.TransactionBuilder.fromTransaction (bitcoin.Transaction.fromHex (txhex), BTC_TESTNET);
const alice = bitcoin.ECPair.fromWIF('example wif cQuy6PDHYrq6bp5vsev3eL1VTcC5fAKZhWB1HHUFoU4goXeSY5 ',BTC_TESTNET)
const p2wpkh = bitcoin.payments.p2wpkh({ pubkey: alice.publicKey, network: BTC_TESTNET })
const p2sh = bitcoin.payments.p2sh({ redeem: p2wpkh, network: BTC_TESTNET })
txb.sign({
prevOutScriptType: 'p2pkh',
vin: 0,
keyPair: alice,
})
txb.build().toHex()
But TransactionBuilder is going to be removed from future release. Officially the PSBT is suggested. Could anyone give me some info about how to use PSBT to sign hex created from bitcoin-cli?
I used the bitcoin-cli createrawtransaction to create the txhex. And it can be signed by using: bitcoin-cli signrawtransactionwithkey.
I can use TransactionBuilder from bitcoinjs-lib to sign the txhex as well:
But TransactionBuilder is going to be removed from future release. Officially the PSBT is suggested. Could anyone give me some info about how to use PSBT to sign hex created from bitcoin-cli?