Commit Graph

403 Commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun
57b7a668c0
lnwire: add new ChannelType field as TLV record to Open/AcceptChannel
In this commit, we add a new ChannelType field as a new TLV record to
the OpenChannel message. During this change, we make a few tweaks to the
generic TLV encode/decode methods for the ExtraOpaqueData struct to have
it work on the level of tlv.RecordProducer instead of tlv.Record, as
this reduces line noise a bit.

We also partially undo existing logic that would attempt to "prepend"
any new TLV records to the end of the ExtraOpaqueData if one was already
present within the struct. This is based on the assumption that if we've
read a message from disk to order to re-send/transmit it, then the
ExtraOpaqueData is fully populated so we'll write that as is. Otherwise,
a message is being encoded for the first time, and we expect all fields
that are known TLV fields to be specified within the struct itself.

This change required the unit tests to be modified slightly, as we'll
always encode a fresh set of TLV records if none was already specified
within the struct.
2021-08-30 19:17:21 -07:00
Olaoluwa Osuntokun
988d01de0d
lnwire: introduce new explicit ChannelType TLV record
In this commit, we add a new TLV record that's intended to be used as an
explicit channel commitment type for a new form of funding negotiation,
and later on a dynamic commitment upgrade protocol. As defined, we have
3 channel types: base (the OG), tweakless, and anchors w/ zero fee
HTLCs. We omit the original variant of anchors as it was never truly
deployed from the PoV of lnd.
2021-08-30 19:17:19 -07:00
yyforyongyu
2cf6969dbc
lnwire: refactor Encode to use specific writers - III
This commit refactors the remaining usage of WriteElements. By
replacing the interface types with concrete types for the params used in
the methods, most of the encoding of the messages now takes zero heap
allocations.
2021-08-10 05:36:09 +08:00
yyforyongyu
c1ad9cc60f
lnwire: refactor Encode to use specific writers - II
This commit takes another 10 message types and refactors their Encode
method to use specific writers. The following commit will refactor the
rest.
2021-08-10 05:36:09 +08:00
yyforyongyu
563ff7266a
lnwire: refactor Encode to use specific writers - I
This commit takes 10 types of messages and refactors their Encode method
to use specific writers. The following commits will refactor the rest.
2021-08-10 05:36:09 +08:00
yyforyongyu
f04410c546
lnwire: add independent writers
This commit breaks the method WriteElement and adds specific writers for
each of the data types.
2021-08-10 05:36:09 +08:00
yyforyongyu
e381b33b21
lnwire: fix typo in docs 2021-08-10 05:36:08 +08:00
yyforyongyu
aa1561c60d
lnwire: use write buffer in Encode methods
This commit changes the WriteElement and WriteElements methods to take a
write buffer instead of io.Writer. The corresponding Encode methods are
changed to use the write buffer.
2021-08-10 05:36:08 +08:00
yyforyongyu
f212f1aa20
lnwire: refactor WriteMessage to use bytes.Buffer
This commit changes the method WriteMessage to use bytes.Buffer to save
heap allocations. A unit test is added to check the method is
implemented as expected.
2021-08-10 05:36:08 +08:00
yyforyongyu
77862e45af
lnwire: add benchmark tests to ReadMessage and WriteMessage 2021-08-10 05:36:07 +08:00
yyforyongyu
4b12f40a48
lnwire: remove unused MaxMessagePayload const
MaxMessagePayload and MaxSliceLength are duplicate variables. This
commit deletes MaxMessagePayload and keeps MaxSliceLength.
2021-08-10 05:36:07 +08:00
Conner Fromknecht
438b03afa4
features: define temporary AMP feature bits 30/31 2021-04-07 12:08:34 -07:00
eugene
7ff04d8bad
lnwire: remove MaxPayloadLength from Message interface
Removes the MaxPayloadLength function from the Message interface
and checks that each message payload is not greater than MaxMsgBody.
Since all messages are now allowed to be 65535 bytes in size, the
MaxPayloadLength is no longer needed.
2021-03-04 16:48:10 -05:00
Johan T. Halseth
6842c0ba8c
lnwire: convert the delivery addr in [Open+Accept]Channel to a TLV type in ExtraData
In this commit, we convert the delivery address in the open and accept
channel methods to be a TLV type. This works as an "empty" delivery
address is encoded using a two zero bytes (uint16 length zero), and a
tlv type of 0 is encoded in the same manner (byte for type, byte for
zero length). This change allows us to easily extend these messages in
the future, in a uniform manner.

When decoding the message we snip the bytes from the read TLV data.
Similarly, when encoding we concatenate the TLV record for the shutdown
script with the rest of the TLV data.
2021-02-24 17:40:08 +01:00
Olaoluwa Osuntokun
9a6bb19770
lnwire: prep wire messages for TLV extensions
Messages:
- UpdateFulfillHTLC
- UpdateFee
- UpdateFailMalformedHTLC
- UpdateFailHTLC
- UpdateAddHTLC
- Shutdown
- RevokeAndAck
- ReplyShortChanIDsEnd
- ReplyChannelRange
- QueryShortChanIDs
- QueryChannelRange
- NodeAnnouncement
- Init
- GossipTimestampRange
- FundingSigned
- FundingLocked
- FundingCreated
- CommitSig
- ClosingSigned
- ChannelUpdate
- ChannelReestablish
- ChannelAnnouncement
- AnnounceSignatures

lnwire: update quickcheck tests, use constant for Error

multi: update unit tests to pass deep equal assertions with messages

In this commit, we update a series of unit tests in the code base to now
pass due to the new wire message encode/decode logic. In many instances,
we'll now manually set the extra bytes to an empty byte slice to avoid
comparisons that fail due to one message having an empty byte slice and
the other having a nil pointer.
2021-02-24 17:31:55 +01:00
Olaoluwa Osuntokun
a603ac4938
lnwire: create new ExtraOpaqueData type for parsing TLV extensions
In this commit, we create a new `ExtraOpaqueData` based on the field
with the same name that's present in all the announcement related
messages. In later commits, we'll embed this new type in each message,
so we'll have a generic way to add/parse TLV extensions from messages.
2021-02-24 17:31:55 +01:00
Olaoluwa Osuntokun
dd6f0ba931
discovery+lnwire: remove embedding within ReplyChannelRange
In order to prep for allowing TLV extensions for the `ReplyChannelRange`
and `QueryChannelRange` messages, we'll need to remove the struct
embedding as is. If we don't remove this, then we'll attempt to decode
TLV extensions from both the embedded and outer struct.

All relevant call sites have been updated to reflect this minor change.
2021-02-24 17:31:55 +01:00
Oliver Gugger
02267565fe
multi: unify code blocks in READMEs 2021-01-22 09:14:11 +01:00
Johan T. Halseth
abefa93065
lnwire+feature: define AnchorsZeroFeeHtlcTx feature 2020-12-15 10:13:04 +01:00
Johan T. Halseth
f6f3ab5b0b
Merge pull request #4829 from yyforyongyu/typo-fix
multi: Typo fix
2020-12-10 13:55:35 +01:00
yyforyongyu
be626df689
peer: use MaxMessagePayload instead of hard coding 2020-12-04 23:08:49 +08:00
yyforyongyu
550341c036
lnwire: fix typo 2020-12-04 23:07:53 +08:00
Olaoluwa Osuntokun
cefbf5f637
Merge pull request #4786 from wpaulino/rate-limit-channel-updates
discovery: rate limit incoming channel updates
2020-11-25 17:07:21 -08:00
Olaoluwa Osuntokun
baeceb2a0b
lnwire: add new RequiresFeature method
In this commit, we add a new RequiresFeature method to the feature
vector struct. This method allows us to check if the set of features
we're examining *require* that the even portion of a bit pair be set.
This can be used to check if new behavior should be allowed (after we
flip new bits to be required) for existing contexts.
2020-11-25 16:31:56 -08:00
Wilmer Paulino
791ba3eb50
discovery: rate limit incoming channel updates
This change was largely motivated by an increase in high disk usage as a
result of channel update spam. With an in memory graph, this would've
gone mostly undetected except for the increased bandwidth usage, which
this doesn't aim to solve yet. To minimize the effects to disks, we
begin to rate limit channel updates in two ways. Keep alive updates,
those which only increase their timestamps to signal liveliness, are now
limited to one per lnd's rebroadcast interval (current default of 24H).
Non keep alive updates are now limited to one per block per direction.
2020-11-25 15:38:08 -08:00
Johan T. Halseth
724f439b0b
lnwire: update anchor bit to spec 2020-09-11 11:10:58 +02:00
Bjarne Magnussen
954e292895
lnwire: fix minor typos in wumbo features 2020-07-20 08:36:39 +02:00
Olaoluwa Osuntokun
1b8fd008c4
lnwire: define feature bits for wumbo channels 2020-07-10 16:27:10 -07:00
nsa
cbd54101f8 multi: remove peer.go, change all references to point to peer pkg 2020-07-06 19:16:07 -04:00
Matheus Degiovani
44555a70ed lnwire: fix decoding for initial zero sid
This fixes a decoding error when the list of short channel ids within a
QueryShortChanIDs message started with a zero sid.

BOLT-0007 specifies that lists of short channel ids should be sorted in
ascending order. Previously, this was checked within lnwire by comparing
two consecutive sids in the list, starting at the empty (zero) sid.

This meant that a list that started with a zero sid couldn't be decoded
since the first element would _not_ be greater than the last one
(namely: also zero).

Given that one can only check for ordering starting at the second
element, we add a check to ensure the proper behavior.

A unit test is also added to ensure no future regressions on this
behavior.
2020-06-18 14:04:39 -03:00
Andras Banki-Horvath
556e3525ea misc: fix error formatting in multiple files 2020-04-24 19:15:08 +02:00
Conner Fromknecht
0f94b8dc62
multi: return input.Signature from SignOutputRaw 2020-04-10 14:27:35 -07:00
Conner Fromknecht
f6c194c3cd
netann/node_announcement: consolidate signing logic 2020-03-17 16:25:02 -07:00