Skip to content

Commit

Permalink
Fix MissingInputWithEd25519Address error (#2207)
Browse files Browse the repository at this point in the history
* logs

* add log

* Insert mana requirement in first position

* rework amount requirement so it doesn't try to get the allotment before all new requirements are complete

* Remove logs

---------

Co-authored-by: Alex Coats <[email protected]>
  • Loading branch information
thibault-martinez and Alex Coats authored Mar 27, 2024
1 parent 254832d commit 1101c72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) fn sdruc_not_expired(

impl TransactionBuilder {
pub(crate) fn fulfill_amount_requirement(&mut self) -> Result<(), TransactionBuilderError> {
let (mut input_amount, mut output_amount) = self.amount_balance()?;
let (input_amount, output_amount) = self.amount_balance()?;
if input_amount >= output_amount {
log::debug!("Amount requirement already fulfilled");
return Ok(());
Expand All @@ -43,22 +43,11 @@ impl TransactionBuilder {
if !self.allow_additional_input_selection {
return Err(TransactionBuilderError::AdditionalInputsRequired(Requirement::Amount));
}
if self.available_inputs.is_empty() {
return Err(TransactionBuilderError::InsufficientAmount {
found: input_amount,
required: output_amount,
});
}

while let Some(input) = self.next_input_for_amount(output_amount - input_amount, self.latest_slot_commitment_id)
{
if let Some(input) = self.next_input_for_amount(output_amount - input_amount, self.latest_slot_commitment_id) {
self.requirements.push(Requirement::Amount);
self.select_input(input)?;
(input_amount, output_amount) = self.amount_balance()?;
if input_amount >= output_amount {
break;
}
}
if output_amount > input_amount {
} else {
return Err(TransactionBuilderError::InsufficientAmount {
found: input_amount,
required: output_amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl TransactionBuilder {
should_recalculate |= self.get_inputs_for_mana_balance()?;

if should_recalculate && !self.requirements.contains(&Requirement::Mana) {
self.requirements.push(Requirement::Mana);
self.requirements.insert(0, Requirement::Mana);
}

Ok(())
Expand Down

0 comments on commit 1101c72

Please sign in to comment.