From dfed0ef54acd566cb8c375157a23c4611043bd8d Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 30 May 2023 23:56:27 +0200 Subject: [PATCH] bitbox02: display amounts in sats if Electrum's base unit is sat The BitBox02 has the ability to display all amounts in sats instead of BTC. This was introduced in v9.13.0. If Electrum is configured to show sats, we propagate this config to the BitBox02. This is backwards compatible: users with older firmware will see the values in BTC regardless of the config. --- electrum/plugins/bitbox02/bitbox02.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py index 1095c39da..320dd0e16 100644 --- a/electrum/plugins/bitbox02/bitbox02.py +++ b/electrum/plugins/bitbox02/bitbox02.py @@ -510,6 +510,12 @@ class BitBox02Client(HardwareClientBase): ) keypath_account = full_path[:-2] + + format_unit = bitbox02.btc.BTCSignInitRequest.FormatUnit.DEFAULT + # Base unit is configured to be "sat": + if self.config.get_decimal_point() == 0: + format_unit = bitbox02.btc.BTCSignInitRequest.FormatUnit.SAT + sigs = self.bitbox02_device.btc_sign( coin, [bitbox02.btc.BTCScriptConfigWithKeypath( @@ -520,6 +526,7 @@ class BitBox02Client(HardwareClientBase): outputs=outputs, locktime=tx.locktime, version=tx.version, + format_unit=format_unit, ) # Fill signatures