@@ -73,6 +73,26 @@ type OpenChannel struct {
7373	RemoteShutdownScript     lnwire.DeliveryAddress 
7474}
7575
76+ // ClosedChannel is the information we want to dump from a closed channel in 
77+ // lnd's channel DB. See `channeldb.ChannelCloseSummary` for information about 
78+ // the fields. 
79+ type  ClosedChannel  struct  {
80+ 	ChanPoint                string 
81+ 	ShortChanID              lnwire.ShortChannelID 
82+ 	ChainHash                chainhash.Hash 
83+ 	ClosingTXID              string 
84+ 	RemotePub                string 
85+ 	Capacity                 btcutil.Amount 
86+ 	CloseHeight              uint32 
87+ 	SettledBalance           btcutil.Amount 
88+ 	TimeLockedBalance        btcutil.Amount 
89+ 	CloseType                string 
90+ 	IsPending                bool 
91+ 	RemoteCurrentRevocation  string 
92+ 	RemoteNextRevocation     string 
93+ 	LocalChanConfig          ChannelConfig 
94+ }
95+ 
7696// ChannelConfig is the information we want to dump from a channel 
7797// configuration. See `channeldb.ChannelConfig` for more information about the 
7898// fields. 
@@ -92,10 +112,10 @@ type KeyDescriptor struct {
92112	PubKey  string 
93113}
94114
95- // ChannelDump  converts the channels in the given channel DB into a dumpable  
96- // format. 
97- func  ChannelDump (channels  []* channeldb.OpenChannel ,  params   * chaincfg. Params ) ( 
98- 	[]OpenChannel , error ) {
115+ // OpenChannelDump  converts the open  channels in the given channel DB into a 
116+ // dumpable  format. 
117+ func  OpenChannelDump (channels  []* channeldb.OpenChannel ,
118+ 	params   * chaincfg. Params ) ( []OpenChannel , error ) {
99119
100120	dumpChannels  :=  make ([]OpenChannel , len (channels ))
101121	for  idx , channel  :=  range  channels  {
@@ -154,6 +174,41 @@ func ChannelDump(channels []*channeldb.OpenChannel, params *chaincfg.Params) (
154174	return  dumpChannels , nil 
155175}
156176
177+ // ClosedChannelDump converts the closed channels in the given channel DB into a 
178+ // dumpable format. 
179+ func  ClosedChannelDump (channels  []* channeldb.ChannelCloseSummary ,
180+ 	params  * chaincfg.Params ) ([]ClosedChannel , error ) {
181+ 
182+ 	dumpChannels  :=  make ([]ClosedChannel , len (channels ))
183+ 	for  idx , channel  :=  range  channels  {
184+ 		dumpChannels [idx ] =  ClosedChannel {
185+ 			ChanPoint :         channel .ChanPoint .String (),
186+ 			ShortChanID :       channel .ShortChanID ,
187+ 			ChainHash :         channel .ChainHash ,
188+ 			ClosingTXID :       channel .ClosingTXID .String (),
189+ 			RemotePub :         PubKeyToString (channel .RemotePub ),
190+ 			Capacity :          channel .Capacity ,
191+ 			CloseHeight :       channel .CloseHeight ,
192+ 			SettledBalance :    channel .SettledBalance ,
193+ 			TimeLockedBalance : channel .TimeLockedBalance ,
194+ 			CloseType : fmt .Sprintf (
195+ 				"%d" , channel .CloseType ,
196+ 			),
197+ 			IsPending : channel .IsPending ,
198+ 			RemoteCurrentRevocation : PubKeyToString (
199+ 				channel .RemoteCurrentRevocation ,
200+ 			),
201+ 			RemoteNextRevocation : PubKeyToString (
202+ 				channel .RemoteNextRevocation ,
203+ 			),
204+ 			LocalChanConfig : ToChannelConfig (
205+ 				params , channel .LocalChanConfig ,
206+ 			),
207+ 		}
208+ 	}
209+ 	return  dumpChannels , nil 
210+ }
211+ 
157212// BackupDump converts the given multi backup into a dumpable format. 
158213func  BackupDump (multi  * chanbackup.Multi , params  * chaincfg.Params ) []BackupSingle  {
159214
0 commit comments