• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ScriptChunk类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.bitcoin.script.ScriptChunk的典型用法代码示例。如果您正苦于以下问题:Java ScriptChunk类的具体用法?Java ScriptChunk怎么用?Java ScriptChunk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScriptChunk类属于com.google.bitcoin.script包,在下文中一共展示了ScriptChunk类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: computeSecret

import com.google.bitcoin.script.ScriptChunk; //导入依赖的package包/类
protected void computeSecret() throws VerificationException {
	for (TransactionInput input : tx.getInputs()) {
		List<ScriptChunk> chunks = input.getScriptSig().getChunks();
		if (chunks.size() == 5) {
			byte[] data = chunks.get(SECRET_POSITION).data;
			if (hash != null) {
				if (Arrays.equals(hash, LotteryUtils.calcDoubleHash(data))) {
					possibleSecrets.add(data);
					return;
				}
			}
			else {
				possibleSecrets.add(data);
			}
		}
	}
	
	if (possibleSecrets.size() == 0) {
		throw new VerificationException("Not an Open transaction.");
	}
}
 
开发者ID:lukmaz,项目名称:BitcoinLottery,代码行数:22,代码来源:OpenTx.java


示例2: getBloomFilter

import com.google.bitcoin.script.ScriptChunk; //导入依赖的package包/类
/**
 * Gets a bloom filter that contains all of the public keys from this wallet,
 * and which will provide the given false-positive rate if it has size elements.
 * Keep in mind that you will get 2 elements in the bloom filter for each key in the wallet.
 * 
 * This is used to generate a BloomFilter which can be #{link BloomFilter.merge}d with another.
 * It could also be used if you have a specific target for the filter's size.
 * 
 * See the docs for {@link BloomFilter(int, double)} for a brief explanation of anonymity when using bloom filters.
 */
@Override
public BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak) {
    BloomFilter filter = new BloomFilter(size, falsePositiveRate, nTweak);
    lock.lock();
    try {
        for (ECKey key : keychain) {
            filter.insert(key.getPubKey());
            filter.insert(key.getPubKeyHash());
        }

        for (Script script : watchedScripts) {
            for (ScriptChunk chunk : script.getChunks()) {
                // Only add long (at least 64 bit) data to the bloom filter.
                // If any long constants become popular in scripts, we will need logic
                // here to exclude them.
                if (!chunk.isOpCode() && chunk.data.length >= MINIMUM_BLOOM_DATA_LENGTH) {
                    filter.insert(chunk.data);
                }
            }
        }
    } finally {
        lock.unlock();
    }
    for (Transaction tx : getTransactions(false)) {
        for (int i = 0; i < tx.getOutputs().size(); i++) {
            TransactionOutput out = tx.getOutputs().get(i);
            try {
                if (isTxOutputBloomFilterable(out)) {
                    TransactionOutPoint outPoint = new TransactionOutPoint(params, i, tx);
                    filter.insert(outPoint.bitcoinSerialize());
                }
            } catch (ScriptException e) {
                throw new RuntimeException(e); // If it is ours, we parsed the script correctly, so this shouldn't happen
            }
        }
    }

    return filter;
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:50,代码来源:Wallet.java


示例3: computeSecretsHashes

import com.google.bitcoin.script.ScriptChunk; //导入依赖的package包/类
protected void computeSecretsHashes() throws VerificationException {
	Script outScript = tx.getOutput(0).getScriptPubKey();
	hashes = new ArrayList<byte[]>();
	List<ScriptChunk> chunks = outScript.getChunks();
	ListIterator<ScriptChunk> it = chunks.listIterator();
	while(it.hasNext()) {
		if (it.next().equalsOpCode(BitcoinLotterySettings.hashFunctionOpCode)) {
			hashes.add(it.next().data);
		}
	}
	Collections.reverse(hashes);
	if (hashes.size() != noPlayers) {
		throw new VerificationException("Wrong out script.");
	}
}
 
开发者ID:lukmaz,项目名称:BitcoinLottery,代码行数:16,代码来源:ComputeTx.java


示例4: computeMinLength

import com.google.bitcoin.script.ScriptChunk; //导入依赖的package包/类
protected void computeMinLength() throws VerificationException {
	Script outScript = tx.getOutput(0).getScriptPubKey();
	List<ScriptChunk> chunks = outScript.getChunks();
	ListIterator<ScriptChunk> it = chunks.listIterator();
	while(it.hasNext()) {
		if (it.next().equalsOpCode(ScriptOpCodes.OP_SIZE)) {
			minLength = Integer.parseInt(Utils.bytesToHexString(it.next().data), 16);
			return;
		}
	}
	throw new VerificationException("Wrong out script.");
}
 
开发者ID:lukmaz,项目名称:BitcoinLottery,代码行数:13,代码来源:ComputeTx.java


示例5: computeInScript

import com.google.bitcoin.script.ScriptChunk; //导入依赖的package包/类
protected void computeInScript(ECKey sk) throws ScriptException {
	List<ScriptChunk> chunks = tx.getInput(0).getScriptSig().getChunks();
  byte[] sig = sign(0, sk).encodeToBitcoin();
	ScriptBuilder sb = new ScriptBuilder()
								.data(chunks.get(0).data)
								.data(chunks.get(1).data)
								.data(sig)
								.data(sk.getPubKey())
								.data(sig);  // dummy secret
	tx.getInput(0).setScriptSig(sb.build());
}
 
开发者ID:lukmaz,项目名称:BitcoinLottery,代码行数:12,代码来源:PayDepositTx.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RowStyles类代码示例发布时间:2022-05-22
下一篇:
Java CGLGraphicsConfig类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap