1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 14:22:39 +01:00

Electrum: fix signature bug (#524)

Regression caused signature to use wrong utxo amount which means it would not be valid, and the
funding tx could not be published.
This commit is contained in:
Fabrice Drouin 2018-03-29 20:20:39 +02:00 committed by GitHub
parent b2178ade30
commit 717eaa799f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -736,7 +736,7 @@ object ElectrumWallet {
tx.copy(txIn = tx.txIn.zipWithIndex.map { case (txIn, i) =>
val utxo = utxos.find(_.outPoint == txIn.outPoint).getOrElse(throw new RuntimeException(s"cannot sign input that spends from ${txIn.outPoint}"))
val key = utxo.key
val sig = Transaction.signInput(tx, i, Script.pay2pkh(key.publicKey), SIGHASH_ALL, Satoshi(utxos(i).item.value), SigVersion.SIGVERSION_WITNESS_V0, key.privateKey)
val sig = Transaction.signInput(tx, i, Script.pay2pkh(key.publicKey), SIGHASH_ALL, Satoshi(utxo.item.value), SigVersion.SIGVERSION_WITNESS_V0, key.privateKey)
val sigScript = Script.write(OP_PUSHDATA(Script.write(Script.pay2wpkh(key.publicKey))) :: Nil)
val witness = ScriptWitness(sig :: key.publicKey.toBin :: Nil)
txIn.copy(signatureScript = sigScript, witness = witness)