Bitcoinjs-lib: Error #-25: Missing inputs, code=-25

Created on 22 Nov 2017  路  7Comments  路  Source: bitcoinjs/bitcoinjs-lib

When broadcast transaction using bitcoinjs signed transaction will result the error code

Validation Error: BitcoindException(super=com.neemre.btcdcli4j.core.BitcoindException: Error #-25: Missing inputs, code=-25)
var bitcoin = require('bitcoinjs-lib')
var keyPair = bitcoin.ECPair.fromWIF('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVw1')
var tx = new bitcoin.TransactionBuilder()

tx.addInput('aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31', 0)
tx.addOutput('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000)
tx.sign(0, keyPair)
txHEX = tx.build().toHex()
console.log(txHEX);

var tx = bitcoin.Transaction.fromHex(txHEX);
console.log(tx)

but if I using some exist TXhex from blockchain.info it can success broadcast.
I thought it's about the version?

how to / question / docs

Most helpful comment

That output was already spent in 2014:

https://btc.com/105eeeb9c448872c2257f93d5e2b14248c4a800cd69641911aa7e964cf570872#in_0

Even still, you should blank out that private key though ASAP..

All 7 comments

That output was already spent in 2014:

https://btc.com/105eeeb9c448872c2257f93d5e2b14248c4a800cd69641911aa7e964cf570872#in_0

Even still, you should blank out that private key though ASAP..

It just an key from other example.
If it already spend it will says already spend not response code:-25.
Because 6 month ago I was doing the same thing,it will response already spend message to me.
But now only give some exception.I also notice new TXhex now have more bytes in hex,guess it was cause by node version?

You can also using the example from your bitcoinjs website.

var bitcoin = require('bitcoinjs-lib')
var keyPair = bitcoin.ECPair.fromWIF('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy')
var tx = new bitcoin.TransactionBuilder()

var tx = new bitcoin.TransactionBuilder()

// Add the input (who is paying):
// [previous transaction hash, index of the output to use]
var txId = 'aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31'
tx.addInput(txId, 0)

// Add the output (who to pay to):
// [payee's address, amount in satoshis]
tx.addOutput("1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK", 15000)

// Initialize a private key using WIF
var privateKeyWIF = 'L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy'
var keyPair = bitcoin.ECPair.fromWIF(privateKeyWIF)

// Sign the first input with the new key
tx.sign(0, keyPair)

// Print transaction serialized as hex
console.log(tx.build().toHex())

then broadcast using https://blockchain.info/pushtx or bitpay,you will see the error

@EasonWang01 can you post the txHex that you have, so we can compare?

Just run the code above as same as on bitcoinjs website example,will got the following hex.


https://blockchain.info/pushtx will cause error.

I get Missing inputs as the Error from bitcoind.

The inputs aren't in the UTXO, so it makes sense as an error.

Maybe your previous error was using a different backend and they therefore had more information?

I don't think this is an unexpected result.

I found the error only happened when using blockchain.info,so not related to bitcoinjs lib.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

silence-may picture silence-may  路  3Comments

dakk picture dakk  路  3Comments

coingeek picture coingeek  路  4Comments

panpan2 picture panpan2  路  3Comments

yakitorifoodie picture yakitorifoodie  路  3Comments