<p>The problem is that in addition to the buffer (denoted as <code>psbtBuffer</code> in the code you provided), it is necessary to pass the <code>txGetter</code> function as a second parameter to the <code>fromBuffer</code> function. If you don't do this, javaScript considers the second parameter as <code>undefined</code> so that later calls to the given function (<code>const unsignedTx = txGetter(unsignedTxMaps[0].value);</code>) will not be possible.</p>
<p>The <code>README</code> says the following:</p>
<blockquote>
<p>// This will parse the PSBT, and use the function you pass to parse the Transaction part<br />
// the function should throw if the scriptSig section is not empty<br />
const psbt = Psbt.fromBuffer(somePsbtBuffer, pTxFromBuffer)</p>
</blockquote>

CC BY-SA 4.0
2023-10-01T13:55:54.270Z
2023-10-01T14:11:53.953Z
2023-10-01T14:11:53.953Z
dassd
<pre><code>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));
</code></pre>
<p>error:
const unsignedTx = txGetter(unsignedTxMaps[0].value);                      ^
TypeError: txGetter is not a function</p>

<javascript><bitcoinjs><bip174-psbt>
Getting Error while trying to decode psbt base64 to json using bitcoinjs/bip174 library
soumyadeep.eth
# Getting Error while trying to decode psbt base64 to json using bitcoinjs/bip174 library

(Asked by: username_0 on 2023-10-01)

```
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

**Tags:** javascript, bitcoinjs, bip174-psbt


---

## 1 answers

### Answer by username_1 on 2023-10-01. Score: 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)


---

