Skip to content

Commit 1049f12

Browse files
guggerostarius
authored andcommitted
dump: include close tx, commit sig, commit height
That will add the new data to the output of chantools dumpbackup.
1 parent 1fe8248 commit 1049f12

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

dump/dump.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ type BackupSingle struct {
4444
LocalChanCfg ChannelConfig
4545
RemoteChanCfg ChannelConfig
4646
ShaChainRootDesc KeyDescriptor
47+
CloseTxInputs *CloseTxInputs
48+
}
49+
50+
// CloseTxInputs is a struct that contains data needed to produce a force close
51+
// transaction from a channel backup as a last resort recovery method.
52+
type CloseTxInputs struct {
53+
CommitTx string
54+
CommitSig string
55+
CommitHeight uint64
4756
}
4857

4958
// OpenChannel is the information we want to dump from an open channel in lnd's
@@ -392,7 +401,25 @@ func BackupDump(multi *chanbackup.Multi,
392401
params, single.ShaChainRootDesc,
393402
),
394403
}
404+
405+
if single.CloseTxInputs != nil {
406+
var buf bytes.Buffer
407+
err := single.CloseTxInputs.CommitTx.Serialize(&buf)
408+
if err != nil {
409+
buf.WriteString("error serializing commit " +
410+
"tx: " + err.Error())
411+
}
412+
413+
dumpSingles[idx].CloseTxInputs = &CloseTxInputs{
414+
CommitTx: hex.EncodeToString(buf.Bytes()),
415+
CommitSig: hex.EncodeToString(
416+
single.CloseTxInputs.CommitSig,
417+
),
418+
CommitHeight: single.CloseTxInputs.CommitHeight,
419+
}
420+
}
395421
}
422+
396423
return dumpSingles
397424
}
398425

0 commit comments

Comments
 (0)