Skip to content

Conversation

@childhoodisend
Copy link

No description provided.

@childhoodisend childhoodisend changed the base branch from master to wallet-daemon August 27, 2025 14:49
Comment on lines 185 to 221
if !is_send_all {
// Calculating minimum set of UTXO's
let mut selected_utxos = Vec::new();
let mut accumulated_amount = 0u64;
let target_amount = amount + MAX_COMMISSION_GAP;

for utxo in sorted_utxos.iter() {
selected_utxos.push(utxo.clone());
accumulated_amount += utxo.amount;

// Stop
if accumulated_amount >= target_amount {
break;
}
if selected_utxos.len() >= MAX_UTXOS_FOR_SINGLE_TX {
log::warn!("Reached maximum UTXO limit ({}) to avoid mass overflow", MAX_UTXOS_FOR_SINGLE_TX);
break;
}
}

info!(
"Selected {} UTXOs out of {} total, covering {} sompi",
selected_utxos.len(),
sorted_utxos.len(),
accumulated_amount
);
sorted_utxos = selected_utxos;
} else {
if sorted_utxos.len() > MAX_UTXOS_FOR_SINGLE_TX {
log::info!(
"Too many UTXOs ({}), selecting {} largest UTXOs to avoid mass limit",
sorted_utxos.len(),
MAX_UTXOS_FOR_SINGLE_TX
);
sorted_utxos.truncate(MAX_UTXOS_FOR_SINGLE_TX);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think this logic is needed. generator handles mass internally and can issue multiple transactions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 182 to 183
let mut sorted_utxos = utxos;
sorted_utxos.sort_by(|a, b| b.amount.cmp(&a.amount));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorted_utxos.sort_unstable_by_key(|a|Reverse(a.amount))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


let utxos = account.clone().get_utxos(search_addresses, None).await.map_err(|err| Status::internal(err.to_string()))?;

info!("Found {} UTXOs with total value {} sompi", utxos.len(), utxos.iter().map(|utxo| utxo.amount).sum::<u64>());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value claculated below again. put the sum into some variable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

None // Search UTXO from all addresses in wallet
} else {
info!("Searching UTXOs in specified addresses: {:?}", from_addresses);
Some(from_addresses.clone())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary clone

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


tokio.workspace = true
tonic.workspace = true
log = "0.4.22"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use workspace deps

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@childhoodisend childhoodisend force-pushed the release/wallet-daemon-sign branch 2 times, most recently from e57c38f to 0eb670f Compare September 2, 2025 09:26
@childhoodisend childhoodisend force-pushed the release/wallet-daemon-sign branch from 0eb670f to d10a46e Compare September 2, 2025 09:34
@biryukovmaxim biryukovmaxim merged commit fc21b72 into aspectron:wallet-daemon Sep 2, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants