mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 05:27:17 +00:00
Provide a consistent fromBase58/toBase58 API for the VersionChecksummedBytes hierarchy.
Deprecates the old constructors and migrates bitcoinj itself to use the new API. Also makes DumpedPrivateKey use WrongNetworkException when appropriate. Adds missing testcases and corrects/adds a bit of JavaDoc.
This commit is contained in:
@@ -28,8 +28,8 @@ public class DoubleSpend {
|
||||
System.out.println(kit.wallet());
|
||||
|
||||
kit.wallet().getBalanceFuture(COIN, Wallet.BalanceType.AVAILABLE).get();
|
||||
Transaction tx1 = kit.wallet().createSend(new Address(params, "muYPFNCv7KQEG2ZLM7Z3y96kJnNyXJ53wm"), CENT);
|
||||
Transaction tx2 = kit.wallet().createSend(new Address(params, "muYPFNCv7KQEG2ZLM7Z3y96kJnNyXJ53wm"), CENT.add(SATOSHI.multiply(10)));
|
||||
Transaction tx1 = kit.wallet().createSend(Address.fromBase58(params, "muYPFNCv7KQEG2ZLM7Z3y96kJnNyXJ53wm"), CENT);
|
||||
Transaction tx2 = kit.wallet().createSend(Address.fromBase58(params, "muYPFNCv7KQEG2ZLM7Z3y96kJnNyXJ53wm"), CENT.add(SATOSHI.multiply(10)));
|
||||
final Peer peer = kit.peerGroup().getConnectedPeers().get(0);
|
||||
peer.addEventListener(new AbstractPeerEventListener() {
|
||||
@Override
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ForwardingService {
|
||||
filePrefix = "forwarding-service";
|
||||
}
|
||||
// Parse the address given as the first parameter.
|
||||
forwardingAddress = new Address(params, args[0]);
|
||||
forwardingAddress = Address.fromBase58(params, args[0]);
|
||||
|
||||
// Start up a basic app using a class that automates some boilerplate.
|
||||
kit = new WalletAppKit(params, new File("."), filePrefix);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class PrivateKeys {
|
||||
// compressed pub key. Otherwise assume it's a raw key.
|
||||
ECKey key;
|
||||
if (args[0].length() == 51 || args[0].length() == 52) {
|
||||
DumpedPrivateKey dumpedPrivateKey = new DumpedPrivateKey(params, args[0]);
|
||||
DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, args[0]);
|
||||
key = dumpedPrivateKey.getKey();
|
||||
} else {
|
||||
BigInteger privKey = Base58.decodeToBigInteger(args[0]);
|
||||
@@ -51,7 +51,7 @@ public class PrivateKeys {
|
||||
}
|
||||
System.out.println("Address from private key is: " + key.toAddress(params).toString());
|
||||
// And the address ...
|
||||
Address destination = new Address(params, args[1]);
|
||||
Address destination = Address.fromBase58(params, args[1]);
|
||||
|
||||
// Import the private key to a fresh wallet.
|
||||
Wallet wallet = new Wallet(params);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SendRequest {
|
||||
|
||||
// To which address you want to send the coins?
|
||||
// The Address class represents a Bitcoin address.
|
||||
Address to = new Address(params, "mupBAFeT63hXfeeT4rnAUcpKHDkz1n4fdw");
|
||||
Address to = Address.fromBase58(params, "mupBAFeT63hXfeeT4rnAUcpKHDkz1n4fdw");
|
||||
|
||||
// There are different ways to create and publish a SendRequest. This is probably the easiest one.
|
||||
// Have a look at the code of the SendRequest class to see what's happening and what other options you have: https://bitcoinj.github.io/javadoc/0.11/com/google/bitcoin/core/Wallet.SendRequest.html
|
||||
|
||||
Reference in New Issue
Block a user