mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-20 10:13:26 +01:00
Removing 'CurrencyUnit' return type from generators were it is irrelevant
This commit is contained in:
parent
52103c1d44
commit
306c9727fc
@ -90,15 +90,15 @@ object P2PKHScriptPubKey extends ScriptFactory[P2PKHScriptPubKey] {
|
||||
sealed trait MultiSignatureScriptPubKey extends ScriptPubKey {
|
||||
|
||||
/** Returns the amount of required signatures for this multisignature script pubkey output */
|
||||
def requiredSigs : Long = {
|
||||
def requiredSigs : Int = {
|
||||
val asmWithoutPushOps = asm.filterNot(_.isInstanceOf[BytesToPushOntoStack])
|
||||
val opCheckMultiSigIndex = if (asm.indexOf(OP_CHECKMULTISIG) != -1) asmWithoutPushOps.indexOf(OP_CHECKMULTISIG) else asmWithoutPushOps.indexOf(OP_CHECKMULTISIGVERIFY)
|
||||
//magic number 2 represents the maxSig operation and the OP_CHECKMULTISIG operation at the end of the asm
|
||||
val numSigsRequired = asmWithoutPushOps(opCheckMultiSigIndex - maxSigs.toInt - 2)
|
||||
numSigsRequired match {
|
||||
case x : ScriptNumber => x.underlying
|
||||
case x : ScriptNumber => x.underlying.toInt
|
||||
case c : ScriptConstant if ScriptNumber(c.hex).underlying <= ScriptSettings.maxPublicKeysPerMultiSig =>
|
||||
ScriptNumber(c.hex).underlying
|
||||
ScriptNumber(c.hex).underlying.toInt
|
||||
case _ => throw new RuntimeException("The first element of the multisignature pubkey must be a script number operation\n" +
|
||||
"operation: " + numSigsRequired +
|
||||
"\nscriptPubKey: " + this)
|
||||
@ -106,15 +106,15 @@ sealed trait MultiSignatureScriptPubKey extends ScriptPubKey {
|
||||
}
|
||||
|
||||
/** The maximum amount of signatures for this multisignature script pubkey output */
|
||||
def maxSigs : Long = {
|
||||
def maxSigs : Int = {
|
||||
if (checkMultiSigIndex == -1 || checkMultiSigIndex == 0) {
|
||||
//means that we do not have a max signature requirement
|
||||
0.toLong
|
||||
0
|
||||
} else {
|
||||
asm(checkMultiSigIndex - 1) match {
|
||||
case x : ScriptNumber => x.underlying
|
||||
case x : ScriptNumber => x.underlying.toInt
|
||||
case c : ScriptConstant if ScriptNumber(c.hex).underlying <= ScriptSettings.maxPublicKeysPerMultiSig =>
|
||||
ScriptNumber(c.hex).underlying
|
||||
ScriptNumber(c.hex).underlying.toInt
|
||||
case x => throw new RuntimeException("The element preceding a OP_CHECKMULTISIG operation in a multisignature pubkey must be a script number operation, got: " + x)
|
||||
}
|
||||
}
|
||||
@ -128,7 +128,7 @@ sealed trait MultiSignatureScriptPubKey extends ScriptPubKey {
|
||||
|
||||
/** Returns the public keys encoded into the scriptPubKey */
|
||||
def publicKeys : Seq[ECPublicKey] = {
|
||||
asm.filter(_.isInstanceOf[ScriptConstant]).slice(1, maxSigs.toInt + 1).map(key => ECPublicKey(key.hex))
|
||||
asm.filter(_.isInstanceOf[ScriptConstant]).slice(1, maxSigs + 1).map(key => ECPublicKey(key.hex))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import org.scalacheck.{Prop, Properties}
|
||||
class TransactionSignatureCreatorSpec extends Properties("TransactionSignatureCreatorSpec") with BitcoinSLogger {
|
||||
property("Must generate a valid signature for a p2pk transaction") =
|
||||
Prop.forAll(TransactionGenerators.signedP2PKTransaction) {
|
||||
case (txSignatureComponent: TransactionSignatureComponent, _, _) =>
|
||||
case (txSignatureComponent: TransactionSignatureComponent, _) =>
|
||||
//run it through the interpreter
|
||||
val program: PreExecutionScriptProgram = ScriptProgram(txSignatureComponent)
|
||||
val result = ScriptInterpreter.run(program)
|
||||
@ -24,7 +24,7 @@ class TransactionSignatureCreatorSpec extends Properties("TransactionSignatureCr
|
||||
|
||||
property("generate a valid signature for a p2pkh transaction") =
|
||||
Prop.forAll(TransactionGenerators.signedP2PKHTransaction) {
|
||||
case (txSignatureComponent: TransactionSignatureComponent, _, _) =>
|
||||
case (txSignatureComponent: TransactionSignatureComponent, _) =>
|
||||
//run it through the interpreter
|
||||
val program = ScriptProgram(txSignatureComponent)
|
||||
val result = ScriptInterpreter.run(program)
|
||||
@ -33,7 +33,7 @@ class TransactionSignatureCreatorSpec extends Properties("TransactionSignatureCr
|
||||
|
||||
property("generate valid signatures for a multisignature transaction") =
|
||||
Prop.forAllNoShrink(TransactionGenerators.signedMultiSigTransaction) {
|
||||
case (txSignatureComponent: TransactionSignatureComponent, _, _ ) =>
|
||||
case (txSignatureComponent: TransactionSignatureComponent, _) =>
|
||||
//run it through the interpreter
|
||||
val program = ScriptProgram(txSignatureComponent)
|
||||
val result = ScriptInterpreter.run(program)
|
||||
@ -42,7 +42,7 @@ class TransactionSignatureCreatorSpec extends Properties("TransactionSignatureCr
|
||||
|
||||
property("generate a valid signature for a p2sh transaction") =
|
||||
Prop.forAll(TransactionGenerators.signedP2SHTransaction) {
|
||||
case (txSignatureComponent: TransactionSignatureComponent, _, _) =>
|
||||
case (txSignatureComponent: TransactionSignatureComponent, _) =>
|
||||
//run it through the interpreter
|
||||
val program = ScriptProgram(txSignatureComponent)
|
||||
val result = ScriptInterpreter.run(program)
|
||||
|
Loading…
Reference in New Issue
Block a user