Skip to content

Commit 9bf457c

Browse files
committed
Set defaults in HW device json up-front
1 parent 871f427 commit 9bf457c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/signer.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ namespace sdk {
225225
// FIXME: Remove this function when the wallets are upgraded to use "supports_ae_protocol"
226226
nlohmann::json ret = hw_device;
227227
json_rename_key(ret, "ae_protocol_support_level", "supports_ae_protocol");
228+
const bool overwrite_null = true;
229+
json_add_if_missing(ret, "supports_low_r", false, overwrite_null);
230+
json_add_if_missing(ret, "supports_arbitrary_scripts", false, overwrite_null);
231+
json_add_if_missing(ret, "supports_liquid", liquid_support_level::none, overwrite_null);
232+
json_add_if_missing(ret, "supports_ae_protocol", ae_protocol_support_level::none, overwrite_null);
228233
return ret;
229234
}
230235

@@ -241,19 +246,22 @@ namespace sdk {
241246
if (get_ae_protocol_support() != ae_protocol_support_level::none) {
242247
return false; // Always use AE if the HW supports it
243248
}
244-
return json_get_value(m_hw_device, "supports_low_r", false);
249+
return m_hw_device["supports_low_r"];
245250
}
251+
246252
bool hardware_signer::supports_arbitrary_scripts() const
247253
{
248-
return json_get_value(m_hw_device, "supports_arbitrary_scripts", false);
254+
return m_hw_device["supports_arbitrary_scripts"];
249255
}
256+
250257
liquid_support_level hardware_signer::get_liquid_support() const
251258
{
252-
return json_get_value(m_hw_device, "supports_liquid", liquid_support_level::none);
259+
return m_hw_device["supports_liquid"];
253260
}
261+
254262
ae_protocol_support_level hardware_signer::get_ae_protocol_support() const
255263
{
256-
return json_get_value(m_hw_device, "supports_ae_protocol", ae_protocol_support_level::none);
264+
return m_hw_device["supports_ae_protocol"];
257265
}
258266

259267
bool hardware_signer::is_hw_device() const { return true; }

0 commit comments

Comments
 (0)