Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
Set invoice labels before sending
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 26, 2024
1 parent 55a40fd commit f9fe553
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,10 @@ impl<S: MutinyStorage> MutinyWallet<S> {
.or(amt_sats.map(|x| x * 1_000))
.ok_or(MutinyError::InvoiceInvalid)?;

// set labels now, need to set it before in case the payment times out
self.storage
.set_invoice_labels(inv.clone(), labels.clone())?;

// Try each federation first
let federation_ids = self.list_federation_ids().await?;
let mut last_federation_error = None;
Expand All @@ -1012,7 +1016,6 @@ impl<S: MutinyStorage> MutinyWallet<S> {
.await;
match payment_result {
Ok(r) => {
self.storage.set_invoice_labels(inv.clone(), labels)?;
return Ok(r);
}
Err(e) => match e {
Expand Down Expand Up @@ -1050,12 +1053,9 @@ impl<S: MutinyStorage> MutinyWallet<S> {
.sum::<u64>()
> 0
{
let res = self
.node_manager
.pay_invoice(None, inv, amt_sats, labels.clone())
.await?;
self.storage.set_invoice_labels(inv.clone(), labels)?;
Ok(res)
self.node_manager
.pay_invoice(None, inv, amt_sats, labels)
.await
} else {
Err(last_federation_error.unwrap_or(MutinyError::InsufficientBalance))
}
Expand Down

0 comments on commit f9fe553

Please sign in to comment.