Bitcoinjs-lib: Verify function changed ?

Created on 23 Aug 2017  路  6Comments  路  Source: bitcoinjs/bitcoinjs-lib

I used to proceed like so in order to verify a specific input's signature :
txb = Bitcoin.TransactionBuilder.fromTransaction(tx)
Bitcoin.ECPair.fromPublicKeyBuffer(txb.inputs[0].pubKeys[0]).verify(tx.ins[0].hash, txb.inputs[0].signatures[0])

but now I get this error message : Expected property "1.r" of type BigInteger, got undefined"
Is it broken or what should I change ?
Thanks !

how to / question / docs

All 6 comments

From the Error:

Expected property "1.r" of type BigInteger, got undefined"

txb.inputs[0].signatures[0].r === undefined
var signature = Bitcoin.ECSignature.parseScriptSignature(txb.inputs[0].signatures[0])
Bitcoin.ECPair.fromPublicKeyBuffer(txb.inputs[0].pubKeys[0])
  .verify(tx.ins[0].hash, signature)

I wouldn't rely on TransactionBuilder internals, they should be private, maybe we need to encapsulate those internals strictly using a closure.

I tried the above

var signature = Bitcoin.ECSignature.parseScriptSignature(txb.inputs[0].signatures[0]) Bitcoin.ECPair.fromPublicKeyBuffer(txb.inputs[0].pubKeys[0]) .verify(tx.ins[0].hash, signature)

and still get the error message : Expected property "1.r" of type BigInteger, got undefined"

Is there another way to check if a signature is valid ?

Ok I found the problem,

.verify(tx.ins[0].hash, signature.signature)

Thanks for the help anyways !

@xorq again, I wouldn't rely on those internals. They are going to be subject to change (and possibly soon).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hoshsadiq picture hoshsadiq  路  3Comments

ghost picture ghost  路  3Comments

itsMikeLowrey picture itsMikeLowrey  路  3Comments

zhaozhiming picture zhaozhiming  路  3Comments

LeonYanghaha picture LeonYanghaha  路  3Comments