mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 21:47:18 +00:00
Introduce UnreadableWalletException and make WalletProtobufSerializer throw it in all cases where there's a problem reading the wallet. Resolves issue 415. Resolves issue 416.
This commit is contained in:
@@ -24,13 +24,13 @@ import com.google.bitcoin.params.RegTestParams;
|
||||
import com.google.bitcoin.params.TestNet3Params;
|
||||
import com.google.bitcoin.store.BlockStore;
|
||||
import com.google.bitcoin.store.SPVBlockStore;
|
||||
import com.google.bitcoin.store.UnreadableWalletException;
|
||||
import com.google.bitcoin.utils.BriefLogFormatter;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetAddress;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class PingService {
|
||||
// Wipe the wallet if the chain file was deleted.
|
||||
if (walletFile.exists() && chainFile.exists())
|
||||
w = Wallet.loadFromFile(walletFile);
|
||||
} catch (IOException e) {
|
||||
} catch (UnreadableWalletException e) {
|
||||
System.err.println("Couldn't load wallet: " + e);
|
||||
// Fall through.
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.bitcoin.params.MainNetParams;
|
||||
import com.google.bitcoin.params.TestNet3Params;
|
||||
import com.google.bitcoin.store.H2FullPrunedBlockStore;
|
||||
import com.google.bitcoin.store.SPVBlockStore;
|
||||
import com.google.bitcoin.store.UnreadableWalletException;
|
||||
import com.google.bitcoin.utils.BriefLogFormatter;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
@@ -34,7 +35,6 @@ import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
@@ -125,7 +125,7 @@ public class ToyWallet {
|
||||
walletFile = new File("toy.wallet");
|
||||
try {
|
||||
wallet = Wallet.loadFromFile(walletFile);
|
||||
} catch (IOException e) {
|
||||
} catch (UnreadableWalletException e) {
|
||||
wallet = new Wallet(params);
|
||||
|
||||
// Allow user to specify the first key on the command line as:
|
||||
|
||||
Reference in New Issue
Block a user