mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-20 10:13:26 +01:00
Implementing generator for p2sh(p2wsh) transactions
This commit is contained in:
parent
202c5df832
commit
b542961ed9
@ -140,7 +140,6 @@ trait ScriptInterpreter extends CryptoInterpreter with StackInterpreter with Con
|
||||
val redeemScript = ScriptPubKey(c.bytes ++ redeemScriptBytes)
|
||||
redeemScript match {
|
||||
case w : WitnessScriptPubKey =>
|
||||
logger.error("Witness scriptPubKey")
|
||||
val pushOp = BitcoinScriptUtil.calculatePushOp(redeemScriptBytes)
|
||||
val expectedScriptBytes = pushOp.flatMap(_.bytes) ++ redeemScriptBytes
|
||||
val flags = scriptPubKeyExecutedProgram.flags
|
||||
@ -148,7 +147,7 @@ trait ScriptInterpreter extends CryptoInterpreter with StackInterpreter with Con
|
||||
if (segwitEnabled && (scriptSig.asmBytes == expectedScriptBytes)) {
|
||||
// The scriptSig must be _exactly_ a single push of the redeemScript. Otherwise we
|
||||
// reintroduce malleability.
|
||||
logger.error("redeem script was witness script pubkey, segwit was enabled, scriptSig was single push of redeemScript")
|
||||
logger.info("redeem script was witness script pubkey, segwit was enabled, scriptSig was single push of redeemScript")
|
||||
executeSegWitScript(scriptPubKeyExecutedProgram,w)
|
||||
} else if (segwitEnabled && (scriptSig.asmBytes != expectedScriptBytes)) {
|
||||
logger.error("Segwit was enabled, but p2sh redeem script was malleated")
|
||||
|
@ -130,4 +130,11 @@ class TransactionSignatureCreatorSpec extends Properties("TransactionSignatureCr
|
||||
result == ScriptOk
|
||||
}
|
||||
|
||||
property("generate a valid signature from a p2sh(p2wsh) witness tranasction") =
|
||||
Prop.forAllNoShrink(TransactionGenerators.signedP2SHP2WSHTransaction) { case (wtxSigComponent, privKeys) =>
|
||||
val program = ScriptProgram(wtxSigComponent)
|
||||
val result = ScriptInterpreter.run(program)
|
||||
if (result != ScriptOk) logger.warn("Result: " + result)
|
||||
result == ScriptOk
|
||||
}
|
||||
}
|
||||
|
@ -144,5 +144,4 @@ class TransactionSignatureCreatorTest extends FlatSpec with MustMatchers with Bi
|
||||
result must be (ScriptOk)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user