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 !
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).