Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add payment_preimage field to Event::PaymentSuccessful #392

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading