Java Code Examples for org.bitcoinj.core.TransactionOutput#getScriptPubKey()
The following examples show how to use
org.bitcoinj.core.TransactionOutput#getScriptPubKey() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UtxoTrieMgr.java From jelectrum with MIT License | 5 votes |
public static byte[] getPublicKeyForTxOut(TransactionOutput out, NetworkParameters params) { byte[] public_key=null; Script script = null; try { script = out.getScriptPubKey(); if (script.isSentToRawPubKey()) { byte[] key = out.getScriptPubKey().getPubKey(); byte[] address_bytes = org.bitcoinj.core.Utils.sha256hash160(key); public_key = address_bytes; } else { Address a = script.getToAddress(params); public_key = a.getHash160(); } } catch(ScriptException e) { public_key = figureOutStrange(script, out, params); } return public_key; }
Example 2
Source File: DumpTxList.java From jelectrum with MIT License | 4 votes |
public static void main(String args[]) throws Exception { Jelectrum jelly = new Jelectrum(new Config(args[0])); Scanner scan = new Scanner(new FileInputStream(args[1])); PrintStream pout = new PrintStream(new FileOutputStream(args[2], false)); TXUtil txutil = new TXUtil(jelly.getDB(), jelly.getNetworkParameters()); while(scan.hasNext()) { String hash = scan.next(); Transaction tx = jelly.getDB().getTransaction(new Sha256Hash(hash)).getTx(jelly.getNetworkParameters()); int in_idx =0; for(TransactionInput in : tx.getInputs()) { Address addr = in.getFromAddress(); byte[] h160 = addr.getHash160(); pout.println("txin:" + hash + ":" + in_idx + ":" + Hex.encodeHexString(h160)); in_idx++; /*System.out.println("Input: " + in); Script script = in.getScriptSig(); for(ScriptChunk chunk : script.getChunks()) { if (chunk.isOpCode()) { System.out.println(" op " + chunk.opcode); } if (chunk.isPushData() && (chunk.data != null)) { System.out.println(" data " + chunk.data.length); } }*/ } pout.println("tx:" + hash + ":" + txutil.getTXBlockHeight(tx, jelly.getBlockChainCache())); for(TransactionOutput out : tx.getOutputs()) { int idx = out.getIndex(); Script script = out.getScriptPubKey(); for(ScriptChunk chunk : script.getChunks()) { if (chunk.isOpCode()) { //System.out.println(" op " + chunk.opcode); } if (chunk.isPushData() && (chunk.data != null)) { pout.println("txout:" + hash + ":" + idx + ":" + Hex.encodeHexString(chunk.data)); } } } } pout.flush(); pout.close(); }
Example 3
Source File: DumpTxList.java From jelectrum with MIT License | 4 votes |
public static boolean hasStrangeData(Transaction tx) { try { boolean hasStrange = false; /*for(TransactionInput in : tx.getInputs()) { Script script = in.getScriptSig(); int data_in = 0; for(ScriptChunk chunk : script.getChunks()) { if (chunk.isOpCode()) { } if (chunk.isPushData() && (chunk.data != null)) { data_in += chunk.data.length; } } if (data_in > 20) return true; }*/ int extra_data = 0; for(TransactionOutput out : tx.getOutputs()) { int data_out = 0; Script script = out.getScriptPubKey(); for(ScriptChunk chunk : script.getChunks()) { if (chunk.isOpCode()) { } if (chunk.isPushData() && (chunk.data != null)) { data_out += chunk.data.length; } } if (data_out > 20) extra_data += data_out; } if (extra_data > 20) return true; return false; } catch(Throwable t){return true;} }
Example 4
Source File: DumpTx.java From jelectrum with MIT License | 4 votes |
public static boolean hasStrangeData(Transaction tx) { try { boolean hasStrange = false; /*for(TransactionInput in : tx.getInputs()) { Script script = in.getScriptSig(); int data_in = 0; for(ScriptChunk chunk : script.getChunks()) { if (chunk.isOpCode()) { } if (chunk.isPushData() && (chunk.data != null)) { data_in += chunk.data.length; } } if (data_in > 20) return true; }*/ int extra_data = 0; for(TransactionOutput out : tx.getOutputs()) { int data_out = 0; Script script = out.getScriptPubKey(); for(ScriptChunk chunk : script.getChunks()) { if (chunk.isOpCode()) { } if (chunk.isPushData() && (chunk.data != null)) { data_out += chunk.data.length; } } if (data_out > 20) extra_data += data_out; } if (extra_data > 20) return true; return false; } catch(Throwable t){return true;} }