Bitcoinjs-lib: Inconsistent network issue

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

https://github.com/bitcoinjs/bitcoinjs-lib/blob/348280eb9a9eea321441e3aa607a74c7f3c8a4b5/src/transaction_builder.js#L649

Look at the line above, it's comparing the two objects which as I know javascript does not support object comparison this way. So I always have this issue when trying to sign the tx.

Anyone has the same issue???

how to / question / docs

Most helpful comment

@namnv04 understandable, but, I suppose I didn't expect a deep comparison to be necessary as the network objects are not expected to change (or come from different sources).
Can you elaborate on how you are coming up against this problem?

All 3 comments

@namnv04 understandable, but, I suppose I didn't expect a deep comparison to be necessary as the network objects are not expected to change (or come from different sources).
Can you elaborate on how you are coming up against this problem?

@dcousens Thanks for quick reply.

It was my bad doing this

const keyPair = bitcoin.HDNode.fromBase58(base58, testnet);
tx.sign(index, keyPair);

I should'v done this instead

const key = bitcoin.HDNode.fromBase58(base58, network.testnet);
tx.sign(index, key.keyPair);

Since I passed wrong keyPair, keyPair.network value inside sign method become undefined and it gets default network which is network.bitcoin and that's the reason it throws the error.

Thanks anyway and hope this might save sometime of who runs into same situation

Thanks for the feedback!

We are constantly trying to improve and simplify the interfaces for bitcoinjs-lib.

Points of confusion around HDNode is something I have looked into recently, and noted isn't the greatest. Hopefully this gets better with time.

Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yakitorifoodie picture yakitorifoodie  路  3Comments

silence-may picture silence-may  路  3Comments

ishwarchandratiwari picture ishwarchandratiwari  路  3Comments

zhaozhiming picture zhaozhiming  路  3Comments

rbndg picture rbndg  路  3Comments