@@ -46,6 +46,16 @@ type BackupSingle struct {
46
46
LocalChanCfg ChannelConfig
47
47
RemoteChanCfg ChannelConfig
48
48
ShaChainRootDesc KeyDescriptor
49
+ CloseTxInputs * CloseTxInputs
50
+ }
51
+
52
+ // CloseTxInputs is a struct that contains data needed to produce a force close
53
+ // transaction from a channel backup as a last resort recovery method.
54
+ type CloseTxInputs struct {
55
+ CommitTx string
56
+ CommitSig string
57
+ CommitHeight uint64
58
+ TapscriptRoot string
49
59
}
50
60
51
61
// 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