mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-01 21:17:13 +00:00
Implement some missed Bloom filter application logic (does not impact existing apps).
This commit is contained in:
@@ -961,6 +961,7 @@ public class Block extends Message {
|
|||||||
static private int txCounter;
|
static private int txCounter;
|
||||||
|
|
||||||
/** Adds a coinbase transaction to the block. This exists for unit tests. */
|
/** Adds a coinbase transaction to the block. This exists for unit tests. */
|
||||||
|
@VisibleForTesting
|
||||||
void addCoinbaseTransaction(byte[] pubKeyTo, Coin value) {
|
void addCoinbaseTransaction(byte[] pubKeyTo, Coin value) {
|
||||||
unCacheTransactions();
|
unCacheTransactions();
|
||||||
transactions = new ArrayList<Transaction>();
|
transactions = new ArrayList<Transaction>();
|
||||||
@@ -970,7 +971,8 @@ public class Block extends Message {
|
|||||||
//
|
//
|
||||||
// Here we will do things a bit differently so a new address isn't needed every time. We'll put a simple
|
// Here we will do things a bit differently so a new address isn't needed every time. We'll put a simple
|
||||||
// counter in the scriptSig so every transaction has a different hash.
|
// counter in the scriptSig so every transaction has a different hash.
|
||||||
coinbase.addInput(new TransactionInput(params, coinbase, new byte[]{(byte) txCounter, (byte) (txCounter++ >> 8)}));
|
coinbase.addInput(new TransactionInput(params, coinbase,
|
||||||
|
new ScriptBuilder().data(new byte[]{(byte) txCounter, (byte) (txCounter++ >> 8)}).build().getProgram()));
|
||||||
coinbase.addOutput(new TransactionOutput(params, coinbase, value,
|
coinbase.addOutput(new TransactionOutput(params, coinbase, value,
|
||||||
ScriptBuilder.createOutputScript(ECKey.fromPublicOnly(pubKeyTo)).getProgram()));
|
ScriptBuilder.createOutputScript(ECKey.fromPublicOnly(pubKeyTo)).getProgram()));
|
||||||
transactions.add(coinbase);
|
transactions.add(coinbase);
|
||||||
|
|||||||
@@ -339,7 +339,17 @@ public class BloomFilter extends Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return found;
|
if (found) return true;
|
||||||
|
for (TransactionInput input : tx.getInputs()) {
|
||||||
|
if (contains(input.getOutpoint().bitcoinSerialize())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (ScriptChunk chunk : input.getScriptSig().getChunks()) {
|
||||||
|
if (chunk.isPushData() && contains(chunk.data))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package org.bitcoinj.testing;
|
package org.bitcoinj.testing;
|
||||||
|
|
||||||
import org.bitcoinj.core.*;
|
import org.bitcoinj.core.*;
|
||||||
|
import org.bitcoinj.crypto.TransactionSignature;
|
||||||
|
import org.bitcoinj.script.ScriptBuilder;
|
||||||
import org.bitcoinj.store.BlockStore;
|
import org.bitcoinj.store.BlockStore;
|
||||||
import org.bitcoinj.store.BlockStoreException;
|
import org.bitcoinj.store.BlockStoreException;
|
||||||
|
|
||||||
@@ -43,7 +45,8 @@ public class FakeTxBuilder {
|
|||||||
TransactionOutput prevOut = new TransactionOutput(params, prevTx, value, to);
|
TransactionOutput prevOut = new TransactionOutput(params, prevTx, value, to);
|
||||||
prevTx.addOutput(prevOut);
|
prevTx.addOutput(prevOut);
|
||||||
// Connect it.
|
// Connect it.
|
||||||
t.addInput(prevOut);
|
t.addInput(prevOut).setScriptSig(ScriptBuilder.createInputScript(TransactionSignature.dummy()));
|
||||||
|
// Fake signature.
|
||||||
// Serialize/deserialize to ensure internal state is stripped, as if it had been read from the wire.
|
// Serialize/deserialize to ensure internal state is stripped, as if it had been read from the wire.
|
||||||
return roundTripTransaction(params, t);
|
return roundTripTransaction(params, t);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user