Java Code Examples for org.bitcoinj.script.ScriptChunk#isPushData()
The following examples show how to use
org.bitcoinj.script.ScriptChunk#isPushData() .
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: DefaultRiskAnalysis.java From bcm-android with GNU General Public License v3.0 | 6 votes |
/** * Checks if the given input passes some of the AreInputsStandard checks. Not complete. */ public static RuleViolation isInputStandard(TransactionInput input) { for (ScriptChunk chunk : input.getScriptSig().getChunks()) { if (chunk.data != null && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; if (chunk.isPushData()) { ECDSASignature signature; try { signature = ECKey.ECDSASignature.decodeFromDER(chunk.data); } catch (IllegalArgumentException x) { // Doesn't look like a signature. signature = null; } if (signature != null) { if (!TransactionSignature.isEncodingCanonical(chunk.data)) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; if (!signature.isCanonical()) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; } } } return RuleViolation.NONE; }
Example 2
Source File: BisqRiskAnalysis.java From bisq-core with GNU Affero General Public License v3.0 | 6 votes |
/** Checks if the given input passes some of the AreInputsStandard checks. Not complete. */ public static RuleViolation isInputStandard(TransactionInput input) { for (ScriptChunk chunk : input.getScriptSig().getChunks()) { if (chunk.data != null && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; if (chunk.isPushData()) { ECDSASignature signature; try { signature = ECKey.ECDSASignature.decodeFromDER(chunk.data); } catch (RuntimeException x) { // Doesn't look like a signature. signature = null; } if (signature != null) { if (!TransactionSignature.isEncodingCanonical(chunk.data)) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; if (!signature.isCanonical()) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; } } } return RuleViolation.NONE; }
Example 3
Source File: DefaultRiskAnalysis.java From green_android with GNU General Public License v3.0 | 6 votes |
/** Checks if the given input passes some of the AreInputsStandard checks. Not complete. */ public static RuleViolation isInputStandard(TransactionInput input) { for (ScriptChunk chunk : input.getScriptSig().getChunks()) { if (chunk.data != null && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; if (chunk.isPushData()) { ECDSASignature signature; try { signature = ECKey.ECDSASignature.decodeFromDER(chunk.data); } catch (RuntimeException x) { // Doesn't look like a signature. signature = null; } if (signature != null) { if (!TransactionSignature.isEncodingCanonical(chunk.data)) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; if (!signature.isCanonical()) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; } } } return RuleViolation.NONE; }
Example 4
Source File: DefaultRiskAnalysis.java From GreenBits with GNU General Public License v3.0 | 6 votes |
/** Checks if the given input passes some of the AreInputsStandard checks. Not complete. */ public static RuleViolation isInputStandard(TransactionInput input) { for (ScriptChunk chunk : input.getScriptSig().getChunks()) { if (chunk.data != null && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; if (chunk.isPushData()) { ECDSASignature signature; try { signature = ECKey.ECDSASignature.decodeFromDER(chunk.data); } catch (RuntimeException x) { // Doesn't look like a signature. signature = null; } if (signature != null) { if (!TransactionSignature.isEncodingCanonical(chunk.data)) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; if (!signature.isCanonical()) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; } } } return RuleViolation.NONE; }
Example 5
Source File: BisqRiskAnalysis.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
/** Checks if the given input passes some of the AreInputsStandard checks. Not complete. */ public static RuleViolation isInputStandard(TransactionInput input) { for (ScriptChunk chunk : input.getScriptSig().getChunks()) { if (chunk.data != null && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; if (chunk.isPushData()) { ECDSASignature signature; try { signature = ECKey.ECDSASignature.decodeFromDER(chunk.data); } catch (RuntimeException x) { // Doesn't look like a signature. signature = null; } if (signature != null) { if (!TransactionSignature.isEncodingCanonical(chunk.data)) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; if (!signature.isCanonical()) return RuleViolation.SIGNATURE_CANONICAL_ENCODING; } } } return RuleViolation.NONE; }
Example 6
Source File: DefaultRiskAnalysis.java From bcm-android with GNU General Public License v3.0 | 5 votes |
/** * Checks the output to see if the script violates a standardness rule. Not complete. */ public static RuleViolation isOutputStandard(TransactionOutput output) { if (output.getValue().compareTo(MIN_ANALYSIS_NONDUST_OUTPUT) < 0) return RuleViolation.DUST; for (ScriptChunk chunk : output.getScriptPubKey().getChunks()) { if (chunk.isPushData() && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; } return RuleViolation.NONE; }
Example 7
Source File: BisqRiskAnalysis.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
/** * Checks the output to see if the script violates a standardness rule. Not complete. */ public static RuleViolation isOutputStandard(TransactionOutput output) { // OP_RETURN has usually output value zero, so we exclude that from the MIN_ANALYSIS_NONDUST_OUTPUT check if (!output.getScriptPubKey().isOpReturn() && output.getValue().compareTo(MIN_ANALYSIS_NONDUST_OUTPUT) < 0) return RuleViolation.DUST; for (ScriptChunk chunk : output.getScriptPubKey().getChunks()) { if (chunk.isPushData() && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; } return RuleViolation.NONE; }
Example 8
Source File: DefaultRiskAnalysis.java From green_android with GNU General Public License v3.0 | 5 votes |
/** * Checks the output to see if the script violates a standardness rule. Not complete. */ public static RuleViolation isOutputStandard(TransactionOutput output) { if (output.getValue().compareTo(MIN_ANALYSIS_NONDUST_OUTPUT) < 0) return RuleViolation.DUST; for (ScriptChunk chunk : output.getScriptPubKey().getChunks()) { if (chunk.isPushData() && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; } return RuleViolation.NONE; }
Example 9
Source File: ScriptTools.java From thunder with GNU Affero General Public License v3.0 | 5 votes |
public static boolean testScript (byte[] script, byte[] template, byte[]... parameters) { Script s = new Script(script); List<ScriptChunk> chunks = s.getChunks(); int parameter = 0; for (int i = 0; i < chunks.size(); i++) { boolean correct = false; ScriptChunk chunk = chunks.get(i); byte templateChunk = template[i]; int op = templateChunk; if (op < 0) { op = op + 256; } if (op == 255) { if (chunk.isPushData()) { if (Arrays.equals(chunk.data, parameters[parameter])) { parameter++; correct = true; } } } else { if (chunk.opcode == op) { correct = true; } } if (!correct) { return false; } } return true; }
Example 10
Source File: DefaultRiskAnalysis.java From GreenBits with GNU General Public License v3.0 | 5 votes |
/** * Checks the output to see if the script violates a standardness rule. Not complete. */ public static RuleViolation isOutputStandard(TransactionOutput output) { if (output.getValue().compareTo(MIN_ANALYSIS_NONDUST_OUTPUT) < 0) return RuleViolation.DUST; for (ScriptChunk chunk : output.getScriptPubKey().getChunks()) { if (chunk.isPushData() && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; } return RuleViolation.NONE; }
Example 11
Source File: ScriptTools.java From thundernetwork with GNU Affero General Public License v3.0 | 5 votes |
public static boolean testScript (byte[] script, byte[] template, byte[]... parameters) { Script s = new Script(script); List<ScriptChunk> chunks = s.getChunks(); int parameter = 0; for (int i = 0; i < chunks.size(); i++) { boolean correct = false; ScriptChunk chunk = chunks.get(i); byte templateChunk = template[i]; int op = templateChunk; if (op < 0) { op = op + 256; } if (op == 255) { if (chunk.isPushData()) { if (Arrays.equals(chunk.data, parameters[parameter])) { parameter++; correct = true; } } } else { if (chunk.opcode == op) { correct = true; } } if (!correct) { return false; } } return true; }
Example 12
Source File: BisqRiskAnalysis.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
/** * Checks the output to see if the script violates a standardness rule. Not complete. */ public static RuleViolation isOutputStandard(TransactionOutput output) { // OP_RETURN has usually output value zero, so we exclude that from the MIN_ANALYSIS_NONDUST_OUTPUT check if (!output.getScriptPubKey().isOpReturn() && output.getValue().compareTo(MIN_ANALYSIS_NONDUST_OUTPUT) < 0) return RuleViolation.DUST; for (ScriptChunk chunk : output.getScriptPubKey().getChunks()) { if (chunk.isPushData() && !chunk.isShortestPossiblePushData()) return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA; } return RuleViolation.NONE; }
Example 13
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 14
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 15
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;} }