Skip to content

Commit

Permalink
feat: custom TLVs storage WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jun 13, 2024
1 parent fe5cc20 commit 55b4a81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ where
via_channel_id: _,
via_user_channel_id: _,
claim_deadline: _,
onion_fields: _,
onion_fields,
counterparty_skimmed_fee_msat,
} => {
let payment_id = PaymentId(payment_hash.0);
Expand Down Expand Up @@ -553,6 +553,18 @@ where
panic!("Failed to access payment store");
});
}
if let PaymentPurpose::SpontaneousPayment(preimage) = purpose {
// TODO: fix unwrap to have proper error handling and log error
let custom_tlvs = onion_fields.unwrap().custom_tlvs();
log_info!(
self.logger,
"Saving spontaneous payment with custom TLVs for payment hash {} of {}msat",
// custom_tlvs, // TODO: log the custom TLVs
hex_utils::to_string(&payment_hash.0),
amount_msat,
);
// TODO: create payment in pending status and save TLVs as a new field on spontaneous payment in PaymentKind::Spontaneous
}
},
LdkEvent::PaymentClaimed {
payment_hash,
Expand Down Expand Up @@ -622,6 +634,8 @@ where
return;
},
PaymentPurpose::SpontaneousPayment(preimage) => {
// TODO: change to updating the payment instead of creating it
// since it now has to be created when checking if the payment is claimable in order to store the custom tlvs
let payment = PaymentDetails {
id: payment_id,
kind: PaymentKind::Spontaneous {
Expand Down
1 change: 1 addition & 0 deletions src/payment/spontaneous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl SpontaneousPayment {
kind: PaymentKind::Spontaneous {
hash: payment_hash,
preimage: Some(payment_preimage),
// TODO: save custom TLVs here from recipient_fields.custom_tlvs()
},
status: PaymentStatus::Pending,
direction: PaymentDirection::Outbound,
Expand Down

0 comments on commit 55b4a81

Please sign in to comment.