if script isPayToScriptHash throw new IllegalStateExceptio Not p2sh ou

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
if (!script.isPayToScriptHash) {
throw new IllegalStateException("Not a p2sh output script!")
} else {
val redeem = input.getScriptSig
val secondKeyBytes = EncodingUtils.hex2bytes("c6b56218d28b36b9c043e1ef6009c7a1d3c896b24cf41c8f5dc784df44dcc5ba")
val secondKey = ECKey.fromPrivate(secondKeyBytes)
val signature = tx.calculateSignature(0, key, redeem, SigHash.ALL, false)
val signature2 = tx.calculateSignature(0, secondKey, redeem, SigHash.ALL, false)
val ss = ScriptBuilder.createP2SHMultiSigInputScript(List(signature,signature2), redeem)
input.setScriptSig(ss)
}