Commit Graph

571 Commits

Author SHA1 Message Date
Elle Mouton
9b877b94c3 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-07-01 20:08:12 +02:00
Elle Mouton
c79daf68fa lnwire: add *OpaqueAddrs case in WriteElements
And then expand the chanbackup unit tests to cover such a case.
2025-06-04 12:16:09 +02:00
Elle Mouton
2530ab13c7 lnwire: remove duplicated logic
Use existing serialisation helpers for serialising TC Pand Onion
addresses in WriteElement.
2025-06-04 12:16:09 +02:00
Elle Mouton
ad38ed73c7 go.mod+lnwire: bump TLV dep and fix MilliSatoshi Record
In this commit, we update the `tlv` package version which includes type
constraints on the `tlv.SizeBigSize` method parameter. This exposes a
bug in the MilliSatoshi Record method which is fixed here.

This was not caught in tests before since currently only
our TLV encoding code makes use of this SizeFunc (so we would write 0
size to disk) but then when we read the bytes from disk and decode, we
dont use the SizeFunc and our MilliSatoshi decode method makes direct
use of the `tlv.DBigSize` function which _currently does not make use of
the `l` length variable passed to it_. So it currently does correctly
read the data.
2025-05-07 19:36:25 +02:00
xinhangzhou
b7e3c20383 refactor: use maps.Copy for cleaner map handling
Signed-off-by: xinhangzhou <shuangcui@aliyun.com>
2025-03-25 01:19:55 +08:00
Olaoluwa Osuntokun
05a6b6838f lnwire: add new TestSerializedSize method
This uses all the interfaces and implementations added in the prior test.
2025-03-20 18:28:53 -07:00
Olaoluwa Osuntokun
b2f24789dc lnwire: revamp TestLightningWireProtocol using new rapid test gen
With what we added in the prior commit, we can significantly shrink the
size of this test. We also make it easier to extend in the future, as
this will fail if a new message is added, that doesn't have the needed
methods, as long as MsgEnd is updated.
2025-03-20 18:28:23 -07:00
Olaoluwa Osuntokun
eb877db2ff lnwire: add new TestMessage interface for property tests
In this commit, we add a new `TestMessage` interface for use in property
tests. With this, we'll be able to generate a random instance of a given
message, using the rapid byte stream. This can also eventually be useful
for fuzzing.
2025-03-20 18:28:07 -07:00
Olaoluwa Osuntokun
56a100123b lnwire: add new SerializedSize method to all wire messages
This'll be useful for the bandwidth based rate limiting we'll implement
in the next commit.
2025-03-20 18:27:52 -07:00
Olaoluwa Osuntokun
14eca4406e lnwire: update closing_complete and closing_sig to latest spec draft
Both these messages now carry the address of both parties, so you can
update an address without needing to send shutdown again.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
752fc86c7d lnwire: add feature bits for new rbf coop close 2025-03-18 11:44:20 -05:00
Elle Mouton
c5cff4052b lnwire_test: fix test doc string
This test started out demonstrating a bug. But that bug has since been
fixed. Fix the comment to reflect.
2025-02-05 08:17:42 +02:00
Nishant Bansal
7f8e89f3b4 lnwire: add 'x' separator in ShortChannelID method
Add the `AltString` method for `ShortChannelID` to produce a
human-readable format with 'x' as a separator
(block x transaction x output).

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
2025-01-15 15:25:40 +05:30
Olaoluwa Osuntokun
540d3c0fc7 multi: switch to lock time from sequence for coop close v2 2024-12-10 23:07:01 +01:00
Olaoluwa Osuntokun
fb429d658b Merge pull request #9330 from ProofOfKeags/update/fn2
multi: update to fn v2
2024-12-09 12:56:23 +01:00
Keagan McClelland
ed2989ae33 multi: update to fn v2 2024-12-04 13:19:00 -07:00
yyforyongyu
d108e14c5d multi: rename lll to ll and remove unused nolint 2024-12-04 07:20:59 +08:00
Elle Mouton
ab7aae0708 multi: rename nolint:lll to nolint:ll
Find and replace all nolint instances refering to the `lll` linter and
replace with `ll` which is the name of our custom version of the `lll`
linter which can be used to ignore log lines during linting.

The next commit will do the configuration of the custom linter and
disable the default one.
2024-12-02 09:14:21 +02:00
Keagan McClelland
7a5b55a473 lnwire: signal that we support quiescence 2024-11-26 13:51:56 -07:00
Keagan McClelland
c9debea408 lnwire: add IsChannelUpdate function to distinguish channel updates 2024-11-26 13:51:56 -07:00
Carla Kirk-Cohen
f02bb58486 multi: add experimental endorsement feature bit and disable option 2024-11-22 09:16:58 -05:00
Carla Kirk-Cohen
774bfa740a htlcswitch: relay experimental endorsement signal with update_add_htlc 2024-11-22 09:16:56 -05:00
Matt Morehouse
75bdf2d252 lnwire: use assertEqualFunc in onion failure harness
Simplifies the code slightly and improves the error message printed if
the original and deserialized messages do not match.
2024-11-13 10:25:16 -06:00
Matt Morehouse
d0e6a7a37b lnwire: adapt harness for custom equality funcs
There are several fuzz targets that can't use the standard require.Equal
check for various reasons. By adapting the harness to accept a custom
equality function, we can reduce code duplication in these targets.
2024-11-13 10:25:16 -06:00
Matt Morehouse
b9381acb2d lnwire: move message prefixing to the harness
The prefixing is done every time the harness is used, so it may as well
reside in the harness itself.
2024-11-13 10:25:16 -06:00
Matt Morehouse
b7a1a1e9b8 lnwire: s/harness/wireMsgHarness
This slightly more descriptive name distinguishes the wire message
harness from the onion failure harness while also obviating the
repetitive comments at every call site.
2024-11-13 10:25:16 -06:00
Matt Morehouse
4097527efc lnwire: remove superfluous "Prefix with..." comments
These comments add nothing of value since the following line is always
self-documenting:

  data = prefixWithMsgType(data, MsgTypeToBePrefixed)
2024-11-13 10:25:12 -06:00
Matt Morehouse
4f7267ecea lnwire: add fuzz target for Fee TLV
The new Fee TLV is not included in any other messages within the lnwire
package, so it currently has no fuzzing coverage.  This fuzz target
directly tests the encoding/decoding of the TLV to get some coverage.
2024-11-08 15:03:30 -06:00
Matt Morehouse
f1b7d52308 lnwire: add fuzz target for Schnorr sig conversion
Analogous to FuzzConvertFixedSignature but for Schnorr signatures.
2024-11-08 15:01:48 -06:00
Matt Morehouse
b82ae51a0b lnwire: add fuzz target for route blinding message
Add a simple decode/encode target for the FailInvalidBlinding message.
2024-11-08 15:00:06 -06:00
Matt Morehouse
2784da13f8 lnwire: add fuzz targets for gossip 1.75 messages
Add simple decode/encode targets for AnnouncementSignatures2,
ChannelAnnouncement2, and ChannelUpdate2.
2024-11-08 14:57:13 -06:00
Elle Mouton
a5f3fa17e7 lnwire21: update Msat and TrueBoolean
Add the TrueBoolean type along with its Record method. Also update the
Millisatoshi type with a Record method. Both of these will be used in an
upcoming commit which adjusts a mission control migration to use pure
TLV types.
2024-11-01 08:59:54 +02:00
Olaoluwa Osuntokun
7f9268c38f lnwire: add new taproot chans overlay feature bit 2024-10-02 18:10:04 -07:00
Olaoluwa Osuntokun
bf0bd64023 lnwire: modify TestLightningWireProtocol to use sub-tests
This way, it's possible to run induvidual tests to target failures.
2024-10-02 18:09:48 -07:00
Olaoluwa Osuntokun
099f5566bc lnwire: add CustomRecords to shutdown message 2024-09-19 10:18:39 +02:00
Oliver Gugger
83923c7f33 lnwire: add MergedCopy method to CustomRecords 2024-09-19 09:21:38 +02:00
Oliver Gugger
cdad5d988d Merge pull request #9072 from lightningnetwork/extract-part3-from-staging-branch
[custom channels 3/5]: Extract PART3 from mega staging branch
2024-09-19 01:20:55 -06:00
Elle Mouton
580c10477f lnwire: add ChannelUpdate2
Add the new ChannelUpdate2 message and ensure that it implements the
ChannelUpdate interface.
2024-09-18 16:20:28 +02:00
Elle Mouton
a438eb3af3 lnwire: add ChannelAnnouncement2 message
And ensure that it implements the ChannelAnnouncement interface.
2024-09-18 16:14:59 +02:00
Elle Mouton
66302ceb29 lnwire: make RawFeatureVector a Record producer 2024-09-18 16:14:58 +02:00
Elle Mouton
0b4e5a0d83 lnwire: add AnnounceSignatures2 message
And ensure that it implements the AnnounceSignatures interface.
2024-09-18 16:14:58 +02:00
Elle Mouton
34e9ee1ee5 lnwire: lnwire: add a ChannelUpdate interface
In this commit, a new ChannelUpdate interface is added and
ChannelUpdate1 is made to implement the new interface.
2024-09-18 16:14:58 +02:00
Elle Mouton
e07d23567c lnwire: add a ChannelAnnouncement interface
Add a new ChannelAnnouncement interface and ensure that
ChannelAnnouncement1 implements it.
2024-09-18 16:13:17 +02:00
Elle Mouton
f230e2c574 lnwire: add AnnounceSignatures interface
Add a AnnounceSignatures interface and ensure that AnnounceSignatures1
implements it.
2024-09-18 16:13:17 +02:00
Elle Mouton
df65b7cad9 lnwire: add FirstBlock and BlockRange to GossipTimestampRange
Add new FirstBlockHeight and BlockRange TLV fields to the
GossipTimestampRange message. This will be used to query for Gossip 1.75
messages which are timestamped using block height instead of Unix
timestamps.
2024-09-18 16:13:17 +02:00
Elle Mouton
60b0e46c36 lnwire: add btc and node announcement nonces to channel_ready
In preparation for Gossip 1.75, we add new TLV's to the `ChannelReady`
message. Namely: `AnnouncementBitcoinNonce` and `AnnouncementNodeNonce`.
These will be used to exchange nones required for producing the partial
signature to be send in the `AnnouncementSignatures2` message.
The type numbers for these new fields are even because if they are set,
then a peer is expecting its peer to understand gossip 1.75 and the new
fields.
2024-09-18 16:13:17 +02:00
Elle Mouton
60f331edb1 multi: rename ChannelUpdate to ChannelUpdate1
In preparation for adding a new ChannelUpdate2 message and a
ChannelUpdate interface, we rename the existing message to
ChannelUpdate1.
2024-09-18 16:13:17 +02:00
Elle Mouton
bb44efa21f multi: rename ChannelAnnouncement to ChannelAnnouncment1
In preparation for adding the new ChannelAnnouncement2 message along
with a ChannelAnnouncement interface, we rename the existing message to
ChannelAnnouncement1.
2024-09-18 16:13:17 +02:00
Elle Mouton
05d76b696d multi: rename AnnounceSignatures to AnnounceSignatures1
In preparation for adding a new message, AnnounceSignatures2 along with
an AnnounceSignatures interface, we rename the existing message to
AnnounceSignatures1.
2024-09-18 16:13:16 +02:00
Oliver Gugger
bd84fd256e lnwire: add custom records field to type CommitSig 2024-09-18 10:25:42 +02:00