mirror of
https://github.com/guggero/chantools.git
synced 2026-08-13 12:33:34 +02:00
dump: include close tx and related fields
Include fields closetx, commit sig, commit height, tapscript root. That will add the new data to the output of chantools dumpbackup.
This commit is contained in:
parent
35527ba55c
commit
63e1e5fdad
1 changed files with 43 additions and 0 deletions
43
dump/dump.go
43
dump/dump.go
|
|
@ -46,6 +46,16 @@ 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
|
||||
TapscriptRoot string
|
||||
}
|
||||
|
||||
// OpenChannel is the information we want to dump from an open channel in lnd's
|
||||
|
|
@ -406,7 +416,40 @@ func BackupDump(multi *chanbackup.Multi,
|
|||
params, single.ShaChainRootDesc,
|
||||
),
|
||||
}
|
||||
|
||||
single.CloseTxInputs.WhenSome(
|
||||
func(inputs chanbackup.CloseTxInputs) {
|
||||
// Serialize unsigned transaction.
|
||||
var buf bytes.Buffer
|
||||
err := inputs.CommitTx.Serialize(&buf)
|
||||
if err != nil {
|
||||
buf.WriteString("error serializing " +
|
||||
"commit tx: " + err.Error())
|
||||
}
|
||||
tx := buf.Bytes()
|
||||
|
||||
// Serialize TapscriptRoot if present.
|
||||
var tapscriptRoot string
|
||||
inputs.TapscriptRoot.WhenSome(
|
||||
func(tr chainhash.Hash) {
|
||||
tapscriptRoot = tr.String()
|
||||
},
|
||||
)
|
||||
|
||||
// Put all CloseTxInputs to dump in human
|
||||
// readable form.
|
||||
dumpSingles[idx].CloseTxInputs = &CloseTxInputs{
|
||||
CommitTx: hex.EncodeToString(tx),
|
||||
CommitSig: hex.EncodeToString(
|
||||
inputs.CommitSig,
|
||||
),
|
||||
CommitHeight: inputs.CommitHeight,
|
||||
TapscriptRoot: tapscriptRoot,
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return dumpSingles
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue