paulmillr / scure-btc-signer

Audited & minimal library for creating, signing & decoding Bitcoin transactions.
https://paulmillr.com/noble/#scure
MIT License
158 stars 41 forks source link

Error: Reader(inputs/0/finalScriptSig): readBytes: Unexpected end of buffer #100

Closed cmdruid closed 4 months ago

cmdruid commented 4 months ago

Hello. I am getting this error when trying to encode a PSBT with a single output.

My code:

const psbt = new Transaction()

psbt.addOutput({ amount : BigInt(10000), script : '51203701d8f81bf26a07eebef592f2960e4b6db32b09fce20246db0842ebfc45001b' })

console.log(psbt)

const b64 = psbt.toPSBT(0)

console.log('psbt:', b64)

The error:

Error: Reader(inputs/0/finalScriptSig): readBytes: Unexpected end of buffer
    at Object.err (file:///home/.../node_modules/micro-packed/lib/esm/index.js:290:21)
    at _Reader.err (file:///home/.../node_modules/micro-packed/lib/esm/index.js:401:21)
    at _Reader.bytes (file:///home/.../node_modules/micro-packed/lib/esm/index.js:414:24)
    at Object.decodeStream (file:///home/.../node_modules/micro-packed/lib/esm/index.js:1252:27)
    at Object.decodeStream (file:///home/.../node_modules/micro-packed/lib/esm/index.js:652:31)
    at file:///home/.../node_modules/micro-packed/lib/esm/index.js:1633:67
    at file:///home/.../node_modules/micro-packed/lib/esm/index.js:277:13
    at file:///home/.../node_modules/micro-packed/lib/esm/index.js:1633:21
    at Object.pushObj (file:///home/.../node_modules/micro-packed/lib/esm/index.js:275:9)
    at _Reader.pushObj (file:///home/.../node_modules/micro-packed/lib/esm/index.js:360:21)