Commit Graph

4081 Commits

Author SHA1 Message Date
Sean Gilligan
90582ac414 AbstractBitcoinNetParams: rename to BitcoinNetworkParams
The Abstract qualifier isn't necessary in the class name.
Also use "Network" instead of "Net" in the new name.
2022-08-03 19:05:40 +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
279b35b25f Network: add exceedsMaxMoney() and simplify various maxMoney checks 2022-08-03 18:09:36 +02:00
Sean Gilligan
696ba9f0d1 AbstractBitcoinNetworkParams: add of method, delegate to it in NetworkParameters
* Add `of(BitcoinNetwork)` `static` method in `AbstractBitcoinNetParams`
* In `NetworkParameters.of(Network)` delegate to `AbstractBitcoinNetParams` for type `BitcoinNetwork`
2022-08-03 01:09:11 +02:00
Andreas Schildbach
d0420cbcd0 PeerTest: use TestNet3Params, rather than UnitTestParams 2022-08-02 15:46:25 +02:00
Andreas Schildbach
4d1e8d659e TransactionBroadcastTest: use TestNet3Params, rather than UnitTestParams 2022-08-02 15:16:57 +02:00
Andreas Schildbach
1f10855462 FilteredBlockAndPartialMerkleTreeTest: use TestNet3Params, rather than UnitTestParams 2022-08-02 15:14:35 +02:00
Sean Gilligan
28c2e2c7e3 Wallet: add network()
Perhaps in the future, we'll want a `network` private or protected member,
but for now that doesn't seem needed.

When we start using Network for address and transaction creation, this
will be used even more.
2022-08-02 12:00:47 +02:00
Sean Gilligan
a942ca0751 FakeTxBuilder: extract private method to generate random addresses 2022-08-02 10:35:02 +02:00
Andreas Schildbach
d3ef5b9493 BlockTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 22:21:01 +02:00
Andreas Schildbach
6584fbcef3 TestWithWallet hierarchy: use TestNet3Params, rather than UnitTestParams 2022-08-01 21:10:43 +02:00
Andreas Schildbach
b0442721c8 ChainSplitTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 21:10:35 +02:00
Andreas Schildbach
1ae9ba3fcf VersionTallyTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 21:05:54 +02:00
Andreas Schildbach
65bcb72ae9 WalletProtobufSerializerTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 20:38:46 +02:00
Andreas Schildbach
6ce49549c3 SPVBlockStoreTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 20:10:57 +02:00
Andreas Schildbach
c5787eafc3 SPVBlockStoreTest: fix context not initialized 2022-08-01 20:08:15 +02:00
Andreas Schildbach
e96de8271e ParseByteCacheTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 19:50:26 +02:00
Andreas Schildbach
16ccbc0f7a TransactionTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 19:46:22 +02:00
Andreas Schildbach
c56fab863b Context: introduce relaxProofOfWork property
This allows unit-tests to disable enforcement of proof of work, so that fake blocks
can be created and solved in short time.
2022-08-01 19:07:07 +02:00
Andreas Schildbach
2e651c35b7 FilteredBlockAndPartialMerkleTreeTest: simplify test wallet creation 2022-08-01 14:24:17 +02:00
Andreas Schildbach
ae63dfb561 FilteredBlockAndPartialMerkleTreeTest: rewrite most assertTrue() as assertEquals() 2022-08-01 14:08:23 +02:00
Andreas Schildbach
f420c5280b TxConfidenceTableTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 12:00:32 +02:00
Andreas Schildbach
03687a807e PeerGroup: create a context as a convenience for apps that mainly operate on a PeerGroup 2022-08-01 10:08:19 +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
Andreas Schildbach
4842cdc6af SPVBlockStoreTest: use TestNet3Params where possible, rather than UnitTestParams 2022-08-01 00:39:52 +02:00
Andreas Schildbach
58b07466f1 VersionMessageTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 00:34:04 +02:00
Andreas Schildbach
2633910b0b TransactionTest: use TestNet3Params where possible, rather than UnitTestParams 2022-08-01 00:30:57 +02:00
Andreas Schildbach
5293901cae TransactionTest: fix context not initialized 2022-08-01 00:24:27 +02:00
Andreas Schildbach
1dd53f713f TransactionInputTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 00:13:10 +02:00
Andreas Schildbach
9e5d07cbc6 TransactionInputTest: fix context not initialized 2022-08-01 00:10:33 +02:00
Andreas Schildbach
f93a67b0c3 ChildKeyDerivationTest: use TestNet3Params, rather than UnitTestParams 2022-08-01 00:02:52 +02:00
Andreas Schildbach
996b2f4759 PaymentProtocolTest: use TestNet3Params, rather than UnitTestParams 2022-07-31 23:58:47 +02:00
Andreas Schildbach
58a6295db1 WalletProtobufSerializerTest: use TestNet3Params where possible, rather than UnitTestParams 2022-07-31 23:52:26 +02:00
Andreas Schildbach
e73d876be6 ParseByteCacheTest: fix context not initialized 2022-07-31 23:37:54 +02:00
Andreas Schildbach
4f150bbe96 MessageTest: use TestNet3Params, rather than UnitTestParams 2022-07-31 23:33:37 +02:00
Andreas Schildbach
90d6c21963 DeterministicKeyChainTest: use TestNet3Params, rather than UnitTestParams 2022-07-31 23:25:01 +02:00
Andreas Schildbach
027372cc60 ECKeyTest: use TestNet3Params, rather than UnitTestParams 2022-07-31 23:17:11 +02:00
Andreas Schildbach
17a4cd12a6 VersionTallyTest: use TestNet3Params where possible, rather than UnitTestParams 2022-07-31 23:14:09 +02:00
Andreas Schildbach
4b534f853d AddressV1MessageTest, AddressV2MessageTest: use TestNet3Params, rather than UnitTestParams 2022-07-31 23:03:39 +02:00
Andreas Schildbach
20cee2c20c BlockTest: fix context not initialized 2022-07-31 22:55:22 +02:00
Andreas Schildbach
9da6616d5a Wallet: remove the output shuffling override for unit-tests
Only one unit-test was dependent on it. That test has been changed to manually disable the shuffling.
2022-07-31 21:19:39 +02:00
Andreas Schildbach
d95e825112 KeyChainGroup: remove the reduced lookahead for unit-tests
It turns out the effect on unit-test runtime is negligible these days.
2022-07-31 17:15:37 +02:00
Sean Gilligan
295ce50782 TransactionBroadcast: add broadcastOnly(), broadcastAndAwaitRelay() deprecate broadcast() 2022-07-31 12:28:18 +02:00
Sean Gilligan
2bd3a8bcde TransactionBroadcast: use stream to simplify collecting sentFutures 2022-07-31 12:08:14 +02:00
Sean Gilligan
419dba9845 TransactionBroadcast: extract method dropPeerAfterBroadcastHandler(Peer)
Refactor the creation of this lambda to its own method.
2022-07-31 11:53:49 +02:00
Sean Gilligan
81fd758800 TransactionBroadcast: extract method broadcastOne(Peer)
* Move code to broadcast to one peer into broadcastOne(Peer) method
* Stop swallowing (but logging) exception thrown by peer.sendMessage(tx)
2022-07-31 11:37:31 +02:00
Sean Gilligan
e078421edd Context: re-add constructors that take params (as deprecated)
There are apps and libraries that are using these, we need to keep them as @Deprecated for
at least one release.
2022-07-30 14:13:40 +02:00
Andreas Schildbach
56419ded8e TransactionBroadcast: fix missing brace in JavaDoc 2022-07-30 13:35:10 +02:00
Sean Gilligan
32c58ad723 TransactionBroadcast: internally create/complete sentFuture
* Add a private member called `sentFuture` that completes when the broadcast
  is "sent" (written to buffer) to the broadcast peers
* Update the broadcast() method to track success/failure of the individual
  broadcast messages and update sentFuture when the individual messages complete.
  (This is done by using `thenComposeAsync`/`whenComplete`)
* Add comments and TODOs
2022-07-29 13:22:00 -07:00
Sean Gilligan
30595af6e4 ForwardingService: use collectingAndThen() to simplify forwardingCoinSelector() 2022-07-29 10:53:57 +02:00