Wallet: make keychain private and add a remove method.

This commit is contained in:
Mike Hearn
2013-04-22 13:45:38 +02:00
parent 5112a94955
commit f88bdc5fe3
7 changed files with 31 additions and 20 deletions

View File

@@ -57,7 +57,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class PingService {
private final PeerGroup peerGroup;
private final BlockChain chain;
private final BlockStore blockStore;
private final File walletFile;
@@ -77,7 +76,7 @@ public class PingService {
w = Wallet.loadFromFile(walletFile);
} catch (IOException e) {
w = new Wallet(params);
w.keychain.add(new ECKey());
w.addKey(new ECKey());
w.saveToFile(walletFile);
}
final Wallet wallet = w;
@@ -95,7 +94,7 @@ public class PingService {
CheckpointManager.checkpoint(params, stream, blockStore, key.getCreationTimeSeconds());
}
}
chain = new BlockChain(params, wallet, blockStore);
BlockChain chain = new BlockChain(params, wallet, blockStore);
// Connect to the localhost node. One minute timeout since we won't try any other peers
System.out.println("Connecting ...");
peerGroup = new PeerGroup(params, chain);

View File

@@ -151,7 +151,7 @@ public class ToyWallet {
wallet.saveToFile(walletFile);
freshWallet = true;
}
System.out.println("Send to: " + wallet.keychain.get(0).toAddress(params));
System.out.println("Send to: " + wallet.getKeys().get(0).toAddress(params));
System.out.println(wallet);
wallet.autosaveToFile(walletFile, 500, TimeUnit.MILLISECONDS, null);
@@ -238,7 +238,7 @@ public class ToyWallet {
}
private void setupWindow(JFrame window) {
final Address address = wallet.keychain.get(0).toAddress(params);
final Address address = wallet.getKeys().get(0).toAddress(params);
JLabel instructions = new JLabel(
"<html>Broadcast transactions appear below. Watch them gain confidence.<br>" +
"Send coins to: <b>" + address + "</b> <i>(click to place on clipboard)</i>");