本文整理汇总了Java中org.bitcoinj.script.Script.getProgram方法的典型用法代码示例。如果您正苦于以下问题:Java Script.getProgram方法的具体用法?Java Script.getProgram怎么用?Java Script.getProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.script.Script
的用法示例。
在下文中一共展示了Script.getProgram方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: produceScript
import org.bitcoinj.script.Script; //导入方法依赖的package包/类
public static Script produceScript (byte[] template, byte[]... parameters) {
try {
ScriptBuilder builder = new ScriptBuilder();
int parameter = 0;
for (byte chunk : template) {
int op = chunk;
if (op < 0) {
op = op + 256;
}
if (op == 255) {
builder.data(parameters[parameter]);
parameter++;
} else if (op == 0) {
builder.data(new byte[0]);
} else {
builder.op(op);
}
}
//Bug in bitcoinJ when dealing with OP_0. Gets solved by reserializing.
Script s = builder.build();
return new Script(s.getProgram());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例2: getMultisigInputScript
import org.bitcoinj.script.Script; //导入方法依赖的package包/类
public static Script getMultisigInputScript (ECDSASignature client, ECDSASignature server) {
ArrayList<TransactionSignature> signList = new ArrayList<TransactionSignature>();
signList.add(new TransactionSignature(client, SigHash.ALL, false));
signList.add(new TransactionSignature(server, SigHash.ALL, false));
Script inputScript = ScriptBuilder.createMultiSigInputScript(signList);
/*
* Seems there is a bug here,
* https://groups.google.com/forum/#!topic/bitcoinj/A9R8TdUsXms
*/
Script workaround = new Script(inputScript.getProgram());
return workaround;
}