Commit Graph

3283 Commits

Author SHA1 Message Date
Andreas Schildbach
e27baa1012 DefaultRiskAnalysisTest: fix context not initialized 2023-02-19 12:24:45 +01:00
Andreas Schildbach
bb3fb79f06 Message: deprecate method getHash()
It's not implemented anyways and only used as a generalization of some subclass implementations.
2023-02-19 10:56:23 +01:00
Sean Gilligan
a62ec7921e SegwitAddressTest: add two tests for P2WPKH REGTEST 2023-02-18 00:40:31 +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
micheal swiggs-malmevik
81ddf4f27e Script: remove deprecated method executeScript() 2023-02-17 20:11:40 +01:00
micheal swiggs-malmevik
54c85b2574 Script: remove a couple of deprecated pattern matchers
They had been moved to ScriptPattern.
2023-02-17 20:05:31 +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
Sean Gilligan
49f17929ac DefaultAddessParser: implement parse*AnyNetwork() methods 2023-02-16 19:48:06 +01:00
Sean Gilligan
e6a4dd4718 Wallet, WalletFiles: improve error handling on save
Catch FileNotFound error earlier and provide more informative
exception when it happens.

I discovered this issue running the WalletTool with an invalid directory
path to the wallet file. Before this fix the error/exception message is:

    java.io.IOException: No such file or directory

After the fix it is:

    java.io.FileNotFoundException: /Users/sean/bitcoinj (wallet directory not found)
2023-02-16 11:48:49 +01:00
micheal swiggs-malmevik
e283a832dd Message: deprecate unused property recached and its getter 2023-02-11 12:53:43 +01:00
micheal swiggs-malmevik
1b9b339720 BitcoinSerializer: remove redundant cursor incrementation 2023-02-09 15:40:22 +01:00
micheal swiggs-malmevik
3ff22bdf13 ChildMessage: remove deprecated constructor 2023-02-09 15:33:37 +01:00
Andreas Schildbach
24a94ec981 Peer: make sure to not invoke the unimplemented Message.getHash()
This fixes the integration tests which were broken with the previous commit.
2023-02-09 14:37:56 +01:00
micheal swiggs-malmevik
7fa3730dbc Transaction: remove deprecated methods getHash(), getHashAsString() 2023-02-09 13:58:21 +01:00
micheal swiggs-malmevik
0869228cc4 Peer: remove deprecated method toStringServices() 2023-02-09 12:08:06 +01:00
Andreas Schildbach
2b5c50db25 Transaction: remove deprecated constant MIN_NONDUST_OUTPUT 2023-02-09 11:52:11 +01:00
micheal swiggs-malmevik
6a7ac8e2c7 NetworkParameters: remove deprecated method getMinNonDustOutput() 2023-02-09 11:46:22 +01:00
micheal swiggs-malmevik
ea5de696e8 Message: remove unused method hasMoreBytes() 2023-02-02 13:25:17 +01:00
micheal swiggs-malmevik
1477230f40 Peer: remove unused method isNotFoundMessageSupported() 2023-02-02 12:17:12 +01:00
micheal swiggs-malmevik
3950b88f76 BitcoinSerializer: remove unused parameter checksum in makeMessage() 2023-02-02 12:13:03 +01:00
Johannes Zweng
56e936d534
SegwitAddress: include length check for Taproot witness programs 2023-01-30 11:47:38 +01:00
Andreas Schildbach
aaeadb52c8 build.gradle: update protobuf-javalite to 3.21.12 2023-01-29 21:59:16 +01:00
Andreas Schildbach
27cc40a301 build.gradle: update EasyMock to 5.1.0 2023-01-29 21:52:41 +01:00
Johannes Zweng
fa2d3b3db6 MessageVerifyUtils: add util for verifying signed messages
Since P2SH-P2WPKH addresses do not contain the public itself – but instead
a value derived from a pubkey, namely
RIPEMD160(SHA256(0x00 0x14 <20-byte-pubKeyHash>)) - the verification of
signed messages got a bit more complicated (and different per address
type). To encapsulate this complexity and make it easy to use, this commit
introduces a new util class for verifying signed Bitcoin messages.

It also adds some test vectors partly from other projects implementing
the same functionality to test interoperability, as well as some publicly
known messages and signatures.
2022-12-18 12:01:59 +01:00
Johannes Zweng
070e53889e ECKey: add BIP 137 support for signing text messages with segwit addresses
BIP 137 defined new header byte values for the created signature
when the signature was created with a private key from a segwit
address.

This commit extends the "signMessage(..)" with a new ScriptType argument
(because the value of the signature header since BIP 137 depends on the
address type). This commit keeps the old methods (without the ScriptType
argument), but marks them as deprecated (using P2SH as default, if called
without ScriptType, thus not changing old behaviour).
2022-12-18 12:00:44 +01:00
Johannes Zweng
e4f6dbd866 ECKey: add BIP 137 support for verifying signatures from segwit addresses
BIP 137 extended the allowed range of values for the header byte
of signatures (for signatures created from segwit addresses).
This commit reflects these changes and adds the newly allowed
header byte values to ECKey.signedMessageToKey(...).

Also adds test cases verifying signatures created with segwit addresses.
2022-12-18 11:59:57 +01:00
Andreas Schildbach
bc27caaae0 build.gradle: update protobuf-javalite to 3.21.10 2022-12-04 20:03:08 +01:00
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