Skip to content

Commit

Permalink
Add payment_preimage field to Event::PaymentSuccessful
Browse files Browse the repository at this point in the history
.. we add this field for informative purposes.
  • Loading branch information
tnull committed Oct 28, 2024
1 parent 2156611 commit 0ea5032
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ enum VssHeaderProviderError {

[Enum]
interface Event {
PaymentSuccessful(PaymentId? payment_id, PaymentHash payment_hash, u64? fee_paid_msat);
PaymentSuccessful(PaymentId? payment_id, PaymentHash payment_hash, PaymentPreimage? payment_preimage, u64? fee_paid_msat);
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline);
Expand Down
10 changes: 9 additions & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
use lightning::impl_writeable_tlv_based_enum;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::types::ChannelId;
use lightning::ln::PaymentHash;
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::gossip::NodeId;
use lightning::util::errors::APIError;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};
Expand Down Expand Up @@ -65,6 +65,12 @@ pub enum Event {
payment_id: Option<PaymentId>,
/// The hash of the payment.
payment_hash: PaymentHash,
/// The preimage to the `payment_hash`.
///
/// Note that this serves as a payment receipt.
///
/// Will only be `None` for events serialized with LDK Node v0.4.2 or prior.
payment_preimage: Option<PaymentPreimage>,
/// The total fee which was spent at intermediate hops in this payment.
fee_paid_msat: Option<u64>,
},
Expand Down Expand Up @@ -163,6 +169,7 @@ impl_writeable_tlv_based_enum!(Event,
(0, payment_hash, required),
(1, fee_paid_msat, option),
(3, payment_id, option),
(5, payment_preimage, option),
},
(1, PaymentFailed) => {
(0, payment_hash, option),
Expand Down Expand Up @@ -870,6 +877,7 @@ where
let event = Event::PaymentSuccessful {
payment_id: Some(payment_id),
payment_hash,
payment_preimage: Some(payment_preimage),
fee_paid_msat,
};

Expand Down

0 comments on commit 0ea5032

Please sign in to comment.