lnwire: add LocalNonce to OpenChannel

This commit is contained in:
Olaoluwa Osuntokun 2023-01-16 19:39:24 -08:00
parent 14949c972d
commit 7c5ba067ab
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -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