Skip to content

Commit 518cdab

Browse files
committed
Some fixes in the rust code, so that in can compile without Ledger support. Remove the useless "[features]" section from the root Cargo.toml. The tokio-console feature is now present in node-gui and node-daemon and they propagate it to utils/logging.
1 parent 56333f2 commit 518cdab

File tree

12 files changed

+47
-25
lines changed

12 files changed

+47
-25
lines changed

Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,6 @@ overflow-checks = true
335335
[profile.test.package.script]
336336
opt-level = 2
337337

338-
[features]
339-
tokio-console = []
340-
trezor = []
341-
ledger = []
342-
default = ["trezor", "ledger"]
343-
344338
[patch.crates-io]
345339
# Using fontconfig-parser v0.5.8 completely breaks UI in node-gui on Linux - most of the text disappears and the few
346340
# characters that remain have broken spacing, so we force the usage of v0.5.7 via "patch".

node-daemon/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ rpc-description = { path = "../rpc/description" }
1919

2020
assert_cmd.workspace = true
2121
expect-test.workspace = true
22+
23+
[features]
24+
tokio-console = ["utils/tokio-console"]

node-gui/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ tokio.workspace = true
3939
winres = "0.1"
4040

4141
[features]
42+
tokio-console = ["utils/tokio-console"]
4243
trezor = [
4344
"wallet-controller/trezor",
4445
"wallet-types/trezor",

node-gui/src/main_window/main_widget/tabs/wallet/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ impl Tab for WalletTab {
472472
let text = match node_state.wallets.get(&self.wallet_id) {
473473
Some(wallet_info) => match wallet_info.extra_info {
474474
wallet_controller::types::WalletExtraInfo::SoftwareWallet => "Software wallet",
475+
#[cfg(feature = "trezor")]
475476
wallet_controller::types::WalletExtraInfo::TrezorWallet { .. } => "Trezor wallet",
477+
#[cfg(feature = "ledger")]
476478
wallet_controller::types::WalletExtraInfo::LedgerWallet { .. } => "Ledger wallet",
477479
},
478480
None => "No wallet",

node-gui/src/main_window/main_widget/tabs/wallet/status_bar.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ const HORIZONTAL_PADDING: f32 = 10.;
3131

3232
#[allow(clippy::float_arithmetic)]
3333
pub fn estimate_status_bar_height(wallet_info: &WalletExtraInfo) -> f32 {
34+
#[cfg(any(feature = "trezor", feature = "ledger"))]
35+
let height_for_hw_wallet = TEXT_SIZE + 2. * VERTICAL_PADDING
36+
// For some reason, the status bar gets a bit of additional height.
37+
+ 4.;
38+
3439
match wallet_info {
3540
WalletExtraInfo::SoftwareWallet => 0.,
36-
WalletExtraInfo::TrezorWallet { .. } | WalletExtraInfo::LedgerWallet { .. } => {
37-
TEXT_SIZE + 2. * VERTICAL_PADDING
38-
// For some reason, the status bar gets a bit of additional height.
39-
+ 4.
40-
}
41+
#[cfg(feature = "trezor")]
42+
WalletExtraInfo::TrezorWallet { .. } => height_for_hw_wallet,
43+
#[cfg(feature = "ledger")]
44+
WalletExtraInfo::LedgerWallet { .. } => height_for_hw_wallet,
4145
}
4246
}
4347

utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ tempfile.workspace = true
4040
loom.workspace = true
4141

4242
[features]
43-
tokio-console = []
43+
tokio-console = ["logging/tokio-console"]
4444

4545
[[bench]]
4646
name = "benches"

wallet/Cargo.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,18 @@ tracing = { workspace = true }
7676

7777
[features]
7878
trezor = ["dep:trezor-client", "wallet-types/trezor"]
79-
enable-trezor-device-tests = []
80-
enable-ledger-device-tests = []
81-
# Note: currently this is used in certain external tests (in particular, in the bridge), so we only
82-
# allow it for regtest. TODO: it's better to have some regtest-specific options for the wallet,
83-
# similar to what we have for the node.
84-
use-deterministic-signatures-in-software-signer-for-regtest = []
79+
enable-trezor-device-tests = ["trezor"]
80+
8581
ledger = [
8682
"dep:ledger-lib",
8783
"dep:mintlayer-ledger-messages",
8884
"wallet-types/ledger",
8985
]
86+
enable-ledger-device-tests = ["ledger"]
87+
88+
# Note: currently this is used in certain external tests (in particular, in the bridge), so we only
89+
# allow it for regtest. TODO: it's better to have some regtest-specific options for the wallet,
90+
# similar to what we have for the node.
91+
use-deterministic-signatures-in-software-signer-for-regtest = []
92+
9093
default = ["trezor", "ledger"]

wallet/types/src/hw_data.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
use core::fmt;
17-
1816
use serialization::{Decode, Encode};
1917

2018
/// This is the data that will be stored in the wallet db.
@@ -56,8 +54,9 @@ pub enum LedgerModel {
5654
Unknown { usb_pid: Option<u16> },
5755
}
5856

59-
impl fmt::Display for LedgerModel {
60-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
57+
#[cfg(feature = "ledger")]
58+
impl std::fmt::Display for LedgerModel {
59+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6160
match self {
6261
LedgerModel::NanoS => write!(f, "Nano S"),
6362
LedgerModel::NanoSPlus => write!(f, "Nano S Plus"),

wallet/wallet-cli-commands/src/command_handler/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ where
281281
force_change_wallet_type,
282282
None,
283283
),
284+
#[cfg(feature = "trezor")]
284285
OpenWalletSubCommand::Trezor {
285286
wallet_path,
286287
encryption_password,
@@ -291,6 +292,7 @@ where
291292
false,
292293
Some(HardwareWalletType::Trezor { device_id }),
293294
),
295+
#[cfg(feature = "ledger")]
294296
OpenWalletSubCommand::Ledger {
295297
wallet_path,
296298
encryption_password,
@@ -372,6 +374,7 @@ where
372374
let info = self.non_empty_wallet().await?.wallet_info().await?;
373375
let wallet_description = match info.extra_info {
374376
WalletExtraInfo::SoftwareWallet => "This is a software wallet".to_owned(),
377+
#[cfg(feature = "trezor")]
375378
WalletExtraInfo::TrezorWallet {
376379
device_name,
377380
device_id,
@@ -382,6 +385,7 @@ where
382385
device_name, device_id, firmware_version
383386
)
384387
}
388+
#[cfg(feature = "ledger")]
385389
WalletExtraInfo::LedgerWallet { app_version, model } => format!(
386390
"This is a Ledger wallet; model: {model}, running app version {}",
387391
app_version

wallet/wallet-cli-commands/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub enum CreateWalletSubCommand {
8888
/// Cannot specify a mnemonic or passphrase here, the mnemonic must have been entered on
8989
/// the device during its initial setup and the passphrase will have to be entered every
9090
/// time the device is connected to the host machine.
91+
#[cfg(feature = "trezor")]
9192
#[command()]
9293
Trezor {
9394
/// File path of the wallet file
@@ -107,6 +108,7 @@ pub enum CreateWalletSubCommand {
107108
/// Cannot specify a mnemonic or passphrase here, both are managed on the device.
108109
/// Depending on its configuration, the passphrase may need to be entered manually
109110
/// each time or may be applied automatically after unlocking with a secondary PIN.
111+
#[cfg(feature = "ledger")]
110112
#[command()]
111113
Ledger {
112114
/// File path of the wallet file
@@ -134,11 +136,13 @@ impl CreateWalletSubCommand {
134136
)
135137
}
136138

139+
#[cfg(feature = "trezor")]
137140
Self::Trezor {
138141
wallet_path,
139142
device_id,
140143
} => (wallet_path, WalletTypeArgs::Trezor { device_id }),
141144

145+
#[cfg(feature = "ledger")]
142146
Self::Ledger { wallet_path } => (wallet_path, WalletTypeArgs::Ledger),
143147
}
144148
}
@@ -177,6 +181,7 @@ pub enum RecoverWalletSubCommand {
177181
/// Cannot specify a mnemonic or passphrase here, the mnemonic must have been entered on
178182
/// the device during its initial setup and the passphrase will have to be entered every
179183
/// time the device is connected to the host machine.
184+
#[cfg(feature = "trezor")]
180185
#[command()]
181186
Trezor {
182187
/// File path of the wallet file
@@ -196,6 +201,7 @@ pub enum RecoverWalletSubCommand {
196201
/// Cannot specify a mnemonic or passphrase here, both are managed on the device.
197202
/// Depending on its configuration, the passphrase may need to be entered manually
198203
/// each time or may be applied automatically after unlocking with a secondary PIN.
204+
#[cfg(feature = "ledger")]
199205
#[command()]
200206
Ledger {
201207
/// File path of the wallet file
@@ -223,11 +229,13 @@ impl RecoverWalletSubCommand {
223229
)
224230
}
225231

232+
#[cfg(feature = "trezor")]
226233
Self::Trezor {
227234
wallet_path,
228235
device_id,
229236
} => (wallet_path, WalletTypeArgs::Trezor { device_id }),
230237

238+
#[cfg(feature = "ledger")]
231239
Self::Ledger { wallet_path } => (wallet_path, WalletTypeArgs::Ledger),
232240
}
233241
}
@@ -247,6 +255,7 @@ pub enum OpenWalletSubCommand {
247255
force_change_wallet_type: bool,
248256
},
249257
/// (Beta) Open a wallet file that is connected to a Trezor hardware wallet.
258+
#[cfg(feature = "trezor")]
250259
#[command()]
251260
Trezor {
252261
/// File path of the wallet file
@@ -263,6 +272,7 @@ pub enum OpenWalletSubCommand {
263272
},
264273

265274
/// (Beta) Open a wallet file that is connected to a Ledger hardware wallet.
275+
#[cfg(feature = "ledger")]
266276
#[command()]
267277
Ledger {
268278
/// File path of the wallet file
@@ -1301,6 +1311,7 @@ pub trait ChoiceMenu: DynClone + Debug {
13011311
}
13021312
dyn_clone::clone_trait_object!(ChoiceMenu);
13031313

1314+
// TODO: this is Trezor-specific, so it should be either renamed or generalized.
13041315
#[derive(Debug, Clone)]
13051316
pub struct CreateWalletDeviceSelectMenu {
13061317
available_devices: Vec<FoundDevice>,
@@ -1354,6 +1365,7 @@ impl ChoiceMenu for CreateWalletDeviceSelectMenu {
13541365
}
13551366
}
13561367

1368+
// TODO: this is Trezor-specific, so it should be either renamed or generalized.
13571369
#[derive(Debug, Clone)]
13581370
pub struct OpenWalletDeviceSelectMenu {
13591371
available_devices: Vec<FoundDevice>,

0 commit comments

Comments
 (0)