multi: add co-op close custom data to close update

With this commit we populate additional information about the close
outputs (including potential custom channel data) in the close update
RPC message.
This will allow custom channels to find out how the additional close
outputs look like on chain and what data they might commit to.

We also hook up the aux custom data formatter, so it can format the
custom channel data to JSON.
This commit is contained in:
Oliver Gugger committed 2024-09-19 10:18:41 +02:00
1 parent 8dee76a1b8
commit e0b4601fb9
5 files changed
+3624 -3308

No files matched your search

+27 -4
View File
@@ -145,6 +145,21 @@ type PendingUpdate struct {
type ChannelCloseUpdate struct {
ClosingTxid []byte
Success bool
// LocalCloseOutput is an optional, additional output on the closing
// transaction that the local party should be paid to. This will only be
// populated if the local balance isn't dust.
LocalCloseOutput fn.Option[chancloser.CloseOutput]
// RemoteCloseOutput is an optional, additional output on the closing
// transaction that the remote party should be paid to. This will only
// be populated if the remote balance isn't dust.
RemoteCloseOutput fn.Option[chancloser.CloseOutput]
// AuxOutputs is an optional set of additional outputs that might be
// included in the closing transaction. These are used for custom
// channel types.
AuxOutputs fn.Option[chancloser.AuxCloseOutputs]
}
// TimestampedError is a timestamped error that is used to store the most recent
@@ -3567,17 +3582,25 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
}
}
go WaitForChanToClose(chanCloser.NegotiationHeight(), notifier, errChan,
localOut := chanCloser.LocalCloseOutput()
remoteOut := chanCloser.RemoteCloseOutput()
auxOut := chanCloser.AuxOutputs()
go WaitForChanToClose(
chanCloser.NegotiationHeight(), notifier, errChan,
&chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, func() {
// Respond to the local subsystem which requested the
// channel closure.
if closeReq != nil {
closeReq.Updates <- &ChannelCloseUpdate{
ClosingTxid: closingTxid[:],
Success: true,
ClosingTxid: closingTxid[:],
Success: true,
LocalCloseOutput: localOut,
RemoteCloseOutput: remoteOut,
AuxOutputs: auxOut,
}
}
})
},
)
}
// WaitForChanToClose uses the passed notifier to wait until the channel has