Commit Graph

51 Commits

Author SHA1 Message Date
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
d86406ab2e TimeUtils: move (mock) time utils from o.b.core.Utils to new class 2023-02-27 19:32:50 +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
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
Andreas Schildbach
83644530cd EncodedPrivateKey: migrate from NetworkParameters to Network 2022-08-17 09:34:04 +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
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
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
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
900af2bde9 build.gradle: update JUnit 5 to 5.9.0 2022-07-28 20:50:06 +02:00
Andreas Schildbach
f6cb6c15d1 CoinSelection: add a new constructor that doesn't require valueGathered
We'll add the output values up ourselves.

This also deprecates the old constructor.
2022-07-19 09:37:27 +02:00
Andreas Schildbach
fb90c4458d Context: remove network parameters
This is the first step in the goal of making Context optional again,
using it only for configuration of a test environment.
2022-07-14 01:59:49 +02:00
Sean Gilligan
665574add5 WalletTool: use BitcoinNetwork::toString for chain fileName 2022-07-13 22:09:47 +02:00
Andreas Schildbach
50ccb6b8fc Network: rename MAIN to MAINNET and TEST to TESTNET
The old, shorter names can be used as an alternate name so they will still be accepted for user-facing input.
2022-07-13 22:04:31 +02:00
Sean Gilligan
b8729f2fbd Network: rename to BitcoinNetwork
This is done in preparation for introducing a `Network` interface as a parent,
coming in a future commit.
2022-06-27 12:11:25 +02:00
Sean Gilligan
bfa6536942 org.bitcoinj.base: move Network to base 2022-06-26 20:05:09 +02:00
Sean Gilligan
a0b0392093 NetworkParameters: depend on Network enum, rather the reverse
This change makes NetworkParameters use and depend upon Network instead
of the reverse. This will allow Network to be moved to `base`.

Define `UnitTestParams` as being on the `TEST` network. We must choose
a `Network` property for `UnitTestParams` and I have learned through trial-and-error
that `TEST` is the correct choice.
2022-06-24 12:30:40 +02:00
Sean Gilligan
44d0576ce4 org.bitcoinj.base: move Base58, Bech32, AddressFormatException to base 2022-06-23 11:48:01 +02:00
Sean Gilligan
0645a835de org.bitcoinj.base: move Script.ScriptType to a top level type in base 2022-06-22 18:13:34 +02:00
Sean Gilligan
93cc0ac9c5 org.bitcoinj.base: move Sha256Hash and byte/math Utils members to base
* move o.b.core.Sha256Hash to o.b.base.Sha256Hash
* move byte and math utility methods from o.b.core.Utils to a new
  o.b.base.ByteUtils class
2022-06-22 17:40:50 +02:00
Sean Gilligan
84e737acdf org.bitcoinj.base: introduce new package that provides fundamental types with minimal dependencies
This also moves Coin, Fiat, its parent Monetary and the related MonetaryFormat into the new base package.

See the provided package-info.java for details.
2022-06-21 19:25:47 +02:00
Sean Gilligan
8f2757c0eb WalletTool: explicitly specify BIP32 in createWallet() 2022-05-03 20:04:16 +02:00
Sean Gilligan
e428cfbc04 wallet-tool: Add nativeCompile task for GraalVM
Also add graalvm.yml to do a nativeCompile build on Github Actions
2022-05-02 11:57:59 -07:00
Sean Gilligan
1283fe6f36 Network.java: remove PROD (alias for MAIN)
This affects the command-line UI of some tools, but since the `Network`
enum hasn't been released yet, we can remove it without deprecating
first.
2022-04-29 01:19:22 +02:00
Sean Gilligan
a6e5c88ce8 build.gradle: add detailed deprecation warnings to all modules 2022-04-19 10:07:55 +02:00
Sean Gilligan
bb8687f278 Wallet: add WalletFactory parameter to loadFromFile() 2022-04-15 14:56:27 +02:00
Sean Gilligan
e6dd75d823 wallettool: add some first basic JUnit 5 tests
Also update gradle.yml to upload test results to GitHub.
2022-04-15 14:42:58 +02:00
Sean Gilligan
05b0ee144b WalletTool: declare specific exceptions for call() 2022-04-14 15:33:22 +02:00
Sean Gilligan
eede925c96 Wallet: add loadFromFile method that supports WalletTool
* Add `Wallet.loadFromFile` that takes options needed by WalletTool
* Add `Wallet.loadFromFileStream` that supports the extra options
* Update `WalletTool` to use the new `loadFromFile` method
2022-04-12 17:38:19 +02:00
Sean Gilligan
1219e0d7b0 InternalUtils: replace Guava Joiner and Splitter with native JDK equivalent
Also deprecate the old Joiner and Splitter related members of Utils.
2022-04-10 16:20:00 +02:00
Sean Gilligan
56d89f37ac WalletTool: remove unnecessary null assignments 2022-04-09 10:54:52 +02:00
Sean Gilligan
3ea2dc40d9 WalletTool: remove superfluous throws Exception from main
main() currently throws no checked exceptions. This is a good thing and
means all checked exceptions are caught and (hopefully properly) handled by
outputting error messages and return a non-zero exit code.
2022-04-01 20:27:13 +02:00
Sean Gilligan
1343776286 convert ImmutableList to unmodifiable list
This converts all remaining instances of ImmutableList (except those
in core tests) to JDK unmodifiable list.
2022-03-30 16:33:22 +02:00
Sean Gilligan
25d4b8b8a0 WalletTool: improve sendPayment() exception handling
* Split the long `try` block into multiple `try/catch` blocks
* Consistently use System.err.println and System.exit on errors
* System.out.println an information message before falling back to `broadcastPayment`
2022-03-25 20:35:35 +01:00
Sean Gilligan
091fdd9791 PaymentSession: proper future-style error handling for sendPayment()
This is a breaking change, but the existing code is not using futures properly and
fixing this is worth the breakage.

* Instead of returning `null`, return a failed future
* Instead of throwing errors, return failed futures
2022-03-25 19:33:08 +01:00
Sean Gilligan
a20db6ed2c WalletTool: migrate from ListenableFuture to CompletableFuture 2022-03-07 23:24:18 +01:00
Sean Gilligan
55b87f497c build.gradle: fix hasAnnotationProcessor check 2022-03-05 00:07:12 +01:00
Sean Gilligan
4cde8940fc wallettool/build.gradle: generate man, html5 and adoc manpages
Adds the picocli-codegen annotation processor.

To build the documentation use `gradle bitcoinj-wallettool:asciidoctor`. The results are in:

 * wallettool/build/generated-picocli-docs/wallet-tool.adoc (asciidoc source)
 * wallettool/build/docs/html5/wallet-tool.html (HTML version)
 * wallettool/build/docs/manpage/wallet-tool.1 (man format)
2022-02-25 21:46:54 +01:00
Sean Gilligan
0a1e1ca8a0 WalletTool: extract common code from dumpWallet() into printWallet() 2022-02-23 16:11:18 +01:00
Andreas Schildbach
f3a314e2d9 global replace SegWit by segwit 2022-02-18 10:42:12 +01:00
Sean Gilligan
7626b27850 build.gradle: update picocli to 4.6.3 2022-02-18 09:02:24 +01:00
Sean Gilligan
ea208935ff build.gradle: Update SLF4J to 1.7.36
Starting with version 1.7.36, SLF4J releases are reproducible.
2022-02-18 08:54:36 +01:00
Andreas Schildbach
435e39a841 Utils: add bytesToBigInteger() helper and use it
This is the antagonist to Utils.bigIntegerToBytes().
2022-02-11 16:17:24 +01:00
Andreas Schildbach
6ad636ccec SigNetParams: support signet 2022-02-11 10:52:49 +01:00
Kasim G
a31cbe0470 apply "Anonmyous type can be replaced with lambda" refactoring 2022-01-28 17:18:42 +01:00