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

Commit f9fe553

Browse files
committed
Set invoice labels before sending
1 parent 55a40fd commit f9fe553

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mutiny-core/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,10 @@ impl<S: MutinyStorage> MutinyWallet<S> {
998998
.or(amt_sats.map(|x| x * 1_000))
999999
.ok_or(MutinyError::InvoiceInvalid)?;
10001000

1001+
// set labels now, need to set it before in case the payment times out
1002+
self.storage
1003+
.set_invoice_labels(inv.clone(), labels.clone())?;
1004+
10011005
// Try each federation first
10021006
let federation_ids = self.list_federation_ids().await?;
10031007
let mut last_federation_error = None;
@@ -1012,7 +1016,6 @@ impl<S: MutinyStorage> MutinyWallet<S> {
10121016
.await;
10131017
match payment_result {
10141018
Ok(r) => {
1015-
self.storage.set_invoice_labels(inv.clone(), labels)?;
10161019
return Ok(r);
10171020
}
10181021
Err(e) => match e {
@@ -1050,12 +1053,9 @@ impl<S: MutinyStorage> MutinyWallet<S> {
10501053
.sum::<u64>()
10511054
> 0
10521055
{
1053-
let res = self
1054-
.node_manager
1055-
.pay_invoice(None, inv, amt_sats, labels.clone())
1056-
.await?;
1057-
self.storage.set_invoice_labels(inv.clone(), labels)?;
1058-
Ok(res)
1056+
self.node_manager
1057+
.pay_invoice(None, inv, amt_sats, labels)
1058+
.await
10591059
} else {
10601060
Err(last_federation_error.unwrap_or(MutinyError::InsufficientBalance))
10611061
}

0 commit comments

Comments
 (0)