Commit Graph

224 Commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun 29af6e6932
lnwire: shift fields in NodeAnnouncment to match recent BOLT-0007 changes
This commit modifies the NodeAnnouncement message to ensure that it
matches the current spec ordering. The spec was recently modified to
place the feature vector first to allow for future changes to the
fields to be forwards compatible.
2017-08-22 00:51:59 -07:00
Olaoluwa Osuntokun 96696ccd99
lnwire: update node alias type to respect utf8, use full 32 bytes 2017-08-22 00:51:56 -07:00
Olaoluwa Osuntokun 1d1f9f1724
lnwire: update onion error encoding/decoding to match BOLT-0004
This commit updates the encoding/decoding for the onion errors to
properly match BOLT-0004. This commit does to major things: we increase
the max message size to 256 bytes to account for recent modifications
to the ChannelUpdate message, and also fold in the error code into the
failure message encapsulation itself.
2017-08-22 00:51:53 -07:00
Olaoluwa Osuntokun b174ae80bf
lnwire: convert all relevant fields to use the MilliSatoshi type 2017-08-22 00:51:51 -07:00
Olaoluwa Osuntokun 05d05ac5ee
lnwire: introduce new lnwire.MilliSatoshi type
This commit adds a new type to the lnwire package: MilliSatoshi. A
milli-satoshi is simply 1/1000th of a satoshi, and will be used for all
internal accounting when sending payments, calculating fees, updating
commitment state, etc. Two helper methods are added: ToBTC(), and
ToSatoshis() to make manipulation of the values easy.
2017-08-22 00:51:48 -07:00
Olaoluwa Osuntokun 50d521ba8c
lnwire: add a case in MessageType.String() for UpdateFee 2017-08-22 00:51:46 -07:00
Olaoluwa Osuntokun 8cda421784
lnwire: add new error code for rejecting a channel that's too large 2017-08-07 16:31:22 -07:00
Olaoluwa Osuntokun de30c14aea
lnwire: update testing/quick tests to new wire message updates 2017-07-30 17:47:55 -07:00
Olaoluwa Osuntokun f7800709ba
lnwire: use %v instead of %x when printing length of oversized msg 2017-07-30 17:47:51 -07:00
Olaoluwa Osuntokun 53f45e8210
lnwire: update MessageType definition to include new funding messages 2017-07-30 17:47:48 -07:00
Olaoluwa Osuntokun 364a9a8059
lnwire: add a HtlcSigs field to the CommitSig message
This commit adds a new field to the CommitSig message: HtlcSigs. This
new field will house signatures for each of the HTLC’s on the newly
created commitment state. This addition allows us to implement the new
commitment transaction structure outlined within the specification
which modifies HTLC’s such that the claiming process is now a two-phase
process. The first state transitions an HTLC to the delay+claim state,
and the second state (after the delay has passed) allows the
broadcaster of the commitment transaction to sweep the HTLC’s.

Fixes #61.
2017-07-30 17:47:44 -07:00
Olaoluwa Osuntokun be67bd46cd
lnwire: add a case for a slice of signatures to readElement/writeElement
This commit modifies the readElement and writeElement functions to add
the capability of reading/writing a slice of btcec.Signature. This new
case is required for the upcoming commit which will modify the
CommitSig message to include a field which houses signatures of reach
HTLC on the commitment transaction.
2017-07-30 17:47:40 -07:00
Olaoluwa Osuntokun 7f36b70a4a
lnwire: add new single funder messages from specification
This commit adds the new set of single funder messages from the
specification. As a result, after this commit and a follow up, all of
our messages will directly line up with those that are detailed within
the specification.

The new set of funding messages are very similar to our prior ones,
aside from the main difference of the addition of several channel level
constraints that give nodes control over their exposure, throughput,
and other values.
2017-07-30 17:47:37 -07:00
Olaoluwa Osuntokun 2263a6a1b7
lnwire: modify RevokeAndAck to remove NextRevocationHash
This commit modifies the RevokeAndAck message in order to bring it more
in line with the current draft of the specification. The prior version
was based on a version that used a revocation hash for HTLC’s and a
revocation key for commitment outputs. The current commitment design
uses revocation keys uniformly throughout.
2017-07-30 17:47:33 -07:00
Olaoluwa Osuntokun b2d86bffc5
lnwire: remove deprecated single funding wire messages
This commit removes the original single funder wire messages as they’ve
now been deprecated by the new commitment and HTLC structure within the
latest draft of the specification.
2017-07-30 17:47:29 -07:00
Olaoluwa Osuntokun a04fa76a4c
lnwire+htlcswitch: minor grammatical, formatting fixes after error PR 2017-07-14 20:08:37 -07:00
Andrey Samokhvalov 46ba18db9b lnwire: add update_fail_malformed_htlc message
In this commit BOLT#4 specification message have been added to the
lnwire package. This messsage is needed in order to notify payment
sender that forwarding node unable to parse the onion blob.
2017-07-14 19:08:04 -07:00
Andrey Samokhvalov 98956bc2fe lnwire: add specification onion errors
In this commit onion routing error from BOLT#4 have been added, the
initial error construction have been splitted on two parts: The first
part which contains the actual data will reside inside the lnwire
package because it contains all necessary function to decode/encode
the data. The second part obfuscation and hmac checking will resides
inside the lighting-onion package because it requires the key
generation.
2017-07-14 19:08:04 -07:00
Olaoluwa Osuntokun 14832d8c09
lnwallet+lnwire: minor grammatical fixes after UpdateFee merge 2017-07-14 17:10:42 -07:00
Johan T. Halseth a3836d5241 lnwire: add update_fee message type. 2017-07-14 16:39:15 -07:00