Use broader matching on HWI wallet types (eg bitbox02_btconly)

This commit is contained in:
Craig Raw 2020-11-05 16:46:01 +02:00
parent 8d413e839c
commit 87fe0accd5

View file

@ -535,7 +535,17 @@ public class Hwi {
private static class DeviceModelDeserializer implements JsonDeserializer<WalletModel> { private static class DeviceModelDeserializer implements JsonDeserializer<WalletModel> {
@Override @Override
public WalletModel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { 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);
} }
} }