mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
Do a backup of the wallet before segwit migration
This commit is contained in:
parent
417daf5692
commit
87da2ae349
2 changed files with 18 additions and 0 deletions
|
@ -22,6 +22,7 @@ import bisq.core.btc.nodes.ProxySocketFactory;
|
|||
import bisq.core.btc.wallet.BisqRiskAnalysis;
|
||||
|
||||
import bisq.common.config.Config;
|
||||
import bisq.common.file.FileUtil;
|
||||
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.util.concurrent.*;
|
||||
|
@ -510,6 +511,14 @@ public class WalletConfig extends AbstractIdleService {
|
|||
// wait for the aesKey to be set and this method to be invoked again.
|
||||
return;
|
||||
}
|
||||
// Do a backup of the wallet
|
||||
File backup = new File(directory, WalletsSetup.PRE_SEGWIT_WALLET_BACKUP);
|
||||
try {
|
||||
FileUtil.copyFile(new File(directory, "bisq_BTC.wallet"), backup);
|
||||
} catch (IOException e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
|
||||
// Btc wallet does not have a native segwit keychain, we should add one.
|
||||
DeterministicSeed seed = wallet.getKeyChainSeed();
|
||||
if (aesKey != null) {
|
||||
|
|
|
@ -109,6 +109,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
@Slf4j
|
||||
public class WalletsSetup {
|
||||
|
||||
public static final String PRE_SEGWIT_WALLET_BACKUP = "pre_segwit_bisq_BTC.wallet.backup";
|
||||
|
||||
@Getter
|
||||
public final BooleanProperty walletsSetupFailed = new SimpleBooleanProperty();
|
||||
|
||||
|
@ -421,6 +423,13 @@ public class WalletsSetup {
|
|||
log.error("Could not delete directory " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
File segwitBackup = new File(walletDir, PRE_SEGWIT_WALLET_BACKUP);
|
||||
try {
|
||||
FileUtil.deleteFileIfExists(segwitBackup);
|
||||
} catch (IOException e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue