Commit 5cbcbf41 authored by Andreas Schildbach's avatar Andreas Schildbach

Upgrade existing unencrypted wallets to receive to and spend from Bech32 addresses (native SegWit).

For encrypted wallets, bitcoinj is currently missing the ability to upgrade them without providing the encryption key.
We'll defer the upgrade until later.
parent 0507d617
......@@ -62,7 +62,7 @@ public final class Constants {
* The type of Bitcoin addresses to upgrade the current wallet to: {@link Script.ScriptType#P2PKH} for classic
* Base58, {@link Script.ScriptType#P2WPKH} for segwit Bech32.
public static final Script.ScriptType UPGRADE_OUTPUT_SCRIPT_TYPE = Script.ScriptType.P2PKH;
public static final Script.ScriptType UPGRADE_OUTPUT_SCRIPT_TYPE = Script.ScriptType.P2WPKH;
/** Enable switch for synching of the blockchain */
public static final boolean ENABLE_BLOCKCHAIN_SYNC = true;
......@@ -261,7 +261,7 @@ public class WalletApplication extends Application {
public void replaceWallet(final Wallet newWallet) {
if (newWallet.isDeterministicUpgradeRequired(Constants.UPGRADE_OUTPUT_SCRIPT_TYPE))
if (newWallet.isDeterministicUpgradeRequired(Constants.UPGRADE_OUTPUT_SCRIPT_TYPE) && !newWallet.isEncrypted())
newWallet.upgradeToDeterministic(Constants.UPGRADE_OUTPUT_SCRIPT_TYPE, null);
......@@ -76,7 +76,7 @@ public final class UpgradeWalletService extends IntentService {
final Wallet wallet = application.getWallet();
// Maybe upgrade wallet from basic to deterministic
if (wallet.isDeterministicUpgradeRequired(Constants.UPGRADE_OUTPUT_SCRIPT_TYPE))
if (wallet.isDeterministicUpgradeRequired(Constants.UPGRADE_OUTPUT_SCRIPT_TYPE) && !wallet.isEncrypted())
wallet.upgradeToDeterministic(Constants.UPGRADE_OUTPUT_SCRIPT_TYPE, null);
// Maybe upgrade wallet to secure chain
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment