-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assertion failed for demo #3357
Comments
Hi, I have the same issue. The reason is the bn.js library which is used by the elliptic library. The (old) bn.js version which is used overrides the "Buffer" class. The following patch fixes the issue for me.
|
How does one apply this patch? |
this is just the git diff, so remove the lines that have a - and replace them with the lines that have a + |
@RobertW123 Thanks mate. Could you explain how to apply that patch? |
I was also stuck on the same issue. Here is some information I found. It looks like there are a couple of upstream pull requests to update elliptic to use bn.js 5: As well there is some further discussion here: It appears the second pull request indutny/elliptic#246 fixes the issue for me. To apply it, I thought it would make more sense to apply via the package manager npm rather than manually hotpatching the modules. I wanted to fork this repo and simply update the So I forked this repo, removed all the monorepo stuff, and left only a copy of bitcore-lib with the hotfix applied: bplunkert/bitcore-lib#elliptic_bn_js_hotfix I do not want to maintain this fork, so I'm hoping that elliptic merges indutny/elliptic#246 soon. In the meantime, you can apply the fix like this by replacing your bitcore-lib line in
|
thanks! @bplunkert Just installing bn.js fixed the issue for me. Your hotfix worked as well! |
|
https://github.com/bitpay/bitcore/blob/master/packages/bitcore-lib/docs/examples.md#create-a-transaction
https://github.com/bitpay/bitcore/blob/master/packages/bitcore-lib/docs/examples.md#spend-from-a-2-of-2-multisig-p2sh-address
var privateKey = new bitcore.PrivateKey('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy');
var utxo = {
"txId" : "115e8f72f39fad874cfab0deed11a80f24f967a84079fb56ddf53ea02e308986",
"outputIndex" : 0,
"address" : "17XBj6iFEsf8kzDMGQk5ghZipxX49VXuaV",
"script" : "76a91447862fe165e6121af80d5dde1ecb478ed170565b88ac",
"satoshis" : 50000
};
var transaction = new bitcore.Transaction()
.from(utxo)
.to('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000)
.sign(privateKey);
get.vue?1d8e:243 error Error: Assertion failed
at assert (bn.js?399f:6:1)
at BN.toBuffer (bn.js?399f:529:1)
at Signature.toBuffer.Signature.toDER (signature.js?47cf:169:1)
at PublicKeyHashInput.addSignature (publickeyhash.js?7937:132:1)
at Transaction.applySignature (transaction.js?97ea:1220:1)
at eval (transaction.js?97ea:1189:1)
at arrayEach (lodash.js?2ef0:530:1)
at Function.forEach (lodash.js?2ef0:9410:1)
at Transaction.sign (transaction.js?97ea:1188:1)
at eval (get.vue?1d8e:237:1)
The text was updated successfully, but these errors were encountered: