本文整理汇总了Java中org.bitcoinj.script.ScriptChunk.isPushData方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptChunk.isPushData方法的具体用法?Java ScriptChunk.isPushData怎么用?Java ScriptChunk.isPushData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.script.ScriptChunk
的用法示例。
在下文中一共展示了ScriptChunk.isPushData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInputStandard
import org.bitcoinj.script.ScriptChunk; //导入方法依赖的package包/类
/** 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;
}
示例2: isInputStandard
import org.bitcoinj.script.ScriptChunk; //导入方法依赖的package包/类
/** 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;
}
示例3: applyAndUpdate
import org.bitcoinj.script.ScriptChunk; //导入方法依赖的package包/类
public synchronized boolean applyAndUpdate(Transaction tx) {
if (contains(tx.getHash().getBytes()))
return true;
boolean found = false;
BloomUpdate flag = getUpdateFlag();
for (TransactionOutput output : tx.getOutputs()) {
Script script = output.getScriptPubKey();
for (ScriptChunk chunk : script.getChunks()) {
if (!chunk.isPushData())
continue;
if (contains(chunk.data)) {
boolean isSendingToPubKeys = script.isSentToRawPubKey() || script.isSentToMultiSig();
if (flag == BloomUpdate.UPDATE_ALL || (flag == BloomUpdate.UPDATE_P2PUBKEY_ONLY && isSendingToPubKeys))
insert(output.getOutPointFor().bitcoinSerialize());
found = true;
}
}
}
return found;
}
示例4: isOutputStandard
import org.bitcoinj.script.ScriptChunk; //导入方法依赖的package包/类
/**
* 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;
}
示例5: testScript
import org.bitcoinj.script.ScriptChunk; //导入方法依赖的package包/类
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;
}
示例6: isOutputStandard
import org.bitcoinj.script.ScriptChunk; //导入方法依赖的package包/类
/**
* Checks the output to see if the script violates a standardness rule. Not complete.
*/
public static RuleViolation isOutputStandard(TransactionOutput output) {
if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0)
return RuleViolation.DUST;
for (ScriptChunk chunk : output.getScriptPubKey().getChunks()) {
if (chunk.isPushData() && !chunk.isShortestPossiblePushData())
return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
}
return RuleViolation.NONE;
}
示例7: main
import org.bitcoinj.script.ScriptChunk; //导入方法依赖的package包/类
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();
}
示例8: hasStrangeData
import org.bitcoinj.script.ScriptChunk; //导入方法依赖的package包/类
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;}
}