Commit Graph

620 Commits

Author SHA1 Message Date
ziggie
870d603ce5 multi: allow invalid tlv data when decoding payment fail info
Older payments might have a invalid tlv stream, we now catch this
case and add a unit test.
2025-11-03 12:54:29 +01:00
Elle Mouton
b8ff9fbef3 lnwire: define NodeAnnouncement2
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.
2025-10-02 12:15:16 +02:00
Elle Mouton
e24dd2f9e0 lnwire: let DNSAddress implement RecordProducer
In preparation for using this type as a TLV record, we let it implement
the RecordProducer interface.
2025-10-01 13:49:15 +02:00
Elle Mouton
e9a4f22dd6 lnwire: add inbound fee to ChannelUpdate2
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.
2025-10-01 13:13:32 +02:00
Elle Mouton
b8abe130a5 multi: rename lnwire.NodeAnnouncement
In preparation for adding a NodeAnnouncement2 struct along with a
NodeAnnouncement interface, this commit renames the existing
NodeAnnouncment struct to NodeAnnouncement1.
2025-10-01 13:13:32 +02:00
Elle Mouton
8372524edf lnwire: add Outpoint to ChannelAnnouncement2
The latest version of the spec has the outpoint included in the
`channel_announcement2` message.
2025-10-01 13:13:32 +02:00
Elle Mouton
004a68e524 lnwire: add OutPoint type with TLV encoding support
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.
2025-10-01 13:13:32 +02:00
Elle Mouton
769b44bfc6 lnwire: shorten method name 2025-10-01 13:13:31 +02:00
George Tsagkarelis
68bd35f7ad lnwire: update tests for init message 2025-09-23 19:05:46 +02:00
George Tsagkarelis
7724d0fa6d lnwire: add custom records to init
Before calling the new interface we first add the ability for the peer
message itself to encode the new data records.
2025-09-23 19:02:59 +02:00
Elle
055fb436e1 Merge pull request #9175 from ellemouton/g175UpdateMessageStructure
lnwire+netann: update structure of g175 messages to be pure TLV
2025-09-22 10:04:44 +02:00
Yong
d1d3a82010 Merge pull request #9884 from ellemouton/relaxFeatureBitCheck
multi: use relaxed feature bit `Set` method for peer features
2025-09-10 17:22:16 +08:00
Elle Mouton
d61a8af4c4 lnwire: re-usable address descriptor parsers
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.
2025-09-03 08:32:37 +02:00
Elle Mouton
f0a20c9d04 netadd: split ValidatenodeAnn into sig and field checks
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.
2025-09-03 01:11:34 +00:00
Elle Mouton
670b26ba3d lnwire: add encoding/decoding for DNS addr
Co-authored-by: Elle Mouton <elle.mouton@gmail.com>
2025-09-02 17:51:31 +00:00
Mohamed Awnallah
a0057c2026 lnwire: add DNSAddress type 2025-09-02 17:51:31 +00:00
Mohamed Awnallah
7acd6018c9 lnwire: remove AddrLen helper
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>
2025-09-02 17:51:31 +00:00
Elle Mouton
b77b698b9d lnwire: update AnnounceSigs2 to use pure TLV 2025-09-01 12:10:30 +02:00
Elle Mouton
b6b764da71 lnwire+netann: update ChannelUpdate2
such that all fields are now TLV including the signature.
2025-09-01 12:10:30 +02:00
Elle Mouton
1f71f14587 lnwire+netann: update ChannelAnnouncement2 structure
Such that all fields are now TLV (including the signature).
2025-09-01 12:06:18 +02:00
Elle Mouton
5e7ca548aa lnwire: let ChannelID implement RecordProducer
So that we can use it as a TLV record type.
2025-09-01 11:05:23 +02:00
Elle Mouton
4addfd1d1f lnwire: introduce PureTLVMessage
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.
2025-09-01 11:04:47 +02:00
Olaoluwa Osuntokun
47e9f05ddf Merge pull request #10027 from yyforyongyu/dyn-bigsize-msg
Fix `ExtraData` field and use `BigSize` encodine
2025-07-16 10:56:30 -07:00
Elle Mouton
ed17574196 lnwire: fix RandNodeAlias to produce valid UTF-8
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.
2025-07-15 18:06:05 +02:00
yyforyongyu
7a9f197de8 lnwire: simplify dyn decode methods
Remove the unnecessary convertions as suggested by Gemini.
2025-07-11 04:11:31 +03:00
yyforyongyu
91797ad1d2 lnwire: patch test and fix extra data in DynCommit 2025-07-11 04:11:31 +03:00
yyforyongyu
e6ab37305c lnwire: add missing record LocalNonce
This record was never added to the `DynCommit`, but it's inherited from
the embedding msg `DynAck`.
2025-07-11 04:11:30 +03:00
yyforyongyu
f39c3679f2 lnwire: make LocalNonce an optional tlv record and fix extra data
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.
2025-07-11 04:11:30 +03:00
yyforyongyu
b7d2f68ed0 lnwire: patch uint test for DynAck 2025-07-11 04:11:30 +03:00
yyforyongyu
5961f7a1bd lnwire: add method ParseAndExtractExtraData
Similar to `ParseAndExtractCustomRecords`, we now add this helper method
to make sure the extra data is parsed correctly.
2025-07-11 04:11:30 +03:00
yyforyongyu
e94ca84449 lnwire: fix encoding of MilliSatoshi
`MilliSatoshi` itself is already a `BigSize`, we just need to change the
decoding and encoding types to use that.
2025-07-11 04:11:29 +03:00
yyforyongyu
5e9365552c lnwire: fix encoding ExtraData in DynPropose
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.
2025-07-11 04:11:29 +03:00
yyforyongyu
61ef83e9c2 lnwire: patch unit test for DynPropose 2025-07-11 04:09:11 +03:00
yyforyongyu
0f1cb54eb2 lnwire: use BigSize for encoding btc amount 2025-07-11 04:09:11 +03:00
Elle Mouton
8cf567b948 multi: use the "errors" package everywhere
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.
2025-06-30 09:46:55 +02:00
Elle Mouton
b41a079901 multi: use relaxed feature bit Set method for peer features
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.
2025-06-25 13:14:31 +02:00
yyforyongyu
c64e3a6c34 lnwire: fix linter 2025-06-25 14:53:22 +08:00
yyforyongyu
828486e35a lnwire: fix unit test for DynCommit 2025-06-25 14:53:20 +08:00
Keagan McClelland
a72cadf2ed lnwire: convert DynPropose and DynCommit to use typed tlv records 2025-06-25 02:22:22 +08:00
Keagan McClelland
79e4e74447 lnwire: change DynPropose/DynCommit TLV numbers to align with spec 2025-06-25 02:09:08 +08:00
Keagan McClelland
72582d4acc lnwire: add HtlcMinimum to DynPropose and DynCommit 2025-06-25 02:08:58 +08:00
Keagan McClelland
f40530e4f4 lnwire: remove FundingKey from DynPropose and DynCommit 2025-06-25 02:08:56 +08:00
Keagan McClelland
cbca5b1152 lnwire: remove kickoff feerate from propose/commit 2025-06-25 02:08:22 +08:00
Keagan McClelland
36f53d74ab lnwire: add convenience functions for protocol validation 2025-06-25 02:06:16 +08:00
yyforyongyu
42089b19d6 lnwire: add DynCommit message to match spec 2025-06-25 01:10:54 +08:00
Keagan McClelland
60887ad3ef lnwire: add signature to DynAck 2025-06-25 01:10:49 +08:00
Keagan McClelland
c6861770de lnwire: remove no longer used initiator field 2025-06-25 01:10:46 +08:00
Elle Mouton
667e0aadc3 lnwire: fix test data race
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.
2025-06-20 12:22:59 +02:00
Elle Mouton
420001a98c lnwire: add InboundFee TLV record to ChannelUpdate 2025-06-09 08:32:52 +02:00
Elle Mouton
412e05f85f lnwire: add *OpaqueAddrs case in WriteElements
And then expand the chanbackup unit tests to cover such a case.
2025-05-23 16:14:47 +02:00