Skip to content

Commit

Permalink
fix collateral count
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Jan 20, 2025
1 parent ec6a06f commit 4251c94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Binary file modified src/core/libs/lucid_core/pkg/lucid_core_bg.wasm
Binary file not shown.
5 changes: 3 additions & 2 deletions src/core/libs/lucid_core/src/instruction_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,9 +895,9 @@ impl InstructionBuilder {
});

loop {
let collateral_count = available_collateral.len() - self.selection.len();
let collateral_count = self.collateral.as_ref().map_or(0, |c| c.len()) as u16;

if collateral_count as u16 >= self.protocol_parameters.max_collateral_inputs {
if collateral_count >= self.protocol_parameters.max_collateral_inputs {
return Err(CoreError::msg(format!(
"Reached maximum collateral inputs, {} allowed",
self.protocol_parameters.max_collateral_inputs
Expand All @@ -907,6 +907,7 @@ impl InstructionBuilder {
let utxo = available_collateral
.pop()
.ok_or(CoreError::msg("Collateral balance insufficient"))?;

self.add_collateral(utxo)?;

if adjust_collateral(self).is_ok() {
Expand Down

0 comments on commit 4251c94

Please sign in to comment.