mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 13:22:42 +01:00
ForwardingService, PrivateKeys: also parse segwit addresses from arguments
This commit is contained in:
parent
eb71e0b0c6
commit
837b614906
@ -74,7 +74,7 @@ public class ForwardingService {
|
||||
filePrefix = "forwarding-service";
|
||||
}
|
||||
// Parse the address given as the first parameter.
|
||||
forwardingAddress = LegacyAddress.fromBase58(params, args[0]);
|
||||
forwardingAddress = Address.fromString(params, args[0]);
|
||||
|
||||
System.out.println("Network: " + params.getId());
|
||||
System.out.println("Forwarding address: " + forwardingAddress);
|
||||
|
@ -22,10 +22,10 @@ import org.bitcoinj.core.Base58;
|
||||
import org.bitcoinj.core.BlockChain;
|
||||
import org.bitcoinj.core.DumpedPrivateKey;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.PeerAddress;
|
||||
import org.bitcoinj.core.PeerGroup;
|
||||
import org.bitcoinj.core.SegwitAddress;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.store.MemoryBlockStore;
|
||||
@ -59,9 +59,9 @@ public class PrivateKeys {
|
||||
BigInteger privKey = Base58.decodeToBigInteger(args[0]);
|
||||
key = ECKey.fromPrivate(privKey);
|
||||
}
|
||||
System.out.println("Address from private key is: " + LegacyAddress.fromKey(params, key).toString());
|
||||
System.out.println("Address from private key is: " + SegwitAddress.fromKey(params, key).toString());
|
||||
// And the address ...
|
||||
Address destination = LegacyAddress.fromBase58(params, args[1]);
|
||||
Address destination = Address.fromString(params, args[1]);
|
||||
|
||||
// Import the private key to a fresh wallet.
|
||||
Wallet wallet = Wallet.createDeterministic(params, Script.ScriptType.P2PKH);
|
||||
|
Loading…
Reference in New Issue
Block a user