本文整理汇总了Java中org.bitcoinj.script.Script.VerifyFlag类的典型用法代码示例。如果您正苦于以下问题:Java VerifyFlag类的具体用法?Java VerifyFlag怎么用?Java VerifyFlag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VerifyFlag类属于org.bitcoinj.script.Script包,在下文中一共展示了VerifyFlag类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dataDrivenValidScripts
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
@Test
public void dataDrivenValidScripts() throws Exception {
JsonNode json = new ObjectMapper().readTree(new InputStreamReader(getClass().getResourceAsStream(
"script_valid.json"), Charsets.UTF_8));
for (JsonNode test : json) {
Script scriptSig = parseScriptString(test.get(0).asText());
Script scriptPubKey = parseScriptString(test.get(1).asText());
Set<VerifyFlag> verifyFlags = parseVerifyFlags(test.get(2).asText());
try {
scriptSig.correctlySpends(new Transaction(PARAMS), 0, scriptPubKey, verifyFlags);
} catch (ScriptException e) {
System.err.println(test);
System.err.flush();
throw e;
}
}
}
示例2: dataDrivenInvalidScripts
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
@Test
public void dataDrivenInvalidScripts() throws Exception {
JsonNode json = new ObjectMapper().readTree(new InputStreamReader(getClass().getResourceAsStream(
"script_invalid.json"), Charsets.UTF_8));
for (JsonNode test : json) {
try {
Script scriptSig = parseScriptString(test.get(0).asText());
Script scriptPubKey = parseScriptString(test.get(1).asText());
Set<VerifyFlag> verifyFlags = parseVerifyFlags(test.get(2).asText());
scriptSig.correctlySpends(new Transaction(PARAMS), 0, scriptPubKey, verifyFlags);
System.err.println(test);
System.err.flush();
fail();
} catch (VerificationException e) {
// Expected.
}
}
}
示例3: dataDrivenValidScripts
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
@Test
public void dataDrivenValidScripts() throws Exception {
JsonNode json = new ObjectMapper().readTree(new InputStreamReader(getClass().getResourceAsStream(
"script_valid.json"), Charsets.UTF_8));
for (JsonNode test : json) {
Script scriptSig = parseScriptString(test.get(0).asText());
Script scriptPubKey = parseScriptString(test.get(1).asText());
Set<VerifyFlag> verifyFlags = parseVerifyFlags(test.get(2).asText());
try {
scriptSig.correctlySpends(new Transaction(params), 0, scriptPubKey, verifyFlags);
} catch (ScriptException e) {
System.err.println(test);
System.err.flush();
throw e;
}
}
}
示例4: dataDrivenInvalidScripts
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
@Test
public void dataDrivenInvalidScripts() throws Exception {
JsonNode json = new ObjectMapper().readTree(new InputStreamReader(getClass().getResourceAsStream(
"script_invalid.json"), Charsets.UTF_8));
for (JsonNode test : json) {
try {
Script scriptSig = parseScriptString(test.get(0).asText());
Script scriptPubKey = parseScriptString(test.get(1).asText());
Set<VerifyFlag> verifyFlags = parseVerifyFlags(test.get(2).asText());
scriptSig.correctlySpends(new Transaction(params), 0, scriptPubKey, verifyFlags);
System.err.println(test);
System.err.flush();
fail();
} catch (VerificationException e) {
// Expected.
}
}
}
示例5: parseVerifyFlags
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
private Set<VerifyFlag> parseVerifyFlags(String str) {
Set<VerifyFlag> flags = EnumSet.noneOf(VerifyFlag.class);
if (!"NONE".equals(str)) {
for (String flag : str.split(",")) {
try {
flags.add(VerifyFlag.valueOf(flag));
} catch (IllegalArgumentException x) {
log.debug("Cannot handle verify flag {} -- ignored.", flag);
}
}
}
return flags;
}
示例6: dataDrivenValidTransactions
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
@Test
public void dataDrivenValidTransactions() throws Exception {
JsonNode json = new ObjectMapper().readTree(new InputStreamReader(getClass().getResourceAsStream(
"tx_valid.json"), Charsets.UTF_8));
for (JsonNode test : json) {
if (test.isArray() && test.size() == 1 && test.get(0).isTextual())
continue; // This is a comment.
Transaction transaction = null;
try {
Map<TransactionOutPoint, Script> scriptPubKeys = parseScriptPubKeys(test.get(0));
transaction = PARAMS.getDefaultSerializer().makeTransaction(HEX.decode(test.get(1).asText().toLowerCase()));
transaction.verify();
Set<VerifyFlag> verifyFlags = parseVerifyFlags(test.get(2).asText());
for (int i = 0; i < transaction.getInputs().size(); i++) {
TransactionInput input = transaction.getInputs().get(i);
if (input.getOutpoint().getIndex() == 0xffffffffL)
input.getOutpoint().setIndex(-1);
assertTrue(scriptPubKeys.containsKey(input.getOutpoint()));
input.getScriptSig().correctlySpends(transaction, i, scriptPubKeys.get(input.getOutpoint()),
verifyFlags);
}
} catch (Exception e) {
System.err.println(test);
if (transaction != null)
System.err.println(transaction);
throw e;
}
}
}
示例7: dataDrivenValidTransactions
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
@Test
public void dataDrivenValidTransactions() throws Exception {
JsonNode json = new ObjectMapper().readTree(new InputStreamReader(getClass().getResourceAsStream(
"tx_valid.json"), Charsets.UTF_8));
for (JsonNode test : json) {
if (test.isArray() && test.size() == 1 && test.get(0).isTextual())
continue; // This is a comment.
Transaction transaction = null;
try {
Map<TransactionOutPoint, Script> scriptPubKeys = parseScriptPubKeys(test.get(0));
transaction = new Transaction(params, HEX.decode(test.get(1).asText().toLowerCase()));
transaction.verify();
Set<VerifyFlag> verifyFlags = parseVerifyFlags(test.get(2).asText());
for (int i = 0; i < transaction.getInputs().size(); i++) {
TransactionInput input = transaction.getInputs().get(i);
if (input.getOutpoint().getIndex() == 0xffffffffL)
input.getOutpoint().setIndex(-1);
assertTrue(scriptPubKeys.containsKey(input.getOutpoint()));
input.getScriptSig().correctlySpends(transaction, i, scriptPubKeys.get(input.getOutpoint()),
verifyFlags);
}
} catch (Exception e) {
System.err.println(test);
if (transaction != null)
System.err.println(transaction);
throw e;
}
}
}
示例8: dataDrivenScripts
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
@Test
public void dataDrivenScripts() throws Exception {
JsonNode json = new ObjectMapper()
.readTree(new InputStreamReader(getClass().getResourceAsStream("script_tests.json"), Charsets.UTF_8));
for (JsonNode test : json) {
if (test.size() == 1)
continue; // skip comment
Set<VerifyFlag> verifyFlags = parseVerifyFlags(test.get(2).asText());
ScriptError expectedError = ScriptError.fromMnemonic(test.get(3).asText());
try {
Script scriptSig = parseScriptString(test.get(0).asText());
Script scriptPubKey = parseScriptString(test.get(1).asText());
Transaction txCredit = buildCreditingTransaction(scriptPubKey);
Transaction txSpend = buildSpendingTransaction(txCredit, scriptSig);
scriptSig.correctlySpends(txSpend, 0, scriptPubKey, verifyFlags);
if (!expectedError.equals(ScriptError.SCRIPT_ERR_OK))
fail(test + " is expected to fail");
} catch (ScriptException e) {
if (!e.getError().equals(expectedError)) {
System.err.println(test);
e.printStackTrace();
System.err.flush();
throw e;
}
}
}
}
示例9: Verifier
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
public Verifier(final Transaction tx, final List<Script> prevOutScripts, final Set<VerifyFlag> verifyFlags) {
this.tx = tx;
this.prevOutScripts = prevOutScripts;
this.verifyFlags = verifyFlags;
}
示例10: Verifier
import org.bitcoinj.script.Script.VerifyFlag; //导入依赖的package包/类
public Verifier(final Transaction tx, final List<Script> prevOutScripts, final Set<VerifyFlag> verifyFlags) {
this.tx = tx; this.prevOutScripts = prevOutScripts; this.verifyFlags = verifyFlags;
}