当前位置: 首页>>代码示例>>Java>>正文


Java VerifyFlag类代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:18,代码来源:ScriptTest.java

示例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.
        }
    }
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:19,代码来源:ScriptTest.java

示例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;
        }
    }
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:18,代码来源:ScriptTest.java

示例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.
        }
    }
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:19,代码来源:ScriptTest.java

示例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;
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:14,代码来源:ScriptTest.java

示例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;
        }
    }
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:31,代码来源:ScriptTest.java

示例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;
        }
    }
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:31,代码来源:ScriptTest.java

示例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;
            }
        }
    }
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:28,代码来源:ScriptTest.java

示例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;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:6,代码来源:FullPrunedBlockChain.java

示例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;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:4,代码来源:FullPrunedBlockChain.java


注:本文中的org.bitcoinj.script.Script.VerifyFlag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。