public int getNumberOfSignaturesRequiredToSpend ( ) { if ( ScriptPattern . isSentToMultisig ( this ) ) { // for N of M CHECKMULTISIG script we will need N signatures to spend ScriptChunk nChunk = chunks . get ( 0 ) ; return Script . decodeFromOpN ( nChunk . opcode ) ; } else if ( ScriptPattern . isP2PKH ( this ) || ScriptPattern . isP2PK ( this ) ) { // P2PKH and P2PK require single sig return 1 ; } else if ( ScriptPattern . isP2SH ( this ) ) { throw new IllegalStateException ( "For P2SH number of signatures depends on redeem script" ) ; } else { throw new IllegalStateException ( "Unsupported script type" ) ; } }
Returns number of signatures required to satisfy this script .