@@ -45,6 +45,16 @@ type BackupSingle struct {
45
45
LocalChanCfg ChannelConfig
46
46
RemoteChanCfg ChannelConfig
47
47
ShaChainRootDesc KeyDescriptor
48
+ CloseTxInputs * CloseTxInputs
49
+ }
50
+
51
+ // CloseTxInputs is a struct that contains data needed to produce a force close
52
+ // transaction from a channel backup as a last resort recovery method.
53
+ type CloseTxInputs struct {
54
+ CommitTx string
55
+ CommitSig string
56
+ CommitHeight uint64
57
+ TapscriptRoot string
48
58
}
49
59
50
60
// OpenChannel is the information we want to dump from an open channel in lnd's
@@ -406,7 +416,40 @@ func BackupDump(multi *chanbackup.Multi,
406
416
params , single .ShaChainRootDesc ,
407
417
),
408
418
}
419
+
420
+ single .CloseTxInputs .WhenSome (
421
+ func (inputs chanbackup.CloseTxInputs ) {
422
+ // Serialize unsigned transaction.
423
+ var buf bytes.Buffer
424
+ err := inputs .CommitTx .Serialize (& buf )
425
+ if err != nil {
426
+ buf .WriteString ("error serializing " +
427
+ "commit tx: " + err .Error ())
428
+ }
429
+ tx := buf .Bytes ()
430
+
431
+ // Serialize TapscriptRoot if present.
432
+ var tapscriptRoot string
433
+ inputs .TapscriptRoot .WhenSome (
434
+ func (tr chainhash.Hash ) {
435
+ tapscriptRoot = tr .String ()
436
+ },
437
+ )
438
+
439
+ // Put all CloseTxInputs to dump in human
440
+ // readable form.
441
+ dumpSingles [idx ].CloseTxInputs = & CloseTxInputs {
442
+ CommitTx : hex .EncodeToString (tx ),
443
+ CommitSig : hex .EncodeToString (
444
+ inputs .CommitSig ,
445
+ ),
446
+ CommitHeight : inputs .CommitHeight ,
447
+ TapscriptRoot : tapscriptRoot ,
448
+ }
449
+ },
450
+ )
409
451
}
452
+
410
453
return dumpSingles
411
454
}
412
455
0 commit comments