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
2024-05-29 19:57:49 +02:00
parent 39e4e8d8a4
commit 9ce799578c
5 changed files with 3624 additions and 3308 deletions

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