Commit graph

3256 commits

Author SHA1 Message Date
Andreas Schildbach
adcba44ae0 SeedPeers: add a constructor for InetSocketAddress
The old `int` format for peer addresses is now deprecated, as it doesn't support IPv6.
2022-12-04 13:36:45 +01:00
Andreas Schildbach
fe72abe8fc SeedPeers: don't throw in getPeers() if service bit filtering is used
This brings SeedPeers more in line with the other peer discoveries. There
is no guarantee for filtering.
2022-12-04 13:32:52 +01:00
Andreas Schildbach
3fffeee295 PeerGroup: discover peers via P2P addr and addrv2 messages
Adds peer addresses discovered via P2P to the list of potential peers to connect to.
This is enabled by default if at least one PeerDiscovery is set via addPeerDiscovery(),
and the default can be overridden with setDiscoverPeersViaP2P().
2022-11-21 16:23:39 +01:00
Andreas Schildbach
74d54de1f6 AddressEventListener: new event produced by Peer if an addr or addrv2 message is received 2022-11-21 15:39:24 +01:00
Andreas Schildbach
15cc61d066 build.gradle: update Jackson to 2.14.0 2022-11-14 08:24:23 +01:00
Andreas Schildbach
5a43d69775 build.gradle: update equalsverifier to 3.11 2022-11-14 08:24:23 +01:00
Andreas Schildbach
a9fcec648d build.gradle: update EasyMock to 5.0.1 2022-11-14 08:24:23 +01:00
Andreas Schildbach
310a3ffc4a build.gradle: update protobuf-javalite to 3.21.9 2022-11-14 01:05:58 +01:00
Andreas Schildbach
271e9ab018 build.gradle: update BouncyCastle to 1.72 2022-11-14 00:36:16 +01:00
Andreas Schildbach
f367ffa709 PeerAddress: addresses that make use of base32 in hostnames generally do not use padding, so omit it 2022-08-24 15:26:01 +02:00
Sean Gilligan
97590435d7 PeerAddressTest: add placeholder I2P test case to deserializeToString() 2022-08-23 08:11:01 +02:00
Sean Gilligan
b21b10774a PeerAddressTest: add parameterized deserializeToString test
* build.gradle: Add JUnitParams so we can have parameterized tests in existing test
* Add deserializeToString method with three addresses to test
2022-08-23 00:51:39 +02:00
Sean Gilligan
8a2d4c99d2 PeerAddress: create NetworkId enum, define I2P, CJDNS network IDs
* Replace hardcoded integer values (e.g. `0x01`) with NetworkId enum.
* Define (currently) unsupported values: I2P(5), CJDNS(6)
* Use switch statement to handle Network IDs
* Add placeholder cases for I2P and CJDNS
2022-08-23 00:45:03 +02:00
Sean Gilligan
22f02955d7 PeerAddress: make onionChecksum static
The onionChecksum() method uses no instance variables and has no side-effects,
so it can be static.
2022-08-23 00:15:56 +02:00
Sean Gilligan
bdc174e9bc PeerSocketHandler: make peerAddress field final 2022-08-23 00:13:25 +02:00
Sean Gilligan
10e701f8d7 WalletAppKit, DefaultCoinSelector, BuildCheckpoints: simplify some network-related comparisons
Enums can use ==/!=.
2022-08-22 22:27:46 +02:00
Sean Gilligan
0ccface14d PeerAddress: clean up toString, equals, hashCode - handle nulls properly
* Include `hostname` in equals() and hashcode()
* Fix NPE in toString() that occurs for (unsupported) I2P addresses (both addr and hostname are null)
* Better null-handling in equals()
* Add EqualsVerify test
* Add comments
2022-08-22 21:58:05 +02:00
Sean Gilligan
6bec092af2 LegacyAddress, SegwitAddress: normalize network type
Normalize/canonicalize network member of Address types.

LegacyAddress: map SIGNET, REGTEST to TESTNET
SegwitAddress: map SIGNET to TESTNET

Add tests to verify correct behavoir.
2022-08-17 22:50:07 +02:00
Andreas Schildbach
103250efcf Message: remove obsolete readObject() method
It had been used for Java Serialization.
2022-08-17 14:57:49 +02:00
Andreas Schildbach
83644530cd EncodedPrivateKey: migrate from NetworkParameters to Network 2022-08-17 09:34:04 +02:00
Andreas Schildbach
1ba9011cfa EncodedPrivateKeyTest: move "stringification" tests to Base58EncodeCheckedTest
This allows us to get rid of mocking in EncodedPrivateKeyTest.
2022-08-17 01:25:11 +02:00
Andreas Schildbach
66b0cc8324 PrefixedChecksummedBytes: rename to EncodedPrivateKey and update class-level JavaDoc 2022-08-12 11:51:15 +02:00
Andreas Schildbach
64c619d2bf Wallet: add transaction ID to a precondition message 2022-08-12 01:05:58 +02:00
Andreas Schildbach
410b127176 DatabaseFullPrunedBlockStore: remove all database backed block stores
All of them are unmaintained and their tests are in the way of refactorings.
MySQL and Postgres had been disabled for a while, and one seems to care.
H2 is tested, but pulls a driver dependency into the test classpath.
2022-08-11 17:36:27 +02:00
Sean Gilligan
4e3bf65865 base/package-info.java: add the "deprecation exception" rule to package comment 2022-08-11 17:27:43 +02:00
Andreas Schildbach
c298a2987e Bech32Test: move to base package
Bech32 is already there.
2022-08-11 16:37:08 +02:00
Sean Gilligan
f59dc54ac8 Address: construct with and store Network, rather than NetworkParametesr
LegacyAddress, SegwitAddress: replace static factories that take NetworkParameters

* Add static factory methods that take `Network`
* Deprecate static factory methods that take `NetworkParameters`
* Add `Networks` support to `NetworkParameters.of(Network)`
* Update all usages to use the new methods
2022-08-11 02:40:33 +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
1daa7d5569 NetworkParameters: make id final
and initialize it from Network.id()
2022-08-10 22:16:56 +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
9708b4cad9 MockAltNetworkParams, MockAltNetwork: new mocks for alternate network/address testing 2022-08-10 11:04:49 +02:00
Andreas Schildbach
1a5af67b73 BitcoinURI: strip some whitespace from end of lines 2022-08-10 10:45:13 +02:00
Sean Gilligan
d5d7fb0bcc BitcoinURI: migrate from NetworkParameters to Network
* New constructors and public methods that use Network
* Deprecate constructors and methods that use NetworkParameters
2022-08-10 10:38:45 +02:00
Sean Gilligan
67fd6630f6 LegacyAddressTest.getAltNetwork: unregister AltNetwork in finally block 2022-08-09 19:45:43 +02:00
Sean Gilligan
9c30bab375 TransactionOutput: remove deprecated getAddressFrom* methods
Remove deprecated `getAddressFromP2PKHScript()` and `getAddressFromP2SH()` methods

They have been deprecated for more than one release.
2022-08-09 17:20:59 +02:00
Sean Gilligan
13aee43443 NetworkParameters: remove obsolete reference to acceptableAddress in JavaDoc
acceptableAddressCodes[] was removed in 2018.
2022-08-09 17:14:49 +02:00
Sean Gilligan
6a032bf001 ECKey: add toAddress() method, deprecate *Address.fromKey()
This (after deprecated methods are removed) eliminates all dependencies in
the address classes and is a step towards moving address to o.b.base.
2022-08-03 19:52:55 +02:00
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
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