From 87fe0accd55a4e5d7be8e2e51abde5e4e6a64174 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 5 Nov 2020 16:46:01 +0200 Subject: [PATCH] Use broader matching on HWI wallet types (eg bitbox02_btconly) --- src/main/java/com/sparrowwallet/sparrow/io/Hwi.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java b/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java index 98cfb008..34e242a7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java @@ -535,7 +535,17 @@ public class Hwi { private static class DeviceModelDeserializer implements JsonDeserializer { @Override public WalletModel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - return WalletModel.valueOf(json.getAsJsonPrimitive().getAsString().toUpperCase()); + String modelStr = json.getAsJsonPrimitive().getAsString(); + try { + return WalletModel.valueOf(modelStr.toUpperCase()); + } catch(Exception e) { + for(WalletModel model : WalletModel.values()) { + if(modelStr.startsWith(model.getType())) { + return model; + } + } + } + throw new IllegalArgumentException("Could not determine wallet model for " + modelStr); } }