2
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.data;

console.log(JSON.stringify(psbtJSON, null, 2));

error: const unsignedTx = txGetter(unsignedTxMaps[0].value); ^ TypeError: txGetter is not a function

1 Answer 1

1

The problem is that in addition to the buffer (denoted as psbtBuffer in the code you provided), it is necessary to pass the txGetter function as a second parameter to the fromBuffer function. If you don't do this, javaScript considers the second parameter as undefined so that later calls to the given function (const unsignedTx = txGetter(unsignedTxMaps[0].value);) will not be possible.

The README says the following:

// This will parse the PSBT, and use the function you pass to parse the Transaction part
// the function should throw if the scriptSig section is not empty
const psbt = Psbt.fromBuffer(somePsbtBuffer, pTxFromBuffer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.