Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Sep 20, 2023
1 parent d244b82 commit a90fa7c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ impl InputSelection {
self.outputs.as_slice(),
self.burn.as_ref(),
);
// PANIC: safe to unwrap as treasury outputs can't be used as input.
let required_address = input
.output
.required_and_unlocked_address(self.timestamp, input.output_id(), alias_transition)
.unwrap()
.0;
if remainder_address == required_address {
let required_address =
input
.output
.required_and_unlocked_address(self.timestamp, input.output_id(), alias_transition);

if matches!(required_address, Ok(a) if a.0 == remainder_address) {
return Some((remainder_address, input.chain));
}
}
Expand Down
34 changes: 17 additions & 17 deletions sdk/src/client/secret/ledger_nano.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,24 +295,24 @@ impl SecretManage for LedgerSecretManager {
.map_err(Error::from)?;
} else {
// figure out the remainder address and bip32 index (if there is one)
#[allow(clippy::option_if_let_else)]
let (remainder_address, remainder_bip32): (Option<&Address>, LedgerBIP32Index) =
prepared_transaction.remainder.as_ref().map_or_else(
|| (None, LedgerBIP32Index::default()),
|a| {
a.chain.map_or_else(
|| (None, LedgerBIP32Index::default()),
|chain| {
(
Some(&a.address),
LedgerBIP32Index {
bip32_change: chain.change.harden().into(),
bip32_index: chain.address_index.harden().into(),
},
)
},
)
},
);
match &prepared_transaction.remainder {
Some(a) => {
if let Some(chain) = a.chain {
(
Some(&a.address),
LedgerBIP32Index {
bip32_change: chain.change.harden().into(),
bip32_index: chain.address_index.harden().into(),
},
)
} else {
(None, LedgerBIP32Index::default())
}
}
None => (None, LedgerBIP32Index::default()),
};

let mut remainder_index = 0u16;
if let Some(remainder_address) = remainder_address {
Expand Down

0 comments on commit a90fa7c

Please sign in to comment.