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

Set invoice labels before sending #996

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading