mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-20 10:12:19 +01:00
Wallet: allow customization of the wallet type that is deserialized. Makes subclassing Wallet more useful.
This commit is contained in:
parent
b374ba5108
commit
d2837e8ea9
@ -74,8 +74,24 @@ public class WalletProtobufSerializer {
|
||||
|
||||
private boolean requireMandatoryExtensions = true;
|
||||
|
||||
public interface WalletFactory {
|
||||
Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup);
|
||||
}
|
||||
|
||||
private final WalletFactory factory;
|
||||
|
||||
public WalletProtobufSerializer() {
|
||||
this(new WalletFactory() {
|
||||
@Override
|
||||
public Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup) {
|
||||
return new Wallet(params, keyChainGroup);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public WalletProtobufSerializer(WalletFactory factory) {
|
||||
txMap = new HashMap<ByteString, Transaction>();
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -374,7 +390,7 @@ public class WalletProtobufSerializer {
|
||||
} else {
|
||||
chain = KeyChainGroup.fromProtobufUnencrypted(walletProto.getKeyList());
|
||||
}
|
||||
Wallet wallet = new Wallet(params, chain);
|
||||
Wallet wallet = factory.create(params, chain);
|
||||
|
||||
List<Script> scripts = Lists.newArrayList();
|
||||
for (Protos.Script protoScript : walletProto.getWatchedScriptList()) {
|
||||
|
Loading…
Reference in New Issue
Block a user