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.
* Replace all usages of *Net*Params.get() with BitcoinNetwork.* enum
* Where NetworkParameters is needed get it with NetworkParameters.of(network)
This change does the following:
* Makes it clear that BitcoinNetwork.* is the preferred method of specifying/declaring
the active network.
* Prepares the way for examples to get the network string as a command-line arg
* Continues the general migration 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
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)
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.
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).
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.