Skip to content

Commit

Permalink
dump: include close tx, commit sig, commit height
Browse files Browse the repository at this point in the history
That will add the new data to the output of chantools dumpbackup.
  • Loading branch information
guggero authored and starius committed Jul 17, 2024
1 parent 1fe8248 commit 1049f12
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 1049f12

Please sign in to comment.