public Builder mergeFrom(com.openwallet.core.protos.Protos.Wallet other) { if (other == com.openwallet.core.protos.Protos.Wallet.getDefaultInstance()) return this; if (other.hasVersion()) { setVersion(other.getVersion());
private static Protos.Wallet updateV2toV3Proto(Protos.Wallet walletProto) { checkState(walletProto.getVersion() < 3, "Can update only from version < 3"); Protos.Wallet.Builder b = walletProto.toBuilder(); for (int i = 0; i < b.getPocketsCount(); i++) { Protos.WalletPocket.Builder account = b.getPocketsBuilder(i); // pre v2 wallets were saving the coin name in the description account.clearDescription(); } return b.build(); }
private static Protos.Wallet updateV1toV2Proto(Protos.Wallet walletProto) { checkState(walletProto.getVersion() < 2, "Can update only from version < 2"); // Purge blockchain data if wallet is bigger than 2mb boolean purgeBlockchain = walletProto.getSerializedSize() > 200000; Protos.Wallet.Builder b = walletProto.toBuilder(); for (int i = 0; i < b.getPocketsCount(); i++) { Protos.WalletPocket.Builder account = b.getPocketsBuilder(i); // Purge blockchain data if needed if (purgeBlockchain) { account.clearAddressStatus(); account.clearLastSeenBlockHash(); account.clearLastSeenBlockHeight(); account.clearLastSeenBlockTimeSecs(); account.clearTransaction(); } // Update coin type ids if (account.getNetworkIdentifier().equals("dogecoindark.main")) { account.setNetworkIdentifier("verge.main"); b.setPockets(i, account); } if (account.getNetworkIdentifier().equals("darkcoin.main")) { account.setNetworkIdentifier("dash.main"); b.setPockets(i, account); } } return b.build(); }
if (walletProto.getVersion() > 3) throw new UnreadableWalletException.FutureVersion(); wallet.setVersion(walletProto.getVersion());
private static Protos.Wallet applyProtoUpdates(Protos.Wallet walletProto) { if (walletProto.getVersion() < 2) { walletProto = updateV1toV2Proto(walletProto); } if (walletProto.getVersion() < 3) { walletProto = updateV2toV3Proto(walletProto); } return walletProto; }