From 1049f120473d636970911d884dea61db2d335846 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 17 Jul 2024 10:43:06 -0300 Subject: [PATCH] dump: include close tx, commit sig, commit height That will add the new data to the output of chantools dumpbackup. --- dump/dump.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/dump/dump.go b/dump/dump.go index c1e1812..0b53ec3 100644 --- a/dump/dump.go +++ b/dump/dump.go @@ -44,6 +44,15 @@ type BackupSingle struct { LocalChanCfg ChannelConfig RemoteChanCfg ChannelConfig ShaChainRootDesc KeyDescriptor + CloseTxInputs *CloseTxInputs +} + +// CloseTxInputs is a struct that contains data needed to produce a force close +// transaction from a channel backup as a last resort recovery method. +type CloseTxInputs struct { + CommitTx string + CommitSig string + CommitHeight uint64 } // OpenChannel is the information we want to dump from an open channel in lnd's @@ -392,7 +401,25 @@ func BackupDump(multi *chanbackup.Multi, params, single.ShaChainRootDesc, ), } + + if single.CloseTxInputs != nil { + var buf bytes.Buffer + err := single.CloseTxInputs.CommitTx.Serialize(&buf) + if err != nil { + buf.WriteString("error serializing commit " + + "tx: " + err.Error()) + } + + dumpSingles[idx].CloseTxInputs = &CloseTxInputs{ + CommitTx: hex.EncodeToString(buf.Bytes()), + CommitSig: hex.EncodeToString( + single.CloseTxInputs.CommitSig, + ), + CommitHeight: single.CloseTxInputs.CommitHeight, + } + } } + return dumpSingles }