Commit Graph

536 Commits

Author SHA1 Message Date
Carla Kirk-Cohen
fd8381bf2a
lnwire: add invalid onion blinding error code 2023-12-12 09:44:05 -05:00
Elle Mouton
49a0370dcd
lnwire: add timestamps to ReplyChannelRange msg 2023-12-11 09:12:04 +02:00
Elle Mouton
4872010779
lnwire: sort scids before encoding
This is for later when the timestamps also need to be sorted according
to the SCIDs.
2023-12-11 09:12:04 +02:00
Elle Mouton
c882223ead
lnwire+discovery: rename ShortChannelIDEncoding to QueryEncoding
Since the the encoding can be used for multiple different fields, we
rename it here to be more generic.
2023-12-11 09:12:04 +02:00
Elle Mouton
341bae098c
lnwire: add QueryOptions to QueryChannelRange 2023-12-11 09:12:04 +02:00
Elle Mouton
8efd141347
lnwire: add QueryOptions type
This commit adds a new QueryOptions type which will later be used in the
QueryReplyRange message.
2023-12-11 09:12:03 +02:00
Keagan McClelland
9793fbb94b lnwire: add musig2 taproot execution messages for dynamic commitments 2023-11-10 13:29:52 -08:00
Keagan McClelland
564bf852bb lnwire: add fuzz tests for new dynamic commitment message types 2023-11-10 13:29:30 -08:00
Keagan McClelland
3e84d22eeb lnwire: add TLV extension to channel_reestablish for dynamic commitments 2023-11-10 13:29:30 -08:00
Keagan McClelland
e5f7ed8ba1 lnwire: introduce message types for dynamic commitment negotiation
lnwire: add tests for dynamic commitment wire serialization
2023-11-10 13:29:30 -08:00
Matt Morehouse
ed1b54ac3a
lnwire: use require package for onion failure fuzz tests 2023-10-27 14:52:00 -05:00
Matt Morehouse
a7ee45bea0
lnwire: add FuzzFailIncorrectDetails test
The test is identical to other onion failure fuzz tests, except that it
uses a custom equality function to get around the nil != []byte{} issue
with reflect.DeepEqual.
2023-10-27 14:52:00 -05:00
Matt Morehouse
2181fd432c
lnwire: fuzz onion failure messages
Fuzz tests for decoding and encoding of onion failure messages, based on
the fuzz harness for other lnwire messages. The onion failure messages
were uncovered by existing fuzz tests.
2023-10-27 14:12:41 -05:00
Matt Morehouse
3549e329df lnwire: encode channel_update type in onion errors
For about a year [1], the spec has prescribed encoding channel_updates
with their type prefix (0x0102) in onion failure messages. LND can
decode correctly with or without the prefix but hasn't been writing the
prefix during encoding. This commit starts writing the prefix.

[1] https://github.com/lightning/bolts/pull/979
2023-10-06 16:34:47 -07:00
Michael Rooke
78d9996620
trivial: Fix spelling errors
- Fixes some spelling in code comments and a couple of function names
2023-09-21 22:35:33 -04:00
Olaoluwa Osuntokun
92da6b1d44
multi: fix linter warnings with updated linter 2023-08-22 16:34:47 -07:00
Olaoluwa Osuntokun
384b1b1c12
feature: use +100 staging bit for taproot channels
In this commit, we carry out a new notion introduced during a recent
spec meeting to use a feature bit plus 100 before the feature has been
finalized in the spec.

We split into the Final and Staging bits.
2023-08-22 16:34:28 -07:00
Olaoluwa Osuntokun
9851a6147b
lnwire: TestLightningWireProtocol quick check tests for taproot fields 2023-08-22 16:29:49 -07:00
Olaoluwa Osuntokun
7ae4bf0672
lnwire: sort records in ExtractRecords
This ensures that the caller doesn't need to worry about the TLV type
ordering of the records the pass into the function.
2023-08-22 16:29:47 -07:00
Olaoluwa Osuntokun
25dfbadd23
lnwire: add ShutdownNonce to Shutdown 2023-08-22 16:29:45 -07:00
Olaoluwa Osuntokun
ca4609e394
lnwire: add LocalNonce to RevokeAndAck 2023-08-22 16:29:42 -07:00
Olaoluwa Osuntokun
4a62652ad2
lnwire: add PartialSig to CommitSig 2023-08-22 16:29:40 -07:00
Olaoluwa Osuntokun
5223b6f381
lnwire: add LocalNonce to ChannelReestablish 2023-08-22 16:29:38 -07:00
Olaoluwa Osuntokun
8afb60da17
lnwire: add LocalNonce to FundingLocked 2023-08-22 16:29:36 -07:00
Olaoluwa Osuntokun
79c473cc46
lnwire: add PartialSig to FundingSigned 2023-08-22 16:29:34 -07:00
Olaoluwa Osuntokun
292b8db8f0
lnwire: add PartialSig to FundingCreated 2023-08-22 16:29:31 -07:00
Olaoluwa Osuntokun
ee279fbde3
lnwire: add LocalNonce to AcceptChannel 2023-08-22 16:29:29 -07:00
Olaoluwa Osuntokun
7c5ba067ab
lnwire: add LocalNonce to OpenChannel 2023-08-22 16:29:27 -07:00
Olaoluwa Osuntokun
14949c972d
lnwire: add new musig2 partial signature type
In this commit, we add the new types that'll house musig signatures with
and without their nonces. We send the nonce along with the sig
everywhere but the co-op close flow.
2023-08-22 16:29:24 -07:00
Olaoluwa Osuntokun
5b7caaea6d
lnwire: add new Musig2Nonce TLV record 2023-08-22 16:29:22 -07:00
Olaoluwa Osuntokun
b368e476c5
lnwire: update Sig to support both ECDSA and schnorr sigs
In this commit, we update the Sig type to support ECDSA and schnorr
signatures. We need to do this as the HTLC signatures will become
schnorr sigs for taproot channels. The current spec draft opts to
overload this field since both the sigs are actually 64 bytes in length.
The only consideration with this move is that callers need to "coerce" a
sig to the proper type if they need schnorr signatures.
2023-08-22 16:29:19 -07:00
Olaoluwa Osuntokun
eccc77315b
lnwire: add feature bits for simple taproot chans 2023-08-22 16:29:17 -07:00
yyforyongyu
70bd6d1a11
lnwire: fix unit test flake for Ping message 2023-08-17 23:51:04 +08:00
Oliver Gugger
56dba2df03
multi: update linter, fix new issues 2023-06-13 11:58:33 +02:00
Matt Morehouse
460ba4ad82
lnwire: use require package for fuzz tests
Simplify code by using the require package instead of t.Fatal().
2023-05-23 08:37:22 -05:00
Matt Morehouse
e198e6693f
lnwire: add FuzzConvertFixedSignature test
Test conversion of fixed 64-byte signatures to DER-encoded signatures.
2023-05-12 11:07:57 -05:00
Matt Morehouse
a6a7066454
lnwire: add FuzzParseRawSignature test
Test parsing and serialization of raw DER-encoded signatures.
2023-05-12 11:07:54 -05:00
ziggie
8f4e9d68d0
lnwire_test: fix BenchmarkReadMessage test
The addition of AliasScid in the tlv_stream field of the
funding_locked msg made the requirement for testdata of the
ExtraOpaqueData part for the funding_locked msg type more strict.
Now the input testdata for the funding_locked test is more specific
and includes the new added AliasScid tlv record.
2023-05-09 16:47:44 +02:00
Carla Kirk-Cohen
019127c4f4
multi: add restriction on maximum feature bit in invoices
Base 32 encoded bolt 11 invoices only allow 10 bits to express the
length of the feature vector in a tagged field, so there is a much
lower limit on the values invoice custom features can hold.

Other places in the protocol are theoretically limited by the maximum
message size, but since we express a feature bit as u16 we don't need
to be concerned about this.

The decision is made to track maximum per-set in the feature manager,
which is conceptually aware of sets and then validate in lnwire/features
against some arbitrary maximum value provided to the caller to keep
the base features package unaware of sets.
2023-05-04 10:35:45 -04:00
Carla Kirk-Cohen
1a9d743e18
lnwire: add feature vector update validation helpers 2023-05-04 10:35:43 -04:00
yyforyongyu
dc3f83c670
funding+lnwire: rename and fix make lint
Fix linter and rename `funding_locked.go` to `channel_ready.go`
2023-03-17 18:21:59 +08:00
yyforyongyu
6b9217acfc
multi: replace FundingLocked related docs
This commit replaces `FundingLocked` found in docs using the following
command,
```shell
find . -name "*.go" -exec sed -i '' 's/FundingLocked/ChannelReady/g' {} \;
find . -name "*.go" -exec sed -i '' 's/FundingLock/ChannelReady/g' {} \;
```
2023-03-17 18:21:59 +08:00
yyforyongyu
f8a8326141
multi: replace FundingLocked and funding_locked strings
This commit is created by running the following commands,
```shell
find . -name "*.go" -exec sed -i '' 's/\"FundingLocked/\"ChannelReady/g' {} \;
find . -name "*.go" -exec sed -i '' 's/FundingLocked\"/ChannelReady\"/g' {} \;
find . -name "*.go" -exec sed -i '' 's/\ funding_locked/\ channel_ready/g' {} \;
```
2023-03-17 18:21:59 +08:00
yyforyongyu
015446559b
funding+lnwire: rename FundingLocked related tests
This commit is created by running the following commands,

```shell
gofmt -d -w -r 'fundingLockedAlice -> channelReadyAlice' .
gofmt -d -w -r 'fundingLockedBob -> channelReadyBob' .
gofmt -d -w -r 'assertHandleFundingLocked -> assertHandleChannelReady' .
gofmt -d -w -r 'assertFundingLockedSent -> assertChannelReadySent' .
gofmt -d -w -r 'aliceFundingLocked -> aliceChannelReady' .
gofmt -d -w -r 'bobFundingLocked -> bobChannelReady' .
gofmt -d -w -r 'FuzzFundingLocked -> FuzzChannelReady' .
gofmt -d -w -r 'newMsgFundingLocked -> newMsgChannelReady' .
gofmt -d -w -r 'TestFundingManagerReceiveFundingLockedTwice -> TestFundingManagerReceiveChannelReadyTwice' .
gofmt -d -w -r 'TestFundingManagerRestartAfterReceivingFundingLocked -> TestFundingManagerRestartAfterReceivingChannelReady' .
```
2023-03-17 18:21:59 +08:00
yyforyongyu
2dc08a2a76
multi: rename NewFundingLocked to NewChannelReady
This commit is created by the following command,

```shell
gofmt -d -w -r 'NewFundingLocked -> NewChannelReady' .
```
2023-03-17 18:21:58 +08:00
yyforyongyu
c8e8358918
channeldb+lnwire: rename MsgFundingLocked to MsgChannelReady
This commit is created by running,

```shell
gofmt -d -w -r 'MsgFundingLocked -> MsgChannelReady' .

gco master channeldb/migration
```
2023-03-17 18:21:58 +08:00
yyforyongyu
1b7c56b2ed
multi: rename FundingLocked to ChannelReady
This commit is created by running,

```shell
gofmt -d -w -r 'FundingLocked -> ChannelReady' .

gco master channeldb/migration
```
2023-03-17 18:21:58 +08:00
bitromortac
dd5273c88c
multi: rename due to required maxHTLC bit
We rename `ChanUpdateOptionMaxHtlc` to `ChanUpdateRequiredMaxHtlc`
as with the latest changes it is now required.

Similarly, rename `validateOptionalFields` to
`ValidateChannelUpdateFields`, export it to use it in a later commit.
2023-02-21 11:10:39 +01:00
ziggie
88a8c6618d
lnwire: add custom message to fuzz tests 2023-01-21 08:46:55 +01:00
Carla Kirk-Cohen
93dcbd7ea3
lnwire: allow overriding of protocol messages outside of custom range
Add the ability to specify messages < CustomRangeStart that will still
be treated like custom messages by lnd (rather than unknown ones). This
allows code external to lnd to handle protocol messages that are *not
yet known to lnd*.
2023-01-05 12:05:04 -05:00
Carla Kirk-Cohen
610f5d2140
lnwire: make custom type start a constant 2023-01-05 12:05:03 -05:00
Oliver Gugger
04dc37e463
lnwire: remove nolint comment 2023-01-05 08:49:31 +01:00
Joost Jager
3835b903a9
lnwire: limit channel update reader
Fixes a bug where channel update data is read until the end of the stream
rather than stopping after the specified length. This is problematic
when failure message tlv data is present, because this data is interpreted
as channel update tlv data.
2023-01-04 13:32:52 +01:00
eugene
032632b4e0
multi: update to tlv/v1.1.0 and use new *P2P tlv decoding variants
This changes the call-sites in several places to use the *P2P variants
to not trigger an OOM on untrusted input. This makes the code safe with
the new tlv version. Note that the call-sites prior to this change were
also safe.
2022-12-05 09:32:56 -05:00
Joost Jager
4c8ea29336
lnwire: allow longer failure messages
This fixes an incompatibility where lnd enforces a strict 256 byte
failure message, where as the spec sets this only as the recommended
length.
2022-12-02 14:27:59 +01:00
Joost Jager
5ff5838d74
lnwire: add extra opaque data to FailIncorrectDetails 2022-12-02 09:28:03 +01:00
Joost Jager
9730bc1ca0
lnwire: verify failure message length
Adds extra checks to make sure the failure message
is well-formed.
2022-12-02 09:04:59 +01:00
Matt Morehouse
f0f99d7e36
lnwire: add fuzz test for Warning 2022-11-11 11:56:49 -06:00
Matt Morehouse
258cf6466d
lnwire: add benchmark for Warning 2022-11-11 11:56:49 -06:00
Matt Morehouse
e15d3e898e
brontide,lnwire,wtwire,zpay32: appease linter
Address all linter complaints for the newly migrated fuzz tests.
2022-11-11 08:44:30 -06:00
Matt Morehouse
5a48568806
brontide,lnwire,wtwire,zpay32: use CamelCase
Rename fuzz test functions to use CamelCase.
2022-11-11 08:44:24 -06:00
Conner
3d4d8cd6cc
lnwire: migrate fuzz tests 2022-11-11 08:43:32 -06:00
Oliver Gugger
84401f6f6c
Merge pull request #7039 from TonyGiorgio/sync-7034
Remove ErrSynchronizingChain
2022-10-31 08:35:48 +01:00
habibitcoin
0b1e881d18
scripted-diff: replace ⛰ emoji with $ [skip ci]
-BEGIN VERIFY SCRIPT-
sed -i 's/⛰/$/g' $(git grep -l '⛰')
-END VERIFY SCRIPT-
2022-10-28 12:06:49 -04:00
Tony Giorgio
09537596fc
funding+lnwire: remove ErrSynchronizingChain 2022-10-28 10:06:59 -05:00
positiveblue
4d4d8e480c
multi: stop casting peer warning messages as errors
Split the logic for processing `error` and `warning` messages from our
peers.
2022-10-26 08:09:08 -07:00
positiveblue
fbe79811cf
invoicesrpc: refactor addinvocie hop hint selection
In order to reduce the number of calls to the db we try to process as
few channels as we can + try to not do extra work for each of them.

- First fetch all the channels. Then, filter all the public ones and
  sort the potential candidates by remote balance.

- Filter out each potential candidate as soon as possible.

- Only check the alias if the channel supports scid aliases.

- Because we sort the channels by remote balance, we will hit the
  target amount, if possible, as soon as we can.

We do not want to leak information about our remote balances, so we
shuffle the hop hints (the forced ones go always first) so the invoice
receiver does not know which channels have more balance than others.
2022-09-30 06:55:10 -07:00
yyforyongyu
0735522194
multi: fix make fmt 2022-08-23 22:10:24 +08:00
Olaoluwa Osuntokun
5f9c1b902f
lnwire+feature: add awareness of option_shutdown_anysegwit
In this commit, we add awareness of the option_shutdown_anysegwit that
permits both sides to send newer segwit based addresses. This'll
eventually enable us to send taproot addresses for co-op close.
2022-08-10 18:44:26 -07:00
eugene
3ff8eb899c
lnwire: add alias to FundingLocked in TLV
This adds an optional short channel id field to the FundingLocked
message that is sent/received as a TLV segment inside the
ExtraOpaqueData field.
2022-07-07 17:10:27 -04:00
eugene
a6c62eb71e
lnwire+feature: new zero-conf, scid-alias feature bit + chantypes
This defines the zero-conf feature bit, the scid-alias feature bit,
the zero-conf channel type, and the scid-alias channel type. It also
defines the dependency "tree" that exists for the feature bits.

The scid-alias feature bit signals that the node requires an alias
short channel id to be sent in funding_locked. The scid-alias channel
type requires that the channel is private, in addition to some other
forwarding-related privacy measures.
2022-07-07 17:10:24 -04:00
Olaoluwa Osuntokun
7b56b67f34
Merge pull request #6546 from carlaKC/bolts-950-warningmessage
lnwire/peer: add ability to read + log peer warning messages
2022-06-30 16:56:20 -07:00
Tommy Volk
9a10c80bcb multi: move many t.Fatalf calls to require.NoError 2022-06-17 04:26:55 +00:00
Carla Kirk-Cohen
f5ef4992e0
lnwire: add warning message wrapping existing Error message structure
This commit adds Warning messages to lnwire, as introduced in bolts/950.
It does not include reading/writing of warning messages, which will be
covered in followup commits.
2022-05-16 13:51:29 -04:00
Olaoluwa Osuntokun
8c3b9e7153
Merge pull request #6435 from ellemouton/ignoreUnknownAddressInNA
lnwire: ignore unknown addresses in NodeAnnouncement
2022-05-05 15:54:31 -07:00
Oliver Gugger
bdd1c5c4e1
Merge pull request #6423 from tvolk131/fix_typos
Typo fixes and code cleanup
2022-05-05 09:42:39 +02:00
Elle Mouton
f40e2687ac
lnwire: add randOpaqueAddrs for fuzz test
Let TestLightningWireProtocol also include random OpaqueAddrs.
2022-05-04 11:06:11 +02:00
Elle Mouton
1477c754f5
lnwire: store unknown address type as OpaqueAddrs
Instead of erroring out with encountering an address with an unknown
type, we just store the remainder of the addrBytes as OpaqueAddrs so
that we are able to rewrite them to the wire when we re-propagate the
message.
2022-05-04 11:06:11 +02:00
Elle Mouton
fa0512f62f
lnwire: add new type OpaqueAddrs
In this commit, a new net.Addr implementation called OpaqueAddrs is
added along with a WriteOpaqueAddrs func that is called in
WriteNetAddrs. It will be used to store any address bytes that we cannot
parse due to us not being aware of the address type.
2022-05-04 11:06:11 +02:00
Elle Mouton
f77388e072
lnwire: add TestDecodeUnknownAddressType
Add a test to demonstrate that if a NodeAnnouncement includes an address
with an unknown type, then we incorrectly return an error. This will be
fixed in the following commit.
2022-05-04 11:06:10 +02:00
Tommy Volk
5ae2ce984e multi: typo fixes [skip ci] 2022-05-03 20:55:40 +00:00
Elle Mouton
c54cc6e841
multi: announce Keysend feature bit
In this commit, we add the keysend feature bit to our NodeAnnouncement
if the accept-keysend option is set.
2022-04-14 14:01:19 +02:00
Joost Jager
9195f29e61
routing+channeldb: send payment metadata from invoice 2022-04-13 22:55:40 +02:00
yyforyongyu
19b2236570
lnwire: add length validation in NewSigFromRawSignature 2022-03-11 12:31:49 +08:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Oliver Gugger
895a2e497b
multi: formatting and comment fixes 2022-02-10 11:02:02 +01:00
Oliver Gugger
dfdc2bff8b
multi: run gosimports 2022-02-10 11:02:01 +01:00
Rafe
62dc1b5323 multi: Update Licenses to 2022 [skip ci] 2022-02-09 00:25:20 +02:00
Olaoluwa Osuntokun
3481286ea0
lnwire+peer: clamp pong bytes, make ping handler more effcieint
This was not properly enforced and would be a spec violation on the
peer's end. Also re-use a pong buffer to save on heap allocations if
there are a lot of peers. The pong buffer is only read from, so this
is concurrent safe.
2022-01-13 15:01:18 -08:00
naveen
87a0e52464
multi: Removed deprecated interfacer linter
Removed the deprecated interfacer linter from being called for linting.

Also removed the `nolint:interfacer` within the code.

https://github.com/lightningnetwork/lnd/issues/5741
2022-01-11 14:08:18 +01:00
naveen
545e84f4ce
multi: formatting changes 2022-01-11 14:08:17 +01:00
Olaoluwa Osuntokun
60a1f2d8d9
Merge pull request #5874 from Roasbeef/chan-type-feature-bit-fix
lnwire: switch chan_type feature to bits 44/45
2021-10-25 14:19:29 -07:00
Wilmer Paulino
6252563bc5
lnwire: add LeaseExpiry custom record for Open+AcceptChannel 2021-10-19 18:30:17 -07:00
Wilmer Paulino
6052a446dc
lnwire+feature: add feature bit for script enforced lease support 2021-10-19 18:30:14 -07:00
Olaoluwa Osuntokun
028fc86e5c
lnwire: switch chan_type feature to bits 44/45
We were using an older feature bit that was just "selected". This commit
has us use the feature bit officially included in the spec.

See https://github.com/lightningnetwork/lightning-rfc/pull/906
2021-10-19 17:40:33 -07:00
Joost Jager
ade50d0b2c
lnrpc: receive custom message 2021-10-15 17:08:55 +02:00
Joost Jager
ae959b16ae
lnrpc: send custom message 2021-10-15 17:08:53 +02:00
Oliver Gugger
e79d59dd4c
multi: use key locator for lnwallet.MessageSigner
To simplify the message signing API even further, we refactor the
lnwallet.MessageSigner interface to use a key locator instead of the
public key to identify which key should be signed with.
2021-10-08 12:06:52 +02:00
Wilmer Paulino
031d7b1d55
lnwire: extend RawFeatureVector with helper methods 2021-08-30 19:17:31 -07:00
Olaoluwa Osuntokun
d0779e2ec2
lnwire: add new feature bits for explicit channel type negotiation
If these bits are present, then both sides can examine the new
CommitmentType TLV field that's present and use this in place of the
existing implicit commiment type negotiation. With this change, it's now
possible to actually deprecate old unsupported commitment types
properly.
2021-08-30 19:17:24 -07:00