Skip to content

Commit

Permalink
f Don't update but insert failed payments
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Apr 6, 2023
1 parent 096c789 commit 3380625
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,13 +1040,16 @@ impl Node {
Err(payment::PaymentError::Sending(e)) => {
log_error!(self.logger, "Failed to send payment: {:?}", e);

self.payment_store.update(
&payment_hash,
None,
None,
None,
Some(PaymentStatus::Failed),
)?;
let payment = PaymentDetails {
preimage: None,
hash: payment_hash,
secret: payment_secret,
amount_msat: invoice.amount_milli_satoshis(),
direction: PaymentDirection::Outbound,
status: PaymentStatus::Failed,
};
self.payment_store.insert(payment)?;

Err(Error::PaymentFailed)
}
}
Expand Down Expand Up @@ -1120,9 +1123,9 @@ impl Node {
hash: payment_hash,
preimage: None,
secret: payment_secret,
amount_msat: Some(amount_msat),
direction: PaymentDirection::Outbound,
status: PaymentStatus::Pending,
amount_msat: Some(amount_msat),
};
self.payment_store.insert(payment)?;

Expand All @@ -1135,13 +1138,16 @@ impl Node {
Err(payment::PaymentError::Sending(e)) => {
log_error!(self.logger, "Failed to send payment: {:?}", e);

self.payment_store.update(
&payment_hash,
None,
None,
None,
Some(PaymentStatus::Failed),
)?;
let payment = PaymentDetails {
hash: payment_hash,
preimage: None,
secret: payment_secret,
amount_msat: Some(amount_msat),
direction: PaymentDirection::Outbound,
status: PaymentStatus::Failed,
};
self.payment_store.insert(payment)?;

Err(Error::PaymentFailed)
}
}
Expand Down

0 comments on commit 3380625

Please sign in to comment.