From bd0f3fe4c17cb0166da057a4ad67bf7646ff42f3 Mon Sep 17 00:00:00 2001 From: Justas Date: Fri, 12 Jun 2015 10:21:45 +0300 Subject: [PATCH] Allowed wallet size increased from 64MB to 512MB --- .../java/org/bitcoinj/store/WalletProtobufSerializer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/bitcoinj/store/WalletProtobufSerializer.java b/core/src/main/java/org/bitcoinj/store/WalletProtobufSerializer.java index d18af713..f201dcf4 100644 --- a/core/src/main/java/org/bitcoinj/store/WalletProtobufSerializer.java +++ b/core/src/main/java/org/bitcoinj/store/WalletProtobufSerializer.java @@ -76,6 +76,8 @@ public class WalletProtobufSerializer { private static final Logger log = LoggerFactory.getLogger(WalletProtobufSerializer.class); /** Current version used for serializing wallets. A version higher than this is considered from the future. */ public static final int CURRENT_WALLET_VERSION = Protos.Wallet.getDefaultInstance().getVersion(); + // 512 MB + private static final int WALLET_SIZE_LIMIT = 512 * 1024 * 1024; // Used for de-serialization protected Map txMap; @@ -541,7 +543,9 @@ public class WalletProtobufSerializer { * wallet file format itself. */ public static Protos.Wallet parseToProto(InputStream input) throws IOException { - return Protos.Wallet.parseFrom(input); + CodedInputStream codedInput = CodedInputStream.newInstance(input); + codedInput.setSizeLimit(WALLET_SIZE_LIMIT); + return Protos.Wallet.parseFrom(codedInput); } private void readTransaction(Protos.Transaction txProto, NetworkParameters params) throws UnreadableWalletException {