@@ -34,7 +34,8 @@ use lightning::{impl_writeable_tlv_based, impl_writeable_tlv_based_enum};
3434use lightning_liquidity:: lsps2:: utils:: compute_opening_fee;
3535use lightning_types:: payment:: { PaymentHash , PaymentPreimage } ;
3636
37- use crate :: closed_channel:: { ClosedChannelDetails , PendingChannelInfo } ;
37+ use crate :: channel:: store:: ChannelRecord ;
38+ use crate :: closed_channel:: ClosedChannelDetails ;
3839use crate :: config:: { may_announce_channel, Config } ;
3940use crate :: connection:: ConnectionManager ;
4041use crate :: data_store:: DataStoreUpdateResult ;
@@ -54,8 +55,8 @@ use crate::payment::store::{
5455} ;
5556use crate :: runtime:: Runtime ;
5657use crate :: types:: {
57- ClosedChannelStore , CustomTlvRecord , DynStore , KeysManager , OnionMessenger , PaymentStore ,
58- PendingChannelStore , Sweeper , Wallet ,
58+ ChannelRecordStore , ClosedChannelStore , CustomTlvRecord , DynStore , KeysManager , OnionMessenger ,
59+ PaymentStore , Sweeper , Wallet ,
5960} ;
6061use crate :: {
6162 hex_utils, BumpTransactionEventHandler , ChannelManager , Error , Graph , PeerInfo , PeerStore ,
@@ -551,7 +552,7 @@ where
551552 payment_store : Arc < PaymentStore > ,
552553 peer_store : Arc < PeerStore < L > > ,
553554 closed_channel_store : Arc < ClosedChannelStore > ,
554- pending_channel_store : Arc < PendingChannelStore > ,
555+ channel_record_store : Arc < ChannelRecordStore > ,
555556 // Tracks which user_channel_ids correspond to outbound channels. Populated at startup from
556557 // list_channels() and updated on ChannelPending events. Consumed on ChannelClosed events.
557558 outbound_channel_ids : Mutex < HashSet < UserChannelId > > ,
@@ -579,7 +580,7 @@ where
579580 liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
580581 payment_store : Arc < PaymentStore > , peer_store : Arc < PeerStore < L > > ,
581582 closed_channel_store : Arc < ClosedChannelStore > ,
582- pending_channel_store : Arc < PendingChannelStore > , keys_manager : Arc < KeysManager > ,
583+ channel_record_store : Arc < ChannelRecordStore > , keys_manager : Arc < KeysManager > ,
583584 static_invoice_store : Option < StaticInvoiceStore > , onion_messenger : Arc < OnionMessenger > ,
584585 om_mailbox : Option < Arc < OnionMessageMailbox > > , runtime : Arc < Runtime > , logger : L ,
585586 config : Arc < Config > ,
@@ -612,7 +613,7 @@ where
612613 payment_store,
613614 peer_store,
614615 closed_channel_store,
615- pending_channel_store ,
616+ channel_record_store ,
616617 outbound_channel_ids,
617618 announced_channel_ids,
618619 keys_manager,
@@ -1575,15 +1576,17 @@ where
15751576 . insert ( UserChannelId ( user_channel_id) ) ;
15761577 }
15771578
1578- let pending_info = PendingChannelInfo {
1579+ let record = ChannelRecord :: Funded {
15791580 user_channel_id : UserChannelId ( user_channel_id) ,
1581+ counterparty_node_id,
1582+ channel_id,
15801583 is_outbound : pending_channel. is_outbound ,
15811584 is_announced : pending_channel. is_announced ,
15821585 } ;
1583- if let Err ( e) = self . pending_channel_store . insert_or_update ( pending_info ) {
1586+ if let Err ( e) = self . channel_record_store . insert_or_update ( record ) {
15841587 log_error ! (
15851588 self . logger,
1586- "Failed to persist pending channel info {}: {}" ,
1589+ "Failed to persist channel record for {}: {}" ,
15871590 channel_id,
15881591 e
15891592 ) ;
@@ -1683,15 +1686,19 @@ where
16831686 . expect ( "Lock poisoned" )
16841687 . remove ( & user_channel_id) ;
16851688
1686- // Primary: use the durably-persisted PendingChannelInfo written at
1687- // ChannelPending time. Falls back to in-memory sets (populated at startup
1688- // or on ChannelPending), then to any already-persisted ClosedChannelDetails
1689- // record (for the replay case where insert_or_update already succeeded but
1690- // add_event failed and PendingChannelInfo was already cleaned up).
1689+ // Primary: use the durably-persisted ChannelRecord written at ChannelPending
1690+ // time. Falls back to in-memory sets (populated at startup or on
1691+ // ChannelPending), then to any already-persisted ClosedChannelDetails record
1692+ // (for the replay case where insert_or_update already succeeded but
1693+ // add_event failed and the ChannelRecord was already cleaned up).
16911694 let ( is_outbound, is_announced) = self
1692- . pending_channel_store
1695+ . channel_record_store
16931696 . get ( & user_channel_id)
1694- . map ( |info| ( info. is_outbound , info. is_announced ) )
1697+ . and_then ( |record| match record {
1698+ ChannelRecord :: Funded { is_outbound, is_announced, .. } => {
1699+ Some ( ( is_outbound, is_announced) )
1700+ } ,
1701+ } )
16951702 . or_else ( || {
16961703 self . closed_channel_store
16971704 . get ( & user_channel_id)
@@ -1745,10 +1752,10 @@ where
17451752
17461753 match self . event_queue . add_event ( event) . await {
17471754 Ok ( _) => {
1748- if let Err ( e) = self . pending_channel_store . remove ( & user_channel_id) {
1755+ if let Err ( e) = self . channel_record_store . remove ( & user_channel_id) {
17491756 log_error ! (
17501757 self . logger,
1751- "Failed to remove pending channel info for {}: {}" ,
1758+ "Failed to remove channel record for {}: {}" ,
17521759 channel_id,
17531760 e
17541761 ) ;
0 commit comments