Skip to content

Commit 3380625

Browse files
committed
f Don't update but insert failed payments
1 parent 096c789 commit 3380625

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/lib.rs

+21-15
Original file line numberDiff line numberDiff line change
@@ -1040,13 +1040,16 @@ impl Node {
10401040
Err(payment::PaymentError::Sending(e)) => {
10411041
log_error!(self.logger, "Failed to send payment: {:?}", e);
10421042

1043-
self.payment_store.update(
1044-
&payment_hash,
1045-
None,
1046-
None,
1047-
None,
1048-
Some(PaymentStatus::Failed),
1049-
)?;
1043+
let payment = PaymentDetails {
1044+
preimage: None,
1045+
hash: payment_hash,
1046+
secret: payment_secret,
1047+
amount_msat: invoice.amount_milli_satoshis(),
1048+
direction: PaymentDirection::Outbound,
1049+
status: PaymentStatus::Failed,
1050+
};
1051+
self.payment_store.insert(payment)?;
1052+
10501053
Err(Error::PaymentFailed)
10511054
}
10521055
}
@@ -1120,9 +1123,9 @@ impl Node {
11201123
hash: payment_hash,
11211124
preimage: None,
11221125
secret: payment_secret,
1126+
amount_msat: Some(amount_msat),
11231127
direction: PaymentDirection::Outbound,
11241128
status: PaymentStatus::Pending,
1125-
amount_msat: Some(amount_msat),
11261129
};
11271130
self.payment_store.insert(payment)?;
11281131

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

1138-
self.payment_store.update(
1139-
&payment_hash,
1140-
None,
1141-
None,
1142-
None,
1143-
Some(PaymentStatus::Failed),
1144-
)?;
1141+
let payment = PaymentDetails {
1142+
hash: payment_hash,
1143+
preimage: None,
1144+
secret: payment_secret,
1145+
amount_msat: Some(amount_msat),
1146+
direction: PaymentDirection::Outbound,
1147+
status: PaymentStatus::Failed,
1148+
};
1149+
self.payment_store.insert(payment)?;
1150+
11451151
Err(Error::PaymentFailed)
11461152
}
11471153
}

0 commit comments

Comments
 (0)