Skip to content

Commit

Permalink
fix invoice status
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Dec 5, 2024
1 parent 5c9888b commit 658123a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,8 @@ where
.apply_remove_tlc_operation(state, remove_tlc)
.await
.map_err(|e| {
error!("Error handling RemoveTlc command: {:?}", e);
debug!("error happened in apply_remove_tlc_operation: {:?}", e);
error!("Error handling apply_remove_tlc_operation: {:?}", e);
});
}
}
Expand Down Expand Up @@ -740,10 +741,18 @@ where
CkbInvoiceStatus::Paid => {
unreachable!("Paid invoice shold not be paid again");
}
_ => {}
_ => {
self.store
.update_invoice_status(&tlc.payment_hash, CkbInvoiceStatus::Paid)
.expect("update invoice status error");
}
}
}

debug!(
"register remove reason: {:?} with reason: {:?}",
tlc.tlc_id, remove_reason
);
self.register_tlc_remove(state, tlc.tlc_id, remove_reason);
}

Expand Down Expand Up @@ -903,15 +912,6 @@ where
let channel_id = state.get_id();
let remove_reason = remove_tlc.reason.clone();
let tlc_info = state.remove_tlc_with_reason(remove_tlc.tlc_id, &remove_reason)?;
if let RemoveTlcReason::RemoveTlcFulfill(_) = remove_reason {
if let Some(invoice) = self.store.get_invoice(&tlc_info.payment_hash) {
let status = self.get_invoice_status(&invoice);
assert_eq!(status, CkbInvoiceStatus::Received);
self.store
.update_invoice_status(&tlc_info.payment_hash, CkbInvoiceStatus::Paid)
.expect("update invoice status failed");
}
}
if let (
Some(ref udt_type_script),
RemoveTlcReason::RemoveTlcFulfill(RemoveTlcFulfill { payment_preimage }),
Expand Down Expand Up @@ -4125,6 +4125,7 @@ impl ChannelActorState {
self.to_remote_amount = to_remote_amount;
debug!("Updated local balance to {} and remote balance to {} by removing tlc {:?} with reason {:?}",
to_local_amount, to_remote_amount, tlc_id, reason);

self.tlc_state
.apply_tlc_remove(tlc_id, removed_at, reason.clone());
current
Expand Down

0 comments on commit 658123a

Please sign in to comment.