Bitcoin Stack Change is a query and reply web site for Bitcoin crypto-currency fanatics. It solely takes a minute to enroll.
Anyone can ask a query
Anyone can reply
One of the best solutions are voted up and rise to the highest
Requested
Seen
33 occasions
const base64PSBT = 'base_64';
// Decode the base64 PSBT to a Buffer
const psbtBuffer = Buffer.from(base64PSBT, 'base64');
// Parse the PSBT
const psbt = bip174.Psbt.fromBuffer(psbtBuffer);
// Convert the PSBT to a JSON object
const psbtJSON = psbt.knowledge;
console.log(JSON.stringify(psbtJSON, null, 2));
error:
const unsignedTx = txGetter(unsignedTxMaps[0].worth); ^
TypeError: txGetter just isn’t a perform
The issue is that along with the buffer (denoted as psbtBuffer
within the code you supplied), it’s essential to cross the txGetter
perform as a second parameter to the fromBuffer
perform. For those who do not do that, javaScript considers the second parameter as undefined
in order that later calls to the given perform (const unsignedTx = txGetter(unsignedTxMaps[0].worth);
) is not going to be doable.
The README
says the next:
// This may parse the PSBT, and use the perform you cross to parse the Transaction half
// the perform ought to throw if the scriptSig part just isn’t empty
const psbt = Psbt.fromBuffer(somePsbtBuffer, pTxFromBuffer)