Skip to content

Commit

Permalink
Merge tag 'v0.16.3' of https://github.com/bitcoinj/bitcoinj into rele…
Browse files Browse the repository at this point in the history
…ase-0.16

0.16.3 release
  • Loading branch information
HashEngineering committed Aug 18, 2024
2 parents bfb9c5e + 2f882bc commit 4f52a66
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 27 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
name: JAVA ${{ matrix.distribution }} ${{ matrix.java }} OS ${{ matrix.os }} Gradle ${{ matrix.gradle }}
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }}
Expand All @@ -36,15 +36,15 @@ jobs:
cmake --build .
cd ../../..
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
with:
gradle-version: ${{ matrix.gradle }}
arguments: build --stacktrace
- name: Upload Test Results and Reports
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: groestlcoinj-core-test-results-jdk${{ matrix.java }}-${{ matrix.os }}
name: groestlcoinj-core-test-results-jdk${{ matrix.java }}-${{ matrix.os }}-${{ matrix.gradle }}
path: |
core/build/reports/tests/test/
core/build/test-results/test/
11 changes: 6 additions & 5 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ plugins {
id 'signing'
}

version = '0.16.2'
version = '0.16.3'

dependencies {
api 'org.bouncycastle:bcprov-jdk15to18:1.69'
api 'org.bouncycastle:bcprov-jdk15to18:1.73'
api 'com.google.guava:guava:31.0.1-android'
api 'com.google.protobuf:protobuf-javalite:3.18.0'
api 'com.squareup.okhttp3:okhttp:3.14.9'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'org.slf4j:slf4j-api:1.7.36'
implementation 'net.jcip:jcip-annotations:1.0'
compileOnly 'org.fusesource.leveldbjni:leveldbjni-all:1.8'
testImplementation 'junit:junit:4.13.2'
implementation 'de.sfuhrm:saphir-hash-core:3.0.10'
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.easymock:easymock:3.2'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.5.2'
testImplementation 'org.slf4j:slf4j-jdk14:1.7.32'
testImplementation 'org.slf4j:slf4j-jdk14:1.7.36'
testImplementation 'com.h2database:h2:1.3.167'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:2.5.2'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/bitcoinj/core/StoredBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public StoredBlock getPrev(BlockStore store) throws BlockStoreException {

/** Serializes the stored block to a custom packed format. Used by {@link CheckpointManager}. */
public void serializeCompact(ByteBuffer buffer) {
byte[] chainWorkBytes = getChainWork().toByteArray();
checkState(chainWorkBytes.length <= CHAIN_WORK_BYTES, "Ran out of space to store chain work!");
byte[] chainWorkBytes = Utils.bigIntegerToBytes(getChainWork(), CHAIN_WORK_BYTES);
if (chainWorkBytes.length < CHAIN_WORK_BYTES) {
// Pad to the right size.
buffer.put(EMPTY_BYTES, 0, CHAIN_WORK_BYTES - chainWorkBytes.length);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/bitcoinj/core/VersionMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
public class VersionMessage extends Message {

/** The version of this library release, as a string. */
public static final String BITCOINJ_VERSION = "0.16.2";
public static final String BITCOINJ_VERSION = "0.16.3";
/** The value that is prepended to the subVer field of this application. */
public static final String LIBRARY_SUBVER = "/groestlcoinj:" + BITCOINJ_VERSION + "/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void performanceTest() throws BlockStoreException {
// On slow machines, this test could fail. Then either add @Ignore or adapt the threshold and please report to
// us.
final int ITERATIONS = 100000;
final long THRESHOLD_MS = 2000;
final long THRESHOLD_MS = 5000;
SPVBlockStore store = new SPVBlockStore(UNITTEST, blockStoreFile);
Stopwatch watch = Stopwatch.createStarted();
for (int i = 0; i < ITERATIONS; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Random;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -49,7 +50,9 @@
* Utility class that makes it easy to work with mock NetworkConnections.
*/
public class TestWithNetworkConnections {
protected static final int TCP_PORT_BASE = 10000 + new Random().nextInt(40000);
public static final int PEER_SERVERS = 5;

protected static final NetworkParameters UNITTEST = UnitTestParams.get();
protected Context context;
protected BlockStore blockStore;
Expand Down Expand Up @@ -130,7 +133,7 @@ public void connectionOpened() {
}
};
}
}, new InetSocketAddress(InetAddress.getLoopbackAddress(), 2000 + i));
}, new InetSocketAddress(InetAddress.getLoopbackAddress(), TCP_PORT_BASE + i));
peerServers[i].startAsync();
peerServers[i].awaitRunning();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void run() {

protected InboundMessageQueuer connectPeerWithoutVersionExchange(int id) throws Exception {
Preconditions.checkArgument(id < PEER_SERVERS);
InetSocketAddress remoteAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 2000 + id);
InetSocketAddress remoteAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), TCP_PORT_BASE + id);
Peer peer = peerGroup.connectTo(remoteAddress).getConnectionOpenFuture().get();
InboundMessageQueuer writeTarget = newPeerWriteTargetQueue.take();
writeTarget.peer = peer;
Expand Down
12 changes: 8 additions & 4 deletions core/src/test/java/org/bitcoinj/wallet/KeyChainGroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class KeyChainGroupTest {
private static final byte[] ENTROPY = Sha256Hash.hash("don't use a string seed like this in real life".getBytes());
private static final KeyCrypterScrypt KEY_CRYPTER = new KeyCrypterScrypt(2);
private static final KeyParameter AES_KEY = KEY_CRYPTER.deriveKey("password");
private static final double LOW_FALSE_POSITIVE_RATE = 0.00001;
private KeyChainGroup group;
private DeterministicKey watchingAccountKey;

Expand Down Expand Up @@ -334,7 +335,7 @@ public void encryptionWhilstEmpty() throws Exception {
public void bloom() throws Exception {
ECKey key1 = group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
ECKey key2 = new ECKey();
BloomFilter filter = group.getBloomFilter(group.getBloomFilterElementCount(), 0.001, (long)(Math.random() * Long.MAX_VALUE));
BloomFilter filter = group.getBloomFilter(group.getBloomFilterElementCount(), LOW_FALSE_POSITIVE_RATE, (long)(Math.random() * Long.MAX_VALUE));
assertTrue(filter.contains(key1.getPubKeyHash()));
assertTrue(filter.contains(key1.getPubKey()));
assertFalse(filter.contains(key2.getPubKey()));
Expand All @@ -346,7 +347,7 @@ public void bloom() throws Exception {
// We ran ahead of the lookahead buffer.
assertFalse(filter.contains(group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).getPubKey()));
group.importKeys(key2);
filter = group.getBloomFilter(group.getBloomFilterElementCount(), 0.001, (long) (Math.random() * Long.MAX_VALUE));
filter = group.getBloomFilter(group.getBloomFilterElementCount(), LOW_FALSE_POSITIVE_RATE, (long) (Math.random() * Long.MAX_VALUE));
assertTrue(filter.contains(key1.getPubKeyHash()));
assertTrue(filter.contains(key1.getPubKey()));
assertTrue(filter.contains(key2.getPubKey()));
Expand Down Expand Up @@ -377,7 +378,7 @@ public void bloomFilterForMarriedChains() throws Exception {
assertEquals(expected, group.getBloomFilterElementCount());
Address address1 = group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
assertEquals(expected, group.getBloomFilterElementCount());
BloomFilter filter = group.getBloomFilter(expected + 2, 0.001, (long)(Math.random() * Long.MAX_VALUE));
BloomFilter filter = group.getBloomFilter(expected + 2, LOW_FALSE_POSITIVE_RATE, (long)(Math.random() * Long.MAX_VALUE));
assertTrue(filter.contains(address1.getHash()));

Address address2 = group.freshAddress(KeyChain.KeyPurpose.CHANGE);
Expand All @@ -389,7 +390,10 @@ public void bloomFilterForMarriedChains() throws Exception {
assertTrue("key " + i, filter.contains(address.getHash()));
}
// We ran ahead of the lookahead buffer.
assertFalse(filter.contains(group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS).getHash()));
// We try two fresh addresses because of expected false positives. Note that the test could still fail.
Address fresh1 = group.freshAddress(KeyPurpose.RECEIVE_FUNDS);
Address fresh2 = group.freshAddress(KeyPurpose.RECEIVE_FUNDS);
assertFalse(filter.contains(fresh1.getHash()) && filter.contains(fresh2.getHash()));
}

@Test
Expand Down
11 changes: 7 additions & 4 deletions core/src/test/java/org/bitcoinj/wallet/WalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1757,15 +1757,16 @@ public void marriedKeychainBloomFilter() throws Exception {
createMarriedWallet(2, 2);
Address address = wallet.currentReceiveAddress();

assertTrue(wallet.getBloomFilter(0.001).contains(address.getHash()));
double falsePositiveRate = 0.00001;
assertTrue(wallet.getBloomFilter(falsePositiveRate).contains(address.getHash()));

Transaction t1 = createFakeTx(UNITTEST, CENT, address);
TransactionOutPoint outPoint = new TransactionOutPoint(UNITTEST, 0, t1);

assertFalse(wallet.getBloomFilter(0.001).contains(outPoint.unsafeBitcoinSerialize()));
assertFalse(wallet.getBloomFilter(falsePositiveRate).contains(outPoint.unsafeBitcoinSerialize()));

sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, t1);
assertTrue(wallet.getBloomFilter(0.001).contains(outPoint.unsafeBitcoinSerialize()));
assertTrue(wallet.getBloomFilter(falsePositiveRate).contains(outPoint.unsafeBitcoinSerialize()));
}

@Test
Expand Down Expand Up @@ -2705,7 +2706,9 @@ public void witnessTransactionGetFeeTest() throws Exception {
int vsize = request.tx.getVsize();
Coin feePerVkb = fee.multiply(1000).divide(vsize);
assertEquals(Coin.valueOf(14100), fee);
assertEquals(Transaction.DEFAULT_TX_FEE, feePerVkb);
// due to shorter than expected signature encoding, in rare cases we overpay a little
Coin overpaidFee = Transaction.DEFAULT_TX_FEE.add(valueOf(714));
assertTrue(feePerVkb.toString(),feePerVkb.equals(Transaction.DEFAULT_TX_FEE) || feePerVkb.equals(overpaidFee));
}

@Test
Expand Down
3 changes: 2 additions & 1 deletion examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ plugins {
dependencies {
implementation project(':groestlcoinj-core')
implementation 'info.picocli:picocli:4.6.1'
implementation 'org.slf4j:slf4j-jdk14:1.7.32'
implementation 'org.slf4j:slf4j-jdk14:1.7.36'
implementation 'org.fusesource.leveldbjni:leveldbjni-all:1.8'
}

sourceCompatibility = 1.8
Expand Down
2 changes: 1 addition & 1 deletion tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
dependencies {
implementation project(':groestlcoinj-core')
implementation 'info.picocli:picocli:4.6.1'
implementation 'org.slf4j:slf4j-jdk14:1.7.32'
implementation 'org.slf4j:slf4j-jdk14:1.7.36'
}

sourceCompatibility = 1.8
Expand Down
2 changes: 1 addition & 1 deletion wallettemplate/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
implementation project(':groestlcoinj-core')
implementation 'de.jensd:fontawesomefx:8.0.0'
implementation 'com.google.zxing:core:3.4.1'
implementation 'org.slf4j:slf4j-jdk14:1.7.32'
implementation 'org.slf4j:slf4j-jdk14:1.7.36'
}

javafx {
Expand Down

0 comments on commit 4f52a66

Please sign in to comment.