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???
@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!
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?