Save-and-load new wallet with extensions in WalletAppKit.

Currently the only guaranteed way of passing the containing wallet to an
extension is during deserialization. Therefore every new wallet in WalletAppKit
is saved and then loaded before use, to ensure correct initialization of extensions.
This commit is contained in:
Michael Bell
2015-06-02 16:30:23 +01:00
committed by Mike Hearn
parent 5dd72ed0f7
commit 36ba209a24

View File

@@ -369,7 +369,12 @@ public class WalletAppKit extends AbstractIdleService {
for (WalletExtension e : provideWalletExtensions()) {
wallet.addExtension(e);
}
// Currently the only way we can be sure that an extension is aware of its containing wallet is by
// deserializing the extension (see WalletExtension#deserializeWalletExtension(Wallet, byte[]))
// Hence, we first save and then load wallet to ensure any extensions are correctly initialized.
wallet.saveToFile(vWalletFile);
wallet = loadWallet(false);
}
if (useAutoSave) wallet.autosaveToFile(vWalletFile, 5, TimeUnit.SECONDS, null);