Refactor balance check for alias and foundry output
@@ -34,7 +34,10 @@ impl AccountHandle {
for output_data in account.unspent_outputs.values() {
// Check if output is from the network we're currently connected to
- if output_data.network_id == network_id {
+ if output_data.network_id != network_id {
+ continue;
+ }
+
// Add alias and foundry outputs here because they can't have a [`StorageDepositReturnUnlockCondition`]
// or time related unlock conditions
match &output_data.output {
@@ -43,9 +46,7 @@ impl AccountHandle {
let alias_id = output.alias_id().or_from_output_id(output_data.output_id);
aliases.push(alias_id);
}
- _ => {}
- }
-
+ _ => {
// If there is only an [AddressUnlockCondition], then we can spend the output at any time without
// restrictions
if output_data
@@ -89,8 +90,8 @@ impl AccountHandle {
}
// For outputs that are expired or have a timelock unlock condition, but no expiration unlock
- // condition and we then can unlock them, then they can never be not available for us anymore and
- // should be added to the balance
+ // condition and we then can unlock them, then they can never be not available for us anymore
+ // and should be added to the balance
if output_can_be_unlocked_now {
// check if output can be unlocked always from now on, in that case it should be added to
// the total amount
@@ -146,6 +147,7 @@ impl AccountHandle {
}
}
}
+ }
// for `available` get locked_outputs, sum outputs amount and subtract from total_amount
log::debug!("[BALANCE] locked outputs: {:#?}", account.locked_outputs);
