public static byte[] createMultiSigOutputScript(int threshold,List<ECKey> pubkeys){
  checkArgument(threshold > 0);
  checkArgument(threshold <= pubkeys.size());
  checkArgument(pubkeys.size() <= 16);
  if (pubkeys.size() > 3) {
    log.warn("Creating a multi-signature output that is non-standard: {} pubkeys, should be <= 3",pubkeys.size());
  }
  try {
    ByteArrayOutputStream bits=new ByteArrayOutputStream();
    bits.write(encodeToOpN(threshold));
    for (    ECKey key : pubkeys) {
      writeBytes(bits,key.getPubKey());
    }
    bits.write(encodeToOpN(pubkeys.size()));
    bits.write(OP_CHECKMULTISIG);
    return bits.toByteArray();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

public static byte [ ] createMultiSigOutputScript ( int threshold , List < ECKey > pubkeys ) { checkArgument ( threshold > 0 ) ; checkArgument ( threshold <= pubkeys . size ( ) ) ; checkArgument ( pubkeys . size ( ) <= 16 ) ; if ( pubkeys . size ( ) > 3 ) { log . warn ( "Creating a multi-signature output that is non-standard: {} pubkeys, should be <= 3" , pubkeys . size ( ) ) ; } try { ByteArrayOutputStream bits = new ByteArrayOutputStream ( ) ; bits . write ( encodeToOpN ( threshold ) ) ; for ( ECKey key : pubkeys ) { writeBytes ( bits , key . getPubKey ( ) ) ; } bits . write ( encodeToOpN ( pubkeys . size ( ) ) ) ; bits . write ( OP_CHECKMULTISIG ) ; return bits . toByteArray ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
creates a program that requires at least n of the given keys to sign , using op_checkmultisig .
