Commit Graph

96 Commits

Author SHA1 Message Date
Sean Gilligan
7ef88e709e TransactionOutPoint: make hash and index immutable
* Make the two fields `final`
* Rename accessors to `hash()` and `index()`
* Provide deprecated stubs for the old "get" methods
2023-04-04 00:06:47 +02:00
Andreas Schildbach
fbc5185b5a TransactionOutPoint: divorce from Message
It is never sent on its own, so it doesn't need to be a `Message`.

* A static constructur `read()` replaces the native constructor that deserialized
  from a payload.
* A `write()` helper replace `bitcoinSerializeToStream()`.
* A `serialize()` helper replace `bitcoinSerialize()`.
* A `BYTES` constant replaces `getMessageSize()`.

This comes with a test.
2023-04-03 22:17:31 +02:00
Andreas Schildbach
4248804f82 Sha256Hash: migrate to byte[] serialize() from byte[] getReversedBytes() 2023-04-03 22:12:51 +02:00
Andreas Schildbach
edf889306b VarInt: migrate to byte[] serialize() from byte[] encode() 2023-04-03 22:11:00 +02:00
Andreas Schildbach
fb9b578542 VersionMessage: move isBloomFilteringSupported() to Peer 2023-04-03 19:07:55 +02:00
Andreas Schildbach
f2fa39ef3e HeadersMessage: remove params from constructors 2023-04-03 19:05:45 +02:00
Andreas Schildbach
c613a7d98a Block, FilteredBlock: remove params from constructors 2023-04-03 19:04:23 +02:00
Andreas Schildbach
f174e2350e VersionMessage: inline helpers isWitnessSupported(), hasBlockChain() and hasLimitedBlockChain()
Our API is now fluent enough that we don't need them any more.
2023-04-03 17:53:49 +02:00
Andreas Schildbach
dedf478c66 Transaction: remove params from constructors 2023-04-03 16:23:13 +02:00
Andreas Schildbach
c309994e99 FakeTxBuilder: don't create unnecessary transaction in makeSolvedTestBlock() 2023-04-02 17:29:41 +02:00
Andreas Schildbach
116194f39e Stopwatch: introduce tool for measuring time mainly for log messages
The helpers from `TimeUtils` are affected by the mock clock, which
is not desired for debug output.
2023-04-01 23:34:09 +02:00
Sean Gilligan
772bccd5f8 MemoryBlockStore: construct with genesis block
It doesn't need an entire `NetworkParameters`.
2023-03-31 22:14:06 +02:00
Andreas Schildbach
81fb0c5acb Transaction, TransactionInput, TransactionOutPoint: add static constructors for the elements of a coinbase
This should reduce misuse of the standard constructors.
2023-03-31 19:28:11 +02:00
Andreas Schildbach
eb531166ee TransactionOutput: remove params from constructors
To make this possible, a check for maximum value is removed.
2023-03-30 23:43:17 +02:00
Andreas Schildbach
dd07d2cf62 NetworkParameters: fix protocol version for BIP37 bloom filters
According to BIP111, the protocol version must be greater than 70000.
Since we use "greater or equals", 70001 is the correct number.
2023-03-30 23:39:12 +02:00
Andreas Schildbach
8aeb5d3b1c TransactionInput: remove params from constructors 2023-03-30 23:00:04 +02:00
Andreas Schildbach
f2376e3ba3 PartialMerkleTree: remove params from constructors 2023-03-30 22:39:05 +02:00
Andreas Schildbach
773a9aeb4e PeerAddress: remove params from constructor
To make this possible, a port has to be specified in all cases.
2023-03-30 18:03:18 +02:00
Andreas Schildbach
57c9456ce8 TransactionOutPoint: remove params from constructors 2023-03-30 01:42:50 +02:00
Andreas Schildbach
32ee59f7bb BloomFilter: remove params from constructor 2023-03-30 00:31:02 +02:00
Andreas Schildbach
5ea7d64ee4 RejectMessage: remove params from constructors 2023-03-29 23:48:13 +02:00
Andreas Schildbach
dd2213c7e1 ListMessage: remove params and serializer from constructors in hierarchy 2023-03-29 23:37:17 +02:00
Andreas Schildbach
592f3c692d Services: wrapper for node services bitfield 2023-03-28 15:52:05 +02:00
Sean Gilligan
3b7c630eb4 ForwardingService: move args parsing to constructor
This simplifies the overall flow for tutorial purposes.
2023-03-27 23:23:44 +02:00
Sean Gilligan
65466f8908 ForwardingService: combine methods main() and forward() 2023-03-27 22:21:58 +02:00
Sean Gilligan
41ed5a984b Wallet: deprecate public fields in SendResult, replace with accessors
* Deprecate public fields in `SendResult`
* Make available equivalent accessors
* Update all usages

This prepares the way for replacing `SendResult` with `TransactionBroadcast`
in the future.
2023-03-27 20:22:35 +02:00
Andreas Schildbach
b528fb5180 build.gradle: update SLF4J to 2.0.7
Starting with SLF4J 2.0.0, we can use the fluent logger API.
2023-03-27 15:25:02 +02:00
Andreas Schildbach
150c911750 LegacyAddress: flip arguments of new static constructor fromBase58()
Otherwise the deprecation cycle won't be of much use for consumers who pass `null` for `params`.
2023-03-27 09:17:37 +02:00
Andreas Schildbach
47a5d73035 ByteUtils: rename all writeUInt*() helpers to writeInt*()
This creates overloads in some cases.
2023-03-24 19:34:06 +01:00
Andreas Schildbach
7fba2d8c6b Message: fold unsafeBitcoinSerialize() into bitcoinSerialize() 2023-03-22 02:21:21 +01:00
Andreas Schildbach
0da35c6a0c VarInt: migrate native constructors to static constructors
The old native constructors have been deprecated.
2023-03-21 23:02:41 +01:00
Andreas Schildbach
9d9cadd59c Message: in constructors wrap payload bytes and offset into a ByteBuffer
This reduces arguments of constructors and does away with
a couple of constructor variants.
2023-03-21 17:55:32 +01:00
Andreas Schildbach
371025f604 ByteUtils: rename helpers that write to byte arrays or streams to write*()
Note the read helpers already follow the `read*()` pattern.
2023-03-21 17:10:17 +01:00
Andreas Schildbach
34d8948be9 Message: do away with retaining of original message payload
This removes all caching of original message payload and "retain mode" in message serializers.

There is some effect on tests. Asserts on the cache status have been removed, rendering some
tests almost pointless. Rather than removing them, comments have been added to explain the
history of these tests. An assert on a large binary blob of a block was dependent on retain mode, likely
due to non-optimal encoding. It had to be disabled.

Note: Some classes still cache individual values, like hashes.
2023-03-20 16:55:29 +01:00
Andreas Schildbach
04c72ce003 Peer: migrate pingIntervals field to java.time API 2023-03-19 20:15:00 +01:00
Andreas Schildbach
e37b2ad78c Preconditions: replace Guava checkArgument() and checkState() for the entire codebase
This also fixes many precondition messages, and rewrites two cases
of `checkPositionIndex()` and `checkElementIndex()`.
2023-03-19 17:48:27 +01:00
Andreas Schildbach
b309308076 EncryptableItem: rename creationTime() method from getCreationTime() 2023-03-18 11:23:05 +01:00
Andreas Schildbach
45f87d8339 PeerGroup: rename fastCatchupTime() method from getFastCatchupTime() 2023-03-18 11:16:31 +01:00
Andreas Schildbach
c2cabead9a TransactionConfidence: rename lastBroadcastTime() method from getLastBroadcastTime() 2023-03-18 11:11:05 +01:00
Andreas Schildbach
9ec245c259 Objects: migrate entire codebase to requireNonNull() from Guava Precondition.checkNotNull()
This has the added benefit of exception messages being evaluated on demand.
2023-03-16 20:12:28 +01:00
Andreas Schildbach
006c00ac35 TestWithNetworkConnections: pick random TCP bind ports for each test instance
This will hopefully reduce spurious test failures due to already bound ports.
2023-03-10 23:43:14 +01:00
Andreas Schildbach
7e70541658 PeerGroup: migrate vConnectTimeout field to java.time API 2023-03-10 22:32:47 +01:00
Andreas Schildbach
54754e14e9 EncryptableItem, ECKey, DeterministicKey, DeterministicSeed: migrate creationTime field to java.time API 2023-03-10 09:28:27 +01:00
Sean Gilligan
3023947df8 ByteUtils: move to o.b.base.internal
We don't consider ByteUtils to be part of our external API.
2023-03-10 01:28:23 +01:00
Andreas Schildbach
92ee36848c DeterministicSeed: introduce static constructors meant for external consumers
* native constructors that were meant to be called by consumers now have static equivalents
* all native constructors are discouraged from being used by a JavaDoc comment
* one constructor that wasn't meant to be used by consumers is switched to private access
* tests and tools that resemble consumers are updated to use the new API

Note: although most native constructors are now deprecated, we're not using
annotations because we're still calling them.
2023-03-10 00:53:35 +01:00
Andreas Schildbach
46dcfc6bda TestWithNetworkConnections: ask Wallet for an Address right away
Previously, it was asking for a key and converted manually.
2023-03-08 17:29:51 +01:00
Andreas Schildbach
16c90d2891 TimeUtils: migrate mock clock to java.time API
* Migrate `setMockClock()` parameters to Instant
* Migrate `rollMockClock()` parameters to Duration
* Rename to `clearMockClock()` from `resetMocking()`
* Use `Clock` internally to provide the time
2023-03-08 16:20:48 +01:00
Andreas Schildbach
6eed19d449 PeerTest, TransactionBroadcastTest: clear the mock clock after some tests that use it 2023-03-07 16:08:40 +01:00
Andreas Schildbach
d1e2e71bb5 TransactionConfidence: migrate lastBroadcastedAt field to java.time API 2023-03-07 00:41:55 +01:00
Andreas Schildbach
310b93be4e Peer, PeerGroup: migrate fastCatchupTime field to java.time API 2023-03-06 09:50:07 +01:00