Commit Graph

310 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
dedf478c66 Transaction: remove params from constructors 2023-04-03 16:23:13 +02:00
Andreas Schildbach
44b0ddeb59 Transaction: remove toHexString()
This makes a scary assumption on the format being used (segwit or not).
2023-04-01 10:25:15 +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
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
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
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
1b5fdcaa77 ForwardingService: use awaitRelayed() without extra thenApply() in coinForwardingListener() 2023-03-27 22:07:22 +02:00
Andreas Schildbach
8f504d3795 ForwardingService: return error code 1 on bad command line usage 2023-03-27 22:00:02 +02:00
Sean Gilligan
49290a8ce0 ForwardingService: rename coinForwardingListener from coinsReceivedListener 2023-03-27 21:43:59 +02:00
Sean Gilligan
a0c5501b4b ForwardingService: improve JavaDoc 2023-03-27 21:35:04 +02:00
Sean Gilligan
7cd8f80e44 ForwardingService: fix usage message 2023-03-27 21:32:24 +02:00
Sean Gilligan
3b6bdbad02 WalletAppKit: add launch() methods, simplify examples 2023-03-27 20:59: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
Sean Gilligan
774fde99fb Wallet: move methods sendTransaction() and waitForConfirmation() from ForwardingService
`waitForConfirmation()` now has two variants for convenience.
2023-03-27 19:30:27 +02:00
Sean Gilligan
b24964d056 TransactionBroadcast: add awaitRelayed(), deprecate future()
* Add `awaitRelayed()` method that returns a CF that completes when relaying is confirmed.
* Deprecate `future()` and reimplement it using `awaitRelayed()`.
2023-03-27 18:38:15 +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
Sean Gilligan
b13fe5a5d2 ForwardingService: make coinsReceivedListener() use wallet parameter
...instead of `kit.wallet()`.
2023-03-27 09:11:17 +02:00
Sean Gilligan
3ad07ea28c ForwardingService: rename forwardingCoinSelector() parameter
...to `parentTxId` (which is more clear and correct)
2023-03-27 09:08:27 +02:00
Sean Gilligan
884072c9e3 WalletAppKit: make Closeable 2023-03-26 19:40:28 +02:00
Sean Gilligan
84c8a2887a ForwardingService: make Closable not AutoCloseable
`Closeable` implements `AutoCloseable` but narrows the exception thrown
from `Exception` to `IOException`. ForwardingService.close() currently
doesn't throw any exceptions.
2023-03-26 19:37:08 +02:00
Sean Gilligan
f58d07a623 ForwardingService: start() returns receiving address 2023-03-26 18:10:09 +02:00
Andreas Schildbach
04c72ce003 Peer: migrate pingIntervals field to java.time API 2023-03-19 20:15:00 +01:00
Andreas Schildbach
b309308076 EncryptableItem: rename creationTime() method from getCreationTime() 2023-03-18 11:23: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
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
913f5ac8c6 PeerDiscovery: migrate getPeers() to java.time API 2023-03-03 00:10:35 +01:00
Sean Gilligan
916989a7cd ByteUtils: replace HEX (Guava BaseEncoding) with with own implementation
* Deprecate ByteUtils.HEX
* Migrate usages to new ByteUtils.formatHex() and ByteUtils.parseHex()
* Direct use of Guava BaseEncoding in tests that use some specific
  features of BaseEncoding that aren't provided by new methods.
2023-03-02 15:16:06 +01:00
Sean Gilligan
03782a4697 InternalUtils: move to o.b.base.internal package 2023-02-24 11:47:59 +01:00
Sean Gilligan
0d3c9780b0 SignatureDecodeException: move to o.b.crypto package 2023-02-24 11:21:11 +01:00
Sean Gilligan
1b0ac02eed ECKey, DumpedPrivateKey, EncodedPrivateKey: move to o.b.crypto package
Also move associated tests and test resources.
2023-02-24 10:49:35 +01:00
Sean Gilligan
74821e3517 DefaultAddressParser: move from o.b.core to base 2023-02-24 09:45:59 +01:00
Sean Gilligan
804e8cafec examples: always use BitcoinNetwork enum to specify network
* Replace all usages of *Net*Params.get() with BitcoinNetwork.* enum
* Where NetworkParameters is needed get it with NetworkParameters.of(network)

This change does the following:

* Makes it clear that BitcoinNetwork.* is the preferred method of specifying/declaring
  the active network.
* Prepares the way for examples to get the network string as a command-line arg
* Continues the general migration from NetworkParameters to Network
2023-02-21 18:54:37 +01:00
Sean Gilligan
0acfcb10ec PeerGroup: migrate constructors argument from NetworkParameters to Network
* Add 3 new constructors which take Network
* Deprecate (2 of 3) constructors that take NetworkParameters
* Mark 3-arg NetworkParameters constructor as @VisibleForTesting
2023-02-17 20:21:48 +01:00
Sean Gilligan
d354bc13ce Address, LegacyAddress, SegwitAddress, AddressParser: move to o.b.base
* Move related tests too
* Update imports in referencing classes
2023-02-16 22:50:02 +01:00
Andreas Schildbach
7b970e6001 build.gradle: update picocli to 4.7.1 2023-01-29 21:35:31 +01:00
Andreas Schildbach
8bd519624d build.gradle: update picocli to 4.7.0 2022-11-14 08:10:13 +01:00
Sean Gilligan
94ad7dd344 PeerMonitor: use CompletableFuture for lookupReverseDNS() and getAddr()
* Create threadpool for reverseDns (rather than use new Thread() repeatedly)
* For getAddr() run completion handler on callback thread (and eliminate new Thread())
* Add getHostName() method that handles case where peerAddress.getAddr() is null
2022-08-23 01:09:17 +02:00
Sean Gilligan
39d799e58f PeerMonitor: simplify getAddressForPeer() with trinary operator 2022-08-23 01:02:13 +02:00
Sean Gilligan
2dfd5befb9 PeerMonitor: use ConcurrentHashMap rather than manually synchronized HashMap
* Use ConcurrentHashMap for `reverseDnsLookups` and `addressMessages`
* Remove now-unnecessary `synchronized` blocks
2022-08-17 11:00:56 +02:00
Andreas Schildbach
83644530cd EncodedPrivateKey: migrate from NetworkParameters to Network 2022-08-17 09:34:04 +02:00
Andreas Schildbach
55d1919227 Address, LegacyAddress, SegwitAddress: migrate all usages of deprecated fromKey() to ECKey.toAddress() 2022-08-11 01:49:10 +02:00
Sean Gilligan
d5e2319eb7 Network, BitcoinNetwork: partial alt-net support
Distinguish between `Network` and `BitcoinNetwork` in the code
(some of our implementation supports alt-networks better than others
 and this commit doesn't try to fix them all, just make it more clear
 what is going on. Some may never be made 'generic')
2022-08-10 22:14:17 +02:00
Sean Gilligan
51f1d69e87 Address: deprecate fromString, replace with AddressParser
This change migrates from using `NetworkParameters` to `Network` for specifying the network and
also decouples from static methods in `Address` with an interface/implementation approach.

Note that there are 3 use cases for address parsing:

1. Any network is allowed - AddressParser.parseAddressAnyNetwork(String)
2. Parse for a specified network - AddressParser.parseAddress(String, Network)
3. Parse for a previously-specified (context dependent) network - AddressParser.Strict.parseAddress(String)

In most use cases, an AddressParser instance can be accessed through the Wallet,
which already knows the Network type and in this context validation for network makes
sense. This is why `Wallet` is implementing `AddressParser.Strict`

BitcoinURI allocates its own DefaultAddressParser for now, as do some other tests
and examples that don't have access to a Wallet

In the future DefaultAddressParser may be replaced by something loaded
via the ServiceLoader mechanism or other dynamically configured mechanism.
2022-08-03 18:14:48 +02:00
Sean Gilligan
02aa41e254 TestFeeLevel, DoubleSpend, SendRequest: construct WalletAppKit with BitcoinNetwork constant
This reduces usage of NetworkParameters in WalletAppKit-based examples and tools.
2022-08-01 10:00:06 +02:00
Sean Gilligan
30595af6e4 ForwardingService: use collectingAndThen() to simplify forwardingCoinSelector() 2022-07-29 10:53:57 +02:00
Sean Gilligan
15d0134937 ForwardingService: static method to create CoinSelector
This uses partial function application rather than creating a class
to create the parent-transaction only CoinSelector.
2022-07-29 10:47:30 +02:00