Skip to content

Commit

Permalink
Merge pull request #269 from RGB-WG/fix/noinputs
Browse files Browse the repository at this point in the history
Detect insufficient state early
  • Loading branch information
dr-orlovsky authored Jan 13, 2025
2 parents 55a814a + b4f54bf commit 4339095
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ where Self::Descr: DescriptorRgb<K>
.collect();
state.sort_by_key(|(sum, _, _)| *sum);
let mut sum = Amount::ZERO;
state
let selection = state
.iter()
.rev()
.take_while(|(val, _, _)| {
Expand All @@ -199,7 +199,12 @@ where Self::Descr: DescriptorRgb<K>
}
})
.map(|(_, seal, _)| *seal)
.collect::<BTreeSet<_>>()
.collect::<BTreeSet<_>>();
if sum < amount {
bset![]
} else {
selection
}
}
InvoiceState::Data(NonFungible::RGB21(allocation)) => {
let data_state = DataState::from(allocation);
Expand All @@ -220,6 +225,9 @@ where Self::Descr: DescriptorRgb<K>
)]
}
};
if prev_outputs.is_empty() {
return Err(CompositionError::InsufficientState);
}
let prev_outpoints = prev_outputs
.iter()
// TODO: Support liquid
Expand Down

0 comments on commit 4339095

Please sign in to comment.