@@ -293,6 +293,24 @@ impl StorableObject for PaymentDetails {
293293 }
294294 }
295295
296+ if let Some ( attempts) = update. broadcast_attempts {
297+ match self . kind {
298+ PaymentKind :: Onchain { ref mut broadcast_attempts, .. } => {
299+ update_if_necessary ! ( * broadcast_attempts, attempts) ;
300+ } ,
301+ _ => { } ,
302+ }
303+ }
304+
305+ if let Some ( broadcast_time) = update. last_broadcast_time {
306+ match self . kind {
307+ PaymentKind :: Onchain { ref mut last_broadcast_time, .. } => {
308+ update_if_necessary ! ( * last_broadcast_time, broadcast_time) ;
309+ } ,
310+ _ => { } ,
311+ }
312+ }
313+
296314 if updated {
297315 self . latest_update_timestamp = SystemTime :: now ( )
298316 . duration_since ( UNIX_EPOCH )
@@ -353,6 +371,12 @@ pub enum PaymentKind {
353371 txid : Txid ,
354372 /// The confirmation status of this payment.
355373 status : ConfirmationStatus ,
374+ /// The raw transaction for rebroadcasting
375+ raw_tx : Option < Vec < u8 > > ,
376+ /// Last broadcast attempt timestamp (UNIX seconds)
377+ last_broadcast_time : Option < u64 > ,
378+ /// Number of broadcast attempts
379+ broadcast_attempts : u32 ,
356380 } ,
357381 /// A [BOLT 11] payment.
358382 ///
@@ -451,6 +475,9 @@ impl_writeable_tlv_based_enum!(PaymentKind,
451475 ( 0 , Onchain ) => {
452476 ( 0 , txid, required) ,
453477 ( 2 , status, required) ,
478+ ( 4 , raw_tx, option) ,
479+ ( 10 , last_broadcast_time, option) ,
480+ ( 12 , broadcast_attempts, required) ,
454481 } ,
455482 ( 2 , Bolt11 ) => {
456483 ( 0 , hash, required) ,
@@ -542,6 +569,8 @@ pub(crate) struct PaymentDetailsUpdate {
542569 pub direction : Option < PaymentDirection > ,
543570 pub status : Option < PaymentStatus > ,
544571 pub confirmation_status : Option < ConfirmationStatus > ,
572+ pub last_broadcast_time : Option < Option < u64 > > ,
573+ pub broadcast_attempts : Option < u32 > ,
545574}
546575
547576impl PaymentDetailsUpdate {
@@ -557,6 +586,8 @@ impl PaymentDetailsUpdate {
557586 direction : None ,
558587 status : None ,
559588 confirmation_status : None ,
589+ last_broadcast_time : None ,
590+ broadcast_attempts : None ,
560591 }
561592 }
562593}
@@ -572,9 +603,11 @@ impl From<&PaymentDetails> for PaymentDetailsUpdate {
572603 _ => ( None , None , None ) ,
573604 } ;
574605
575- let confirmation_status = match value. kind {
576- PaymentKind :: Onchain { status, .. } => Some ( status) ,
577- _ => None ,
606+ let ( confirmation_status, last_broadcast_time, broadcast_attempts) = match value. kind {
607+ PaymentKind :: Onchain { status, last_broadcast_time, broadcast_attempts, .. } => {
608+ ( Some ( status) , last_broadcast_time, broadcast_attempts)
609+ } ,
610+ _ => ( None , None , 0 ) ,
578611 } ;
579612
580613 let counterparty_skimmed_fee_msat = match value. kind {
@@ -595,6 +628,8 @@ impl From<&PaymentDetails> for PaymentDetailsUpdate {
595628 direction : Some ( value. direction ) ,
596629 status : Some ( value. status ) ,
597630 confirmation_status,
631+ last_broadcast_time : Some ( last_broadcast_time) ,
632+ broadcast_attempts : Some ( broadcast_attempts) ,
598633 }
599634 }
600635}
0 commit comments