Commit Graph

244 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
4dd108c827
lnwire: replace usage of btcec.Signature with the new lnwire.Sig type 2018-02-06 20:14:30 -08:00
Olaoluwa Osuntokun
0d7b8be11b
lnwire: add new Sig type to handle conversion to/from btcec.Signature
In this commit, we add a new signature type. We’ll use this type to
avoid fully decoding a signature on the wire into a btcec.Signature.
This type is only really needed when we need to do signature
validation, as a result, always encoding it is a waste. Several helper
methods have been added to the new struct in order to ensure that we
can use it in the existing codebase without substantial issues.
2018-02-06 20:14:26 -08:00
practicalswift
a93736d21e multi: comprehensive typo fixes across all packages 2018-02-06 19:11:11 -08:00
nsa
698df2ac16 torsvc: added new type that multiplexes torsvc and net packages
This commit adds the `lnnet` package which contains an
implementation of the newly created LightningNet interface which
multiplexes the Dial and DNS-related functions to use net
by default and torsvc if a flag is specified. This modularization
makes for cleaner code.
2018-02-05 17:37:46 -08:00
Benjamin Congdon
ecff8f2a07
lnwire: Trim zero-bytes from NodeAlias String representation
This commit alters the NodeAlias String method to trim null-bytes from
the end of the alias. This is helpful for presentation in contexts such
as the GetInfo response.
2018-01-18 07:39:37 -06:00
Olaoluwa Osuntokun
7e54b4ae46
lnwire: if unable to parse encapsulated error, log length and raw bytes
In this commit, we add additional detail in the error return hen were’e
unable to properly decode an encapsulated error. This additional
logging was added with the goal of being able to track down a lingering
bug, where at times lnd cannot decode a TemporaryChannelFailure
message.
2017-12-26 16:17:22 +01:00
Olaoluwa Osuntokun
ef2838fdd3
lnwire: log type of failure upon decode failure 2017-12-21 11:31:15 +01:00
Matt Drollette
adf0d98194 multi: fix several typos in godoc comments 2017-12-17 18:40:05 -08:00
Jim Posen
1328e61c00 htlcswitch: Change circuit map keys to (channel ID, HTLC ID).
This changes the circuit map internals and API to reference circuits
by a primary key of (channel ID, HTLC ID) instead of paymnet
hash. This is because each circuit has a unique offered HTLC, but
there may be multiple circuits for a payment hash with different
source or destination channels.
2017-12-14 17:53:58 -08:00
Olaoluwa Osuntokun
4b6ada98d6
lnwire: use color.RGBA instead of custom type in NodeAnnouncment 2017-12-02 18:23:10 -08:00
Olaoluwa Osuntokun
f196c72aa4
Merge pull request #439 from Roasbeef/copy-right
multi: retain original copyright on files copied/modified from btcsuite
2017-12-01 19:34:25 -08:00
Olaoluwa Osuntokun
5e3dbfcd78
lnwire: add new ChanUpdateFlag for the ChannelUpdate flag bitmask
In this commit, we add a new type to the lnwire package:
ChanUpdateFlag. This type represent the bitfield that’s used within the
ChannelUpdate message to give additional details as how the message
should be interpreted.
2017-11-30 22:21:37 -08:00
Olaoluwa Osuntokun
d0a356c948
lnwire: the FeePerKw is a uint32, not a btcutil.Amount 2017-11-30 22:07:47 -08:00
Olaoluwa Osuntokun
5b7abee92e
lnwire: correct incorrect type numbers for UpdateFee, Shutdown, and ClosingSigned
In this commit we correct an off by one error on the Shutdown and
ClosingSigned message types. Additionally, we fix an error related to
the numbering of the UpdateFee message. With this we, gain proper
compatibility with the other implementations when it comes to
commitment hygiene, and also the cooperative closure process.
2017-11-28 12:26:00 -08:00
Olaoluwa Osuntokun
0952b68e64
multi: retain original copyright on files copied/modified from btcsuite
Early in the lifetime of the project here were a few files we either
copied entirely, or used as the basis for code within lnd. Before this
PR, this was not recognized by retaining the original copyright. With
this commit, we remedy that by explicitly noting the copyright in the
relevant files.

Fixes #423.
2017-11-27 16:19:36 -08:00
Olaoluwa Osuntokun
a1c0e30051
lnwire: the FeeSatoshis field in the ClosingSigned message is now btcutil.Amount 2017-11-23 23:10:03 -06:00
Olaoluwa Osuntokun
53f1743be0
lnwire: fix serialization order of global+local features in Init msg
Fixes #428.
2017-11-17 13:27:23 -08:00
Olaoluwa Osuntokun
f7964e7474
lnwire: add observance of optional data loss fields to ChannelReestablish
In this commit, we add support within lnwire for the optional dataloss
fields in ChannelReestablish. With these fields, it’s possible to:
verify that the remote node really knows of the state of our prior
local commitment, and also that they’ve sent us the current commitment
point for their current state.

In the event of dataloss, it’s possible for the party which lost data
to claim their commitment output in the remote party’s commitment if
they broadcast their current commitment transaction.
2017-11-16 20:00:03 -08:00
Olaoluwa Osuntokun
a14a15641b lnwire: add new HtlcPoint to OpenChannel and AcceptChannel
In this commit, we begin implementing the latest spec change to reduce
the attack surface on online channels. In this commit, we introduce a
distinct HTLC base point which will be used to sign the second-level
HTLC transactions for each active HLTC on the commitment transaction of
the remote node. With this, we allow the commitment key to remain
offline, as it isn’t needed in routine channel updates, unless we need
to go to chain.
2017-11-16 19:59:50 -08:00
Laura Cressman
39d38da732 discovery: create deDupedAnnouncements struct in gosspier.go
For Part 1 of Issue #275. Create isolated private struct in
networkHandler goroutine that will de-duplicate
announcements added to the batch. The struct contains maps
for each of channel announcements, channel updates, and
node announcements to keep track of unique announcements.

The struct has a Reset method to reset stored announcements, an
AddMsg(lnwire.Message) method to add a new message to the current
batch, and a Batch method to return the set of de-duplicated
announcements.

Also fix a few minor typos.
2017-11-15 16:50:19 -08:00
Olaoluwa Osuntokun
6f51b941df
multi: fix linter errors 2017-11-10 19:51:13 -08:00
Olaoluwa Osuntokun
b1a6b877ce
lnwire: add additional comments to ChannelReestablish, rename fields 2017-11-10 19:50:51 -08:00
Andrey Samokhvalov
f29b4f60e4 lnwire: add BOLT#2 channel reestablish message
In this commit the reestablish message have been added, which serves as
channel state synchronization message. Before exchanging the messages
for particular channel peers have to send it to each other as the
first message in order to be sure that non of the updates have been
lost because of the previous disconnect.
2017-11-09 16:38:56 -08:00
Olaoluwa Osuntokun
9a2c2cdf86
lnwire: add new FundingFlag type for OpenChannel
In this commit we add a new type to the lnwire package: FundingFlag.
This type will serve as an enum to describe the possible flags that can
be used within the ChannelFlags field in the OpenChannel struct.

We also define the first assigned flag: FFAnnounceChannel, which
indicates if the initiator of the funding flow wishes to announce the
channel to the greater network.
2017-11-09 11:59:37 -08:00
Jim Posen
9fd77a6e40 multi: Update lnd to use new feature vector API. 2017-10-17 22:47:20 -07:00
Jim Posen
1633ab180f lnwire: New API for feature vectors.
This is a rewrite of feature vectors in lnwire. This has a few
benefits:

1) a simpler interface
2) separate structs for a plain set of feature bits and a feature
vector with associated feature names
their respective feature sets
3) loosened requirements that bits MUST be assigned in pairs
4) fix endianness of encoding/decoding
2017-10-17 22:47:20 -07:00
Olaoluwa Osuntokun
a7d846ac40
lnwire: add godoc comments for lnwire.FailureMessage 2017-10-10 22:19:20 -07:00
Olaoluwa Osuntokun
0c9384d991
lnwire: address linter error 2017-10-02 22:16:32 -07:00
Olaoluwa Osuntokun
ab4af750e0
lnwire: expand FailureMessage. Error() method to include error specific info 2017-10-02 22:14:09 -07:00
John Griffith
492f7fa52f lnwire: add Error() method to lnwire.FailureMessage 2017-10-02 22:12:24 -07:00
nsa
d65f17f1b1 fuzzing: fixed calculation of serializedSize() in features.go
This commit fixes an incorrectly calculated size of a
*FeatureVector in the serializedSize() function. go-fuzz
found that when calling NewFeatureVectorFromReader, if
a flag is invalid, it is not added to f.flags. However,
it will skip the index that wasn't included. This
becomes a problem when serializedSize() calculates the
length of f.flags via len() which can lead to an index
out of range since certain flags may be missing.
2017-09-19 16:21:31 -07:00
Johan T. Halseth
ff4ca664e3 lnwire: export SerializeSigToWire and DeserializeSigFromWire 2017-09-19 12:05:58 -07:00
Olaoluwa Osuntokun
f9ca4631ff
lnwire: fix linter error 2017-09-18 17:40:29 -07:00
Olaoluwa Osuntokun
6e7fcac1f5
lnwire: properly encode/decode addrs in NodeAnnouncement msg
This commit fixes an existing deviation in the way we encode+decode the
addresses within the NodeAnnouncement message with that of the
specification. Prior to this commit, we would encode the _number_ of
addresses, rather than the number of bytes it takes to encode all the
addresses.

In this commit, we fix this mistake by properly writing out the total
number of bytes, modifying our parsing to take account of this new
encoding.
2017-09-18 17:27:51 -07:00
Olaoluwa Osuntokun
dc39d3f2c5
lnwire: fix minor typo in tests 2017-09-18 19:46:16 +02:00
Olaoluwa Osuntokun
e3717485f5
lnwire: fix bug in wire.OutPoint -> lnwire.ChannelID conversion
This commit fixes an existing, unnoticed bug within the lnwire.
NewChanIDFromOutPoint function. Two lingering issues cause the function
to not do anything at all, meaning that the channel ID, would be the
exact same as the actual txid passed in.

The first issue was that the xorTxid function wasn’t actually XOR’ing
the last two bytes. This was due to the fact that the function wasn’t
taking a pointer to the target ChannelID, meaning that the mutation
wouldn’t be seen outside of the scope of the function. Second, we had
our slicing reversed, rather than buf[30:], we were using buf[:30],
meaning that we were weren’t properly filling the buffer with the lower
2-bytes of the passed index.
2017-09-18 19:45:11 +02:00
Olaoluwa Osuntokun
b58ef85513
lnwire: make test clause within TestChannelIDOutPointConversion stricter
This commit modifies the main test loop within
TestChannelIDOutPointConversion stricter. With this commit, we now
ensure that the conversion function actually does _something_. This is
the first in a series of commits to fix a recently discovered bug
within the outpoint to channel ID conversion routines.
2017-09-18 19:42:19 +02:00
nsa
d97575d6d2 lnwire: ensure that addrs in ClosedSigned are below 35 bytes
This is a very simple bug that go-fuzz found. If length of an address
within CloseSigned is greater than 34, a runtime error: slice bounds out
of range happens. An error should be returned instead.
2017-09-14 14:23:49 +02:00
Conner Fromknecht
8ef2263e46 lnwallet: move txout serialization out of lnwire 2017-09-14 13:56:25 +02:00
Mrmaxmeier
383b50acb8 fix typo in doc comment (1000 mSAT == 1 SAT) 2017-09-14 13:48:45 +02:00
Olaoluwa Osuntokun
a334025883
lnwire: swap order of MinAcceptDepth and HtlcMinimum
In this commit we reverse the ordering of the MinAcceptDepth and
HltcMinimum fields within the AcceptChannel message. Previously, the
order of these two fields were reversed, meaning the remote peer
would’ve attempted to parse the MinAcceptDepth (as we intended), as
part of the HtlcMinimum, leading to a garbage value.
2017-09-14 13:12:52 +02:00
Olaoluwa Osuntokun
9a93f83370
lnwire: fix ordering of the UpdateAddHTLC message on the wire
This commit fixes a diversion from the way the UpdateAddHTLC message is
defined within the specification. We had the HTLC expiry value in the
wrong place on the wire, which meant that we couldn’t parse the
messages as sent by the other LN implementations.
2017-09-12 17:58:48 +02:00
Olaoluwa Osuntokun
1e5949cfbb
lnwire: return more descriptive errors in DecodeFailure for onion errors 2017-09-12 17:55:25 +02:00
Dave Collins
42a263b29f wire: Correct fuzz test for MsgCommitSig.
This corrects the fuzz test in TestLightningWireProtocol for
MsgCommitSig to avoid creating an empty slice since the decoded message
only creates a slice when there are greater than zero signatures and an
empty slice is not considered equal to a nil slice under reflection.

This can be tested by running the TestLightningWireProtocol 1000 times
in a loop with and without this change.
2017-08-30 18:07:33 -07:00
Conner Fromknecht
6ffe33f01a lnw+ba+utxon+cdb: reverts OutPoint and TxOut encoding 2017-08-25 17:56:50 -07:00
Philip Hayes
f0aa186a56 channeldb+utxonursery+lnwire: use lnwire's OutPoint,TxOut serialization 2017-08-25 17:56:50 -07:00
Olaoluwa Osuntokun
2b2a3714c1
multi: fix linter errors 2017-08-22 01:00:12 -07:00
Olaoluwa Osuntokun
f47e7a9bf4
lnwire: update the ChannelAnnouncement message to match BOLT-0007 2017-08-22 00:52:07 -07:00
Olaoluwa Osuntokun
e93197b303
lnwire: add a ChainHash field to ChannelUpdate
This commit adds a ChainHash field to the ChannelUpdate message in
order to ensure that we’re compatible with the recent change to
BOLT-0007.
2017-08-22 00:52:04 -07:00
Olaoluwa Osuntokun
50c679afa3
lnwire: eliminate the ErrorCode field within the Error message
This commit does away with the ErrorCode field in order to ensure that
we’re properly compatible with BOLT-0002. In the future the error code
field may be re-introduced as it’s much easier to check against an
internet error rather than interpret a byte slice describing the error.
2017-08-22 00:52:02 -07:00