ScriptBuilder { public static byte[] buildVerificationScript(byte[] encodedPublicKey) { return new ScriptBuilder() .pushData(encodedPublicKey) .opCode(OpCode.PUSHNULL) .sysCall(InteropServiceCode.NEO_CRYPTO_VERIFYWITHECDSASECP256R1) .toArray(); } ScriptBuilder(); ScriptBuilder opCode(OpCode opCode); ScriptBuilder opCode(OpCode opCode, byte[] argument); ScriptBuilder contractCall(ScriptHash scriptHash, String method,
            List<ContractParameter> params); ScriptBuilder sysCall(InteropServiceCode operation); ScriptBuilder pushParams(List<ContractParameter> params); ScriptBuilder pushParam(ContractParameter param); ScriptBuilder pushInteger(int v); ScriptBuilder pushInteger(BigInteger v); ScriptBuilder pushBoolean(boolean bool); ScriptBuilder pushData(String data); ScriptBuilder pushData(byte[] data); ScriptBuilder pushArray(ContractParameter[] params); ScriptBuilder pack(); byte[] toArray(); static byte[] buildVerificationScript(byte[] encodedPublicKey); static byte[] buildVerificationScript(List<byte[]> encodedPublicKeys,
            int signingThreshold);  }
@Test public void buildVerificationScriptFromMultiplePublicKeys() { final String key1 = "035fdb1d1f06759547020891ae97c729327853aeb1256b6fe0473bc2e9fa42ff50"; final String key2 = "03eda286d19f7ee0b472afd1163d803d620a961e1581a8f2704b52c0285f6e022d"; List<byte[]> keys = Arrays.asList(Numeric.hexStringToByteArray(key1), Numeric.hexStringToByteArray(key2)); byte[] script = ScriptBuilder.buildVerificationScript(keys, 2); byte[] expected = Numeric.hexStringToByteArray("" + OpCode.PUSH2.toString() + OpCode.PUSHDATA1.toString() + "21" + key1 + OpCode.PUSHDATA1.toString() + "21" + key2 + OpCode.PUSH2.toString() + OpCode.PUSHNULL.toString() + OpCode.SYSCALL.toString() + InteropServiceCode.NEO_CRYPTO_CHECKMULTISIGWITHECDSASECP256R1.getHash() ); assertArrayEquals(expected, script); }
@Test public void buildVerificationScriptFromSinglePublicKey() { final String key = "035fdb1d1f06759547020891ae97c729327853aeb1256b6fe0473bc2e9fa42ff50"; byte[] script = ScriptBuilder.buildVerificationScript(Numeric.hexStringToByteArray(key)); byte[] expected = Numeric.hexStringToByteArray("" + OpCode.PUSHDATA1.toString() + "21" + key + OpCode.PUSHNULL.toString() + OpCode.SYSCALL.toString() + InteropServiceCode.NEO_CRYPTO_VERIFYWITHECDSASECP256R1.getHash() ); assertArrayEquals(expected, script); }