ForwardingService: use Network.checkAddress(Address)

This makes things a little bit simpler and more readable.
This commit is contained in:
Sean Gilligan 2024-04-27 18:00:11 -07:00 committed by Andreas Schildbach
parent 53a6b3e150
commit a7c11c7019

View File

@ -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();
}
}