本文整理汇总了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;未经允许,请勿转载。 |
请发表评论