mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 00:09:31 +01:00
ForwardingService: use Network.checkAddress(Address)
This makes things a little bit simpler and more readable.
This commit is contained in:
parent
53a6b3e150
commit
a7c11c7019
1 changed files with 2 additions and 2 deletions
|
@ -80,13 +80,13 @@ public class ForwardingService implements Closeable {
|
|||
* @param args the arguments from {@link #main(String[])}
|
||||
*/
|
||||
public ForwardingService(String[] args) {
|
||||
forwardingAddress = AddressParser.getDefault().parseAddress(args[0]);
|
||||
if (args.length >= 2) {
|
||||
// If network was specified, validate address against network
|
||||
network = BitcoinNetwork.fromString(args[1]).orElseThrow();
|
||||
forwardingAddress = AddressParser.getDefault(network).parseAddress(args[0]);
|
||||
network.checkAddress(forwardingAddress);
|
||||
} else {
|
||||
// Else network not-specified, extract network from address
|
||||
forwardingAddress = AddressParser.getDefault().parseAddress(args[0]);
|
||||
network = (BitcoinNetwork) forwardingAddress.network();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue