Package com.google.bitcoin.script

Examples of com.google.bitcoin.script.Script


    }

    public RuleList getBlocksToTest(boolean addSigExpensiveBlocks, boolean runLargeReorgs, File blockStorageFile) throws ScriptException, ProtocolException, IOException {
        final FileOutputStream outStream = blockStorageFile != null ? new FileOutputStream(blockStorageFile) : null;

        final Script OP_TRUE_SCRIPT = new ScriptBuilder().op(OP_TRUE).build();
        final Script OP_NOP_SCRIPT = new ScriptBuilder().op(OP_NOP).build();

        // TODO: Rename this variable.
        List<Rule> blocks = new LinkedList<Rule>() {
            @Override
            public boolean add(Rule element) {
View Full Code Here


        for (TransactionInput input : tx.getInputs()) {
            JSONObject inputData = new JSONObject();

            if (!input.isCoinBase()) {
                try {
                    Script scriptSig = input.getScriptSig();
                    Address fromAddress = new Address(networkParams, Utils.sha256hash160(scriptSig.getPubKey()));
                    inputData.put("address", fromAddress);
                } catch (ScriptException e) {
                    // can't parse script, give up
                }
            }

            TransactionOutput source = input.getConnectedOutput();
            if (source != null) {
                inputData.put("amount", source.getValue());
            }

            inputs.put(inputData);
        }

        JSONArray outputs = new JSONArray();

        for (TransactionOutput output : tx.getOutputs()) {
            JSONObject outputData = new JSONObject();

            try {
                Script scriptPubKey = output.getScriptPubKey();

                if (scriptPubKey.isSentToAddress() || scriptPubKey.isPayToScriptHash()) {
                    Address toAddress = scriptPubKey.getToAddress(networkParams);
                    outputData.put("address", toAddress);

                    if (toAddress.toString().equals(getWalletAddress())) {
                        outputData.put("type", "own");
                    } else {
                        outputData.put("type", "external");
                    }
                } else if (scriptPubKey.isSentToRawPubKey()) {
                    outputData.put("type", "pubkey");
                } else if (scriptPubKey.isSentToMultiSig()) {
                    outputData.put("type", "multisig");
                } else {
                    outputData.put("type", "unknown");
                }
            } catch (ScriptException e) {
View Full Code Here

TOP

Related Classes of com.google.bitcoin.script.Script

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.