mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 15:22:16 +00:00
Tweaks to allow wallet subclasses to add their own extensions in their c'tors.
This commit is contained in:
parent
748ff6fc8e
commit
e4af9a673f
@ -459,6 +459,9 @@ public class WalletProtobufSerializer {
|
|||||||
final Map<String, WalletExtension> extensions = new HashMap<String, WalletExtension>();
|
final Map<String, WalletExtension> extensions = new HashMap<String, WalletExtension>();
|
||||||
for (WalletExtension e : extensionsList)
|
for (WalletExtension e : extensionsList)
|
||||||
extensions.put(e.getWalletExtensionID(), e);
|
extensions.put(e.getWalletExtensionID(), e);
|
||||||
|
// The Wallet object, if subclassed, might have added some extensions to itself already. In that case, don't
|
||||||
|
// expect them to be passed in, just fetch them here and don't re-add.
|
||||||
|
extensions.putAll(wallet.getExtensions());
|
||||||
for (Protos.Extension extProto : walletProto.getExtensionList()) {
|
for (Protos.Extension extProto : walletProto.getExtensionList()) {
|
||||||
String id = extProto.getId();
|
String id = extProto.getId();
|
||||||
WalletExtension extension = extensions.get(id);
|
WalletExtension extension = extensions.get(id);
|
||||||
@ -473,7 +476,7 @@ public class WalletProtobufSerializer {
|
|||||||
log.info("Loading wallet extension {}", id);
|
log.info("Loading wallet extension {}", id);
|
||||||
try {
|
try {
|
||||||
extension.deserializeWalletExtension(wallet, extProto.getData().toByteArray());
|
extension.deserializeWalletExtension(wallet, extProto.getData().toByteArray());
|
||||||
wallet.addExtension(extension);
|
wallet.addOrGetExistingExtension(extension);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (extProto.getMandatory() && requireMandatoryExtensions)
|
if (extProto.getMandatory() && requireMandatoryExtensions)
|
||||||
throw new UnreadableWalletException("Could not parse mandatory extension in wallet: " + id);
|
throw new UnreadableWalletException("Could not parse mandatory extension in wallet: " + id);
|
||||||
|
Loading…
Reference in New Issue
Block a user