From 7c5ba067ab56e60e5d96465985cf8c37449fe5d5 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 16 Jan 2023 19:39:24 -0800 Subject: [PATCH] lnwire: add LocalNonce to OpenChannel --- lnwire/open_channel.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lnwire/open_channel.go b/lnwire/open_channel.go index 4887ced34..9cb4bc41a 100644 --- a/lnwire/open_channel.go +++ b/lnwire/open_channel.go @@ -141,6 +141,13 @@ type OpenChannel struct { // type. LeaseExpiry *LeaseExpiry + // LocalNonce is an optional field that transmits the + // local/verification nonce for a party. This nonce will be used to + // verify the very first commitment transaction signature. This will + // only be populated if the simple taproot channels type was + // negotiated. + LocalNonce *Musig2Nonce + // ExtraData is the set of data that was appended to this message to // fill out the full maximum transport message size. These fields can // be used to specify optional data such as custom TLV fields. @@ -168,6 +175,9 @@ func (o *OpenChannel) Encode(w *bytes.Buffer, pver uint32) error { if o.LeaseExpiry != nil { recordProducers = append(recordProducers, o.LeaseExpiry) } + if o.LocalNonce != nil { + recordProducers = append(recordProducers, o.LocalNonce) + } err := EncodeMessageExtraData(&o.ExtraData, recordProducers...) if err != nil { return err @@ -292,9 +302,11 @@ func (o *OpenChannel) Decode(r io.Reader, pver uint32) error { var ( chanType ChannelType leaseExpiry LeaseExpiry + localNonce Musig2Nonce ) typeMap, err := tlvRecords.ExtractRecords( &o.UpfrontShutdownScript, &chanType, &leaseExpiry, + &localNonce, ) if err != nil { return err @@ -307,6 +319,9 @@ func (o *OpenChannel) Decode(r io.Reader, pver uint32) error { if val, ok := typeMap[LeaseExpiryRecordType]; ok && val == nil { o.LeaseExpiry = &leaseExpiry } + if val, ok := typeMap[NonceRecordType]; ok && val == nil { + o.LocalNonce = &localNonce + } o.ExtraData = tlvRecords