Commit graph

3531 commits

Author SHA1 Message Date
Sean Gilligan
f2a7229676 MessageVerifyUtils: move to o.b.crypto.utils from o.b.utils
This class belongs in the crypto module.
2023-03-05 01:06:12 +01:00
Sean Gilligan
848d2d88bb StreamUtils: move to o.b.base.internal from o.b.base.utils 2023-03-05 01:02:20 +01:00
Sean Gilligan
8e35390b8a SegwitAddress: minor simplification in toBech32()
Calculate encoding using ternary operator and replace if statement.
2023-03-05 00:49:45 +01:00
Sean Gilligan
b83710a242 SegwitAddress: store witnessProgram as 8-bits/byte
Change the internal storage format from 5-bits/byte (Bech32 intermediate format)
to standard 8-bits/byte.

Remove now unneeded conversions and add conversion in toBech32().
2023-03-05 00:44:06 +01:00
Sean Gilligan
f8ac6b3405 SegwitAddress: store witnessVersion internally as a short
Separate witnessVersion from witnessProgram in private members.

Note that the witnessProgram is still stored in a 5-bit per byte encoding
as it was in the combined byte[]. A future PR will change it to 8-bit per
byte encoding.
2023-03-05 00:40:56 +01:00
Sean Gilligan
f9be0b2a3d Address: convert to interface
* Migrate protected members to subclasses
* Remove constructors
* Migrate hashCode and equals to subclasses
2023-03-05 00:38:55 +01:00
Sean Gilligan
6c84ffec85 ScriptBuilder: cast address to LegacyAddress before calling getHash()
In both of these cases we have already checked the ScriptType of the 
address and know that it is a LegacyAddress.
2023-03-04 10:08:44 +01:00
Sean Gilligan
4f66bfc462 MessageVerifyUtils: cast P2SH address to LegacyAddress
* Change the private compareP2SHScriptHashDerivedFromPubKey() method to
  take a LegacyAddress
* In caller cast address (after check for P2SH) to LegacyAddress
2023-03-04 09:58:50 +01:00
Sean Gilligan
9002edbe8f Base58: move tests to o.b.base
These should have been moved when the Base58 class was moved.
2023-03-03 22:45:48 +01:00
Andreas Schildbach
1c380de16d PeerAddress: migrate time field to java.time API 2023-03-03 20:06:34 +01:00
Andreas Schildbach
913f5ac8c6 PeerDiscovery: migrate getPeers() to java.time API 2023-03-03 00:10:35 +01:00
Andreas Schildbach
35c4fd9025 ExponentialBackoff: migrate to java.time API 2023-03-02 23:32:45 +01:00
Andreas Schildbach
b356f487e5 PeerGroup: migrate peerDiscoveryTimeout field to java.time API 2023-03-02 23:32:45 +01:00
Andreas Schildbach
d1aa4de677 Block: migrate time field to java.time API
The precision of Bitcoin time is only a second, so we need to
truncate any surplus precision to avoid rounding errors in the
PoW verification.
2023-03-02 23:32:45 +01:00
Sean Gilligan
50caafc8d5 ByteUtils: replace Guava comparator with arrayUnsignedComparator()
Replace Guava UnsignedBytes.lexicographicComparator() with
ByteUtils.arrayUnsignedComparator().
2023-03-02 23:00:07 +01:00
Sean Gilligan
17abffa04b Peer: deprecate ping() and replace with sendPing()
1. Returns Duration rather than long
2. Uses CompletableFuture rather than ListenableCompletableFuture

I've also changed the error-handling a little. Instead of throwing
a ProtocolException (RuntimeException) if PingPong isn't supported
the exception is set in the CompletableFuture. We don't have anything
catching this exception, so wrapping it in the CompletableFuture seems
like a safe move.
2023-03-02 18:50:16 +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
7ee4f334be Sha256Hash: replace Ints.fromBytes with ByteUtils.readUint32BE 2023-03-02 12:35:38 +01:00
Sean Gilligan
f71b085cd2 VarInt: replace Guava Ints.checkedCast with Math.toIntExact 2023-03-02 12:31:31 +01:00
Sean Gilligan
855b50cd63 Coin: replace LongMath.pow() with hardcode
There's no convenient Java built-in for exponentiation
of `long`. And the COIN_VALUE constant is unlikely to ever change.
So we're just going to define it with a `long` literal.

Fortunately Java 7 added the ability to use `_` to group digits.
2023-03-02 12:27:57 +01:00
Sean Gilligan
8325b0aee4 FutureUtils: add failedFuture method
As we're migrating from ListenableCompletableFuture to standard
CompletableFuture, we need a failedFuture() method that returns the
standard CompletableFuture object.

TransactionBroadcast already needed this method as it was returning
a ListenableCompletableFuture in one case where a standard
CompletableFuture would be preferred.

This method can be deprecated when we require Java 9.
2023-03-02 12:22:33 +01:00
Sean Gilligan
9e59b0fc79 Sha256Hash: replace Guava io.ByteStreams with Files.readAllBytes 2023-03-02 11:36:53 +01:00
Andreas Schildbach
a40f206e45 Peer: measure ping-pong time using java.time API 2023-03-01 23:55:44 +01:00
Andreas Schildbach
2eb7278d04 core, integration-test: migrate usage of Guava Stopwatch to java.time API 2023-03-01 13:21:30 +01:00
Sean Gilligan
64dbdd9fcd base, wallet: migrate Guava LongMath.checked{Add,Subtract,Multiply} to Math.{add,substract,multiply}Exact 2023-02-28 22:06:03 +01:00
Sean Gilligan
0e4bda3cd8 LegacyAddress: replace two core imports with paths in JavaDoc
This helps us keep better track of our progress
in migrating away from core.
2023-02-27 22:58:19 +01:00
Sean Gilligan
d86406ab2e TimeUtils: move (mock) time utils from o.b.core.Utils to new class 2023-02-27 19:32:50 +01:00
Sean Gilligan
6e77dcb433 PlatformUtils: move OS/runtime detection from o.b.core.Utils to new class 2023-02-27 18:34:20 +01:00
micheal swiggs-malmevik
0685bf70e4 BitcoinURI: remove redundant BitcoinNetwork cast 2023-02-27 16:56:13 +01:00
micheal swiggs-malmevik
cfc3b26a53 BitcoinURI: remove unused parameter addressToken from parseParameters() 2023-02-27 16:54:02 +01:00
micheal swiggs-malmevik
8e03aee87d DeterministicKey: remove unused parameter parent from ascertainParentFingerprint() 2023-02-27 16:38:06 +01:00
micheal swiggs-malmevik
6298651929 DeterministicKeyChain: remove unused parameter baseKey from initializeHierarchyUnencrypted() 2023-02-27 16:35:24 +01:00
micheal swiggs-malmevik
6e8435e129 Wallet: remove unused parameter originalInputs from calculateFee() 2023-02-27 16:21:46 +01:00
micheal swiggs-malmevik
135476f71b Wallet: remove unused parameter avail from checkBalanceFuturesLocked() 2023-02-27 16:21:08 +01:00
Sean Gilligan
a4e2583b4e FutureUtils: move to o.b.base.internal package 2023-02-27 12:52:36 +01:00
Sean Gilligan
ebe70e453a FutureUtils: migrate ListenableCompletableFuture to CompletableFuture 2023-02-27 12:43:02 +01:00
Sean Gilligan
1fa9bff490 ECKey, DeterministicKey: migrate API usages to Network from NetworkParameters 2023-02-27 11:45:05 +01:00
Andreas Schildbach
625adf55ea DeterministicKey: fix JavaDoc of deprecated serializePrivB58() 2023-02-27 11:40:33 +01:00
Sean Gilligan
232f194a36 DumpedPrivateKey: fix NPE in deprecated fromBase58() 2023-02-27 11:31:59 +01:00
Sean Gilligan
8ba45dd812 CrytoUtils: new internal utils, move sha256hash160() from Utils 2023-02-27 11:25:00 +01:00
Sean Gilligan
03782a4697 InternalUtils: move to o.b.base.internal package 2023-02-24 11:47:59 +01:00
Sean Gilligan
484b7185d4 VarInt: move to o.b.base package 2023-02-24 11:24:58 +01:00
Sean Gilligan
0d3c9780b0 SignatureDecodeException: move to o.b.crypto package 2023-02-24 11:21:11 +01:00
Sean Gilligan
0b865408e6 DRMWorkaround: remove workaround for AES-256 in older Java
Android and OpenJDK don't need this and I'm pretty sure that
Oracle JDK 9 and even recent builds of Oracle JDK don't need it either.
2023-02-24 10:55:45 +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
aaf83be6f8 LegacyAddressTest, SegwitAddressTest: convert to Network from NetworkParameters
Finish conversion from NetworkParameters to Network in the tests. This cleans up
the code, too.

There are still some references to NetworkParameters in LegacyAddressTest:

1. Tests of deprecated methods that can be removed when those methods are removed
2. Tests that need getP2SHHeader() which hasn't moved to Network yet.
2023-02-24 09:33:10 +01:00
Sean Gilligan
10af4cdae9 NetworkParameters: migrate getSegwitAddressHrp() to Network.segwitAddressHrp()
Deprecate the old method.
2023-02-22 11:44:30 +01:00
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