@@ -84,6 +84,28 @@ pub enum Event {
84
84
/// The value, in thousandths of a satoshi, that has been received.
85
85
amount_msat : u64 ,
86
86
} ,
87
+ /// A payment for a previously-registered payment hash has been received.
88
+ ///
89
+ /// This needs to be manually claimed by supplying the correct preimage to [`claim_for_hash`].
90
+ ///
91
+ /// If the the provided parameters don't match the expectations or the preimage can't be
92
+ /// retrieved in time, should be failed-back via [`fail_for_hash`].
93
+ ///
94
+ /// Note claiming will necessarily fail after the `claim_deadline` has been reached.
95
+ ///
96
+ /// [`claim_for_hash`]: crate::payment::Bolt11Payment::claim_for_hash
97
+ /// [`fail_for_hash`]: crate::payment::Bolt11Payment::fail_for_hash
98
+ PaymentClaimable {
99
+ /// A local identifier used to track the payment.
100
+ payment_id : PaymentId ,
101
+ /// The hash of the payment.
102
+ payment_hash : PaymentHash ,
103
+ /// The value, in thousandths of a satoshi, that is claimable.
104
+ claimable_amount_msat : u64 ,
105
+ /// The block height at which this payment will be failed back and will no longer be
106
+ /// eligible for claiming.
107
+ claim_deadline : Option < u32 > ,
108
+ } ,
87
109
/// A channel has been created and is pending confirmation on-chain.
88
110
ChannelPending {
89
111
/// The `channel_id` of the channel.
@@ -156,6 +178,12 @@ impl_writeable_tlv_based_enum!(Event,
156
178
( 1 , counterparty_node_id, option) ,
157
179
( 2 , user_channel_id, required) ,
158
180
( 3 , reason, upgradable_option) ,
181
+ } ,
182
+ ( 6 , PaymentClaimable ) => {
183
+ ( 0 , payment_hash, required) ,
184
+ ( 2 , payment_id, required) ,
185
+ ( 4 , claimable_amount_msat, required) ,
186
+ ( 6 , claim_deadline, option) ,
159
187
} ;
160
188
) ;
161
189
@@ -434,7 +462,7 @@ where
434
462
receiver_node_id : _,
435
463
via_channel_id : _,
436
464
via_user_channel_id : _,
437
- claim_deadline : _ ,
465
+ claim_deadline,
438
466
onion_fields : _,
439
467
counterparty_skimmed_fee_msat,
440
468
} => {
@@ -500,6 +528,38 @@ where
500
528
} ) ;
501
529
return ;
502
530
}
531
+
532
+ // If this is known by the store but ChannelManager doesn't know the preimage,
533
+ // the payment has been registered via `_for_hash` variants and needs to be manually claimed via
534
+ // user interaction.
535
+ match info. kind {
536
+ PaymentKind :: Bolt11 { preimage, .. } => {
537
+ if purpose. preimage ( ) . is_none ( ) {
538
+ debug_assert ! (
539
+ preimage. is_none( ) ,
540
+ "We would have registered the preimage if we knew"
541
+ ) ;
542
+
543
+ self . event_queue
544
+ . add_event ( Event :: PaymentClaimable {
545
+ payment_id,
546
+ payment_hash,
547
+ claimable_amount_msat : amount_msat,
548
+ claim_deadline,
549
+ } )
550
+ . unwrap_or_else ( |e| {
551
+ log_error ! (
552
+ self . logger,
553
+ "Failed to push to event queue: {}" ,
554
+ e
555
+ ) ;
556
+ panic ! ( "Failed to push to event queue" ) ;
557
+ } ) ;
558
+ return ;
559
+ }
560
+ } ,
561
+ _ => { } ,
562
+ }
503
563
}
504
564
505
565
log_info ! (
0 commit comments