In this commit, the lnwire.NodeAnnouncement2 type is defined. This will
be used to represent the `node_announcement_2` message used in the
Gossip 2 (1.75) protocol.
We leave a TODO that should be addressed after a discussion at the spec
meeting. For now, having the incorrect TLV type is not a problem since
this ChannelUpdate2 type is not used in production.
In preparation for adding a NodeAnnouncement2 struct along with a
NodeAnnouncement interface, this commit renames the existing
NodeAnnouncment struct to NodeAnnouncement1.
Add a new OutPoint type that wraps wire.OutPoint and provides TLV
encoding/decoding capabilities through the tlv.RecordProducer interface.
This enables OutPoint to be used in TLV streams of messages.
In this commit, the logic in ReadElements that is used to read a single
address descriptor from a io.Reader is separated out into a new function
so that the logic can be re-used elsewhere.
Check that the node ann doesnt contain more than 1 DNS addr.
This will ensure that we now start rejecting new node announcements
with multiple DNS addrs since this check is called in the gossiper
before persisting a node ann to our local graph.
It also validates the DNS fields according to BOLT #7 specs.
In this commit, we remove `AddrLen` as prepration step
before adding DNS address type which will have a var length.
Co-authored-by: Elle Mouton <elle.mouton@gmail.com>
PureTLVMessage describes an LN message that is a pure TLV stream. If the
message includes a signature, it will sign all the TLV records in the
inclusive ranges: 0 to 159 and 1000000000 to 2999999999.
A comprehensive test is added that shows how two versions of the same
message remain forward compatible.
To ensure that the RandNodeAlias helper can be used elsewhere to
generate random aliases, we adjust it in this test to only produce valid
UTF-8 strings as required by the spec.
It should be an optional record instead of an fn option. In addition,
its tlv type is bumped to be 14 as this record is also included in the
`DynCommit`. If we use tlv type 0, it will create a conflict in the msg
`DynCommit`, which is fixed in the following commit.
Previously we encode all the fields plus extra data to the field
`ExtraData`, this is now fixed by encoding only unknown data to extra
data. For known records, they are already encoded into the message
fields.
Replace all usages of the "github.com/go-errors/errors" and
"github.com/pkg/errors" packages with the standard lib's "errors"
package. This ensures that error wrapping and `errors.Is` checks will
work as expected.
The spec says: `The origin node MUST NOT set both the optional and
mandatory bits`. and so this is why we have the SafeSet method which
prevents us from accidentally setting both optional and required bits
for any of our own feature bits. But the spec then also says `if both
the optional and the mandatory feature bits in a pair are set, the
feature should be treated as mandatory.` which means that when we read
the feature vectors of our peers or from a payment request, we should be
a bit less strict and not error out. We should just set both bits which
will result in "IsRequired" returning true.
Update the `TestExtractIntentFromSendRequest` test to show the new
behaviour.
Ensure that tests can run in parallel without causing a data race by
adding a `makeTestChannelUpdate` constructor rather than sharing the
same `testChannelUpdate` type between tests. This is needed since some
tests write to the type.