Commit Graph

355 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
9dee2ce8f2
lnwire: properly return UnknownMessage if we encounter an unknown message type 2018-03-30 14:25:27 -07:00
Olaoluwa Osuntokun
e7d66e1dfd
peer: don't d/c peer if we encounter lnwire.ErrUnknownAddrType
In this commit, we fix a minor deviation in our implementation from the
specification. Before if we encountered an unknown error type, we would
disconnect the peer. Instead, we’ll now just continue along parsing the
remainder of the messages. This was flared up recently by some
c-lightning related incompatibilities that emerged on main net.
2018-03-23 15:49:33 -07:00
Olaoluwa Osuntokun
00240c6221
lnwire: add new ErrUnknownAddrType for unknown addr types during parsing 2018-03-23 15:46:11 -07:00
Johan T. Halseth
300fb1af4a
lnwire: define ConnectionWideID 2018-03-11 17:21:23 +01:00
Olaoluwa Osuntokun
f83d56c91f lnwire: modify lnwire.MilliSatoshi to be an unsigned integer
In this commit, we modify lnwire.MilliSatoshi to be an unsigned
integer. We do this as all values within the specification are meant to
be unsigned unless otherwise specified. Our usage of signed integers to
this date has caused some compatibility issues with the other
implementations, so this is the first step to reconciling these
compatibility issues.
2018-03-07 13:29:58 -05:00
Johan T. Halseth
b3441561cf
lnwire: make ErrorCode satisfy error interface 2018-03-06 22:02:34 +01:00
Johan T. Halseth
2db5e56754
lnwire: add todo for changing to SatPerKWeight for fee rates 2018-02-26 22:42:28 +01:00
practicalswift
b8e1351cf3 multi: fix some recently introduced typos 2018-02-18 15:27:29 -08:00
MeshCollider
966d25849a lnwire: Fix incorrect variable name in comment 2018-02-08 15:21:04 -08:00
MeshCollider
61414df669 multi: Fix two minor typos 2018-02-08 15:21:04 -08:00
Olaoluwa Osuntokun
aa2e91f7c4
lnwire: replace instances of *btcec.PublicKey with [33]byte in ann messages
In this commit, we replace all instances of *btcec.PublicKey within the
announcement messages with a simple [33]byte. We do this as usually we
don’t need to immediately validate an announcement, therefore we can
avoid the scalar multiplications during decoding.
2018-02-06 20:14:30 -08:00
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
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
Olaoluwa Osuntokun
1be4d67ce4
multi: run all test instances in parallel 2017-06-17 01:00:07 +02:00
Olaoluwa Osuntokun
319afb14f1
lnwire: update ChannelUpdate to latest spec change, min HTLC is 8-bytes 2017-06-16 22:46:36 +02:00
Olaoluwa Osuntokun
650ba7e1ca
lnwire: update OnionPacketSize for new onion payload format
This commit updates the OnionPacketSize constant in order to reflect
the size of the onion payload as a result of the recent changes to the
sphinx packet format in the specification.
2017-06-10 18:15:09 -07:00
Olaoluwa Osuntokun
5adbc7fae3
lnwire: reduce range of randomly generated features in testing.Quick case
This commit reduces the range of the number of randomly generated
features in order to speed up the run time of the integration tests a
bit.
2017-06-07 16:54:49 -07:00
Andrey Samokhvalov
3897343db1 lnwire: add message type description function 2017-05-31 11:06:08 -07:00
Andrey Samokhvalov
b86409cdb3 htlcswitch: recreate hlcswitch from scratch
This commit gives the start for making the htlc manager and htlc switch
testable. The testability of htlc switch have been achieved by mocking
all external subsystems. The concrete list of updates:

1. create standalone package for htlc switch.
2. add "ChannelLink" interface, which represent the previous htlc link.
3. add "Peer" interface, which represent the remote node inside our
subsystem.
4. add htlc switch config to htlc switch susbystem, which stores the
handlers which are not elongs to any of the above interfaces.

With this commit we are able test htlc switch even without having
the concrete implementation of Peer, ChannelLink structures, they will
be added later.
2017-05-31 11:06:08 -07:00
Andrey Samokhvalov
84f94bdf4f lnwire: add reason to fail code conversion method 2017-05-31 11:06:08 -07:00
bryanvu
514760f529 peer: handling for channel shutdown messages
This commit changes the cooperative channel close workflow to comply
with the latest spec. This adds steps to handle and send shutdown
messages as well as moving responsibility for sending the channel close
message from the initiator to the responder.
2017-05-23 14:31:20 -07:00
bryanvu
d7bb600c23 lnwire: adjusted coop close messages to comply with spec
Removed close_request and close_complete and replaced with shutdown and
closing_signed.
2017-05-23 14:31:20 -07:00
Olaoluwa Osuntokun
b671a50157
lnwire: change the FeePerKb field to FeePerKw 2017-05-16 19:06:25 -07:00
Olaoluwa Osuntokun
1124b4556f
lnwire: fix serialization order of features+addresses in NodeAnnouncement
This commit fixes a deviant in the way we serialize and deserialize the
node announcement message from that which is currently in the spec.
Before this commit we reversed the order of features and addresses.
Instead, on the wire, features should come _before_ the addresses.

We also add a new temporary feature bit to ensure nodes that don’t
directly connect to each other if they don’t have this new update.
However, this will also partition any current tests nets when new nodes
join them as the digest signed has changed, therefore invalidating any
older messages.

Fixes #207.
2017-05-12 14:30:17 -07:00
Olaoluwa Osuntokun
994a3c10ca
brontide+lnwire: fix linter issues 2017-04-20 15:50:13 -07:00
Olaoluwa Osuntokun
aa2ca81762
lnwire: modify ReadMessage to no longer return the total bytes read
This commit modifies ReadMessage to no longer return the total bytes
read as this value will now be calculated at a higher level. The
io.Reader that’s passed to ReadMessage is expected to contain the
_entire_ message rather than be a pointer into a stream that contains
the message itself.
2017-04-20 15:45:56 -07:00
Olaoluwa Osuntokun
08a95ead6a
lnwire: remove the CreditsAmount definition, will be replaced with MilliSat 2017-04-19 16:19:14 -07:00
Olaoluwa Osuntokun
f4e8aa21b8
lnwire: enforce a max limit on an outpoint's index
This commit implements the constraint on an outpoint’s index as defined
within the specification.
2017-04-19 16:18:36 -07:00
Olaoluwa Osuntokun
89f4b1185e
lnwire: add a basic test for NetAddress 2017-04-19 16:17:29 -07:00
Olaoluwa Osuntokun
e3686cbc69
lnwire: replace all wire msg tests with a single property-based test
This commit does away with all the old manual message equality tests
and replace it with a single property-based test that uses the
testing/quick package. This test uses a single scenario which MUST hold
for all the messages type and all possible messages generated for those
types. As a result we are able to do away with all the prior manually
generated test data as the fuzzer to scan the input space looking for a
message that violates the scenario.
2017-04-19 16:17:00 -07:00
Olaoluwa Osuntokun
febc8c399a
lnwire: convert message parsing to use the new minimal type header
This commit abandons our old bitcoin inspired message header and
replaces it with the bare type-only message headers that’s currently
used within the draft specification. As a result the message header now
consists of only 2-bytes for the message type, then actual payload
itself. With this change, the daemon will now need to switch to a
purely message based wire protocol in order to be able to handle the
extra data that can be extended to arbitrary messages.
2017-04-19 16:13:15 -07:00
Olaoluwa Osuntokun
587300aa80
lnwire: use ReadFull instead of Read when parsing feature vectors
This commit fixes a bug lingering in the decoding of the feature
vectors which was masked by the prior method of reading the _entire_
message from the stream before parsing it. The issue was that
performing a zero-byte Read on an io.Reader that’s purely streaming
will result in an indefinite block. We fix this bug by properly using
io.ReadFull in this context.
2017-04-19 16:07:17 -07:00
Olaoluwa Osuntokun
9324a503c9
lnwire: allow up to 35-bytes in pkScripts to account for P2WSH 2017-04-19 16:04:46 -07:00
Olaoluwa Osuntokun
8081fab8fe
lnwire: remove unused types from readElement/writeElement 2017-04-19 16:04:27 -07:00
Olaoluwa Osuntokun
f6b3c25f95
lnwire: on Message interface convert Command to MsgType
This commit modifies the Message interface to convert the Command
method to a MsgType method that uses a new set of message type for all
the defined messages. These new messages types nearly exactly match the
message types used within the current draft of the BOLT specifications.
2017-04-19 15:57:50 -07:00
Olaoluwa Osuntokun
bcd142bc30
lnwire: reduce the max message payload to 65KB from 32MB
This commit reduces the max message payload to 65KB from 32MB in order
to better align ourselves with current draft of the BOLT
specifications.
2017-04-19 15:09:18 -07:00
Olaoluwa Osuntokun
c8d978261b
lnwire: remove the Validate method from the Message interface
This commit revues the Validate method from the Message interface as
the method is no longer used and is a relic from an older version of
the codebase.
2017-04-19 15:03:51 -07:00
Olaoluwa Osuntokun
920fcf3392
lnwire: modify newAlias to no longer return an error 2017-04-19 14:59:22 -07:00
Olaoluwa Osuntokun
1b10db212e
lnwire: rename ChannelUpdateAnnouncement to ChannelUpdate 2017-04-17 16:20:21 -07:00
Olaoluwa Osuntokun
bf7701cd62
features: add new feature bits to guard recent changes 2017-04-16 18:19:09 -07:00
Olaoluwa Osuntokun
feec611531
lnwire+peer: implement new ping/pong messages and behavior
This commit implements the new ping/pong messages along with their new
behavior. The new set of ping/pong messages allow clients to generate
fake cover traffic as the ping messages tells the pong message how many
bytes to included and can also be padded itself.
2017-04-16 18:11:45 -07:00
Olaoluwa Osuntokun
83c72eb082
lnwire: place ping and pong in the correct files :p 2017-04-16 15:48:46 -07:00
Olaoluwa Osuntokun
d17b11862b
lnwire: convert ErrorGeneric to Error
With this change we move one step closer to matching the wire protocol
currently defined within the spec.
2017-04-16 15:23:45 -07:00
Olaoluwa Osuntokun
c06894a2e6
lnwire: replace ChannelPoint with ChannelID, use new PendingChanID 2017-04-16 15:22:27 -07:00
Olaoluwa Osuntokun
8147151fbf
lnwire: add new 32-byte persistent/pending channel ID's
This commit does to things: moves the prior ShortChannelID struct into
a new short_channel_id.go file, and also implements the new ChannelID’s
currently used within he specification.

These new ID’s are 32-bytes in length and used during initial channel
funding as well as during normal channel updates. During initial
channel funding, the ID is to be a random 32-byte string, while once
normal channel operation has began, the ID is to be (txid XOR index),
where index is the index of the funding outpoint.
2017-04-16 15:19:45 -07:00
Andrey Samokhvalov
c3b2854428 lnwire: converge discovery part of messages with specification
Change the name of fields of messages which are belong to the discovery
subsystem in a such way so they were the same with the names that are
defined in the specification.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
54b3541707 lnwire: add specification 'AnnounceSignature' message
In this commit announcement signature message has been added which is
needed when peers want to announce their channel to the rest of the
network. This message acts as half proof carrier, nodes exchanges
their half proofs with each other and after that they are able to
construct the full proof.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
c174141a72 lnwire: remove not working test
Validation of the announcements message has been removed and it will
be added in the discovery package latter.
2017-03-29 19:49:05 -07:00
Olaoluwa Osuntokun
afe77853b7
server+lnwire: pre-allocate address slices 2017-03-29 19:00:31 -07:00
bryanvu
085b7333cb lnwire: add support for Features in NodeAnnouncement
Add support for Features in NodeAnnouncment according to spec.
2017-03-29 12:03:43 -07:00
bryanvu
9ffac9eae1 lnwire: update NodeAnnouncement to handle multiple addresses
This commit modifies address handling in the NodeAnnouncement struct,
switching from net.TCPAddr to []net.Addr. This enables more flexible
address handling with multiple types and multiple addresses for each
node. This commit addresses the first part of issue #131 .
2017-03-29 12:03:43 -07:00
Olaoluwa Osuntokun
6b3a258e86
multi: fix formatting issues in packge README's 2017-03-27 16:25:25 -07:00
Andrey Samokhvalov
9dfaca1632 linter: fix new warnings 2017-03-17 12:53:15 -07:00
Olaoluwa Osuntokun
0db384fd6b
lnwire: properly fold at 80-columns within features.go 2017-03-16 12:12:00 -07:00
Andrey Samokhvalov
61991a1c89 lnd: fix latest goclean.sh lint warning 2017-03-13 16:30:23 -07:00
Andrey Samokhvalov
fd97a4bd19 lnd: partially fix golint warnings 2017-03-13 16:30:23 -07:00
Andrey Samokhvalov
143a6e01bb lnd: fix unconvert warnings 2017-03-13 16:30:23 -07:00
Andrey Samokhvalov
8fb54782e2 lnd: fix gosimple warnings 2017-03-13 16:30:23 -07:00
Olaoluwa Osuntokun
da09f4dcc4
lnwire: modify newAlias to truncate alias strings if too long 2017-03-08 14:21:57 -08:00
Olaoluwa Osuntokun
f881e0a356
lnwire: fix typo in ChannelUpdateAnnouncement, Mstat -> Msat 2017-03-08 14:20:14 -08:00
Olaoluwa Osuntokun
743de45c92
lnwire: rename Expiry to TimeLockDelta within ChannelUpdateAnnouncement
This commit modifies the ChannelUpdateAnnouncement to rename the Expiry
variable instead of TimeLockDelta as that is more descriptive of the
purpose of the attribute itself.
2017-03-05 22:43:57 -06:00
bryanvu
7048480a4a minor: fixed arbiter spelling and comment/error messages in funding rpc messages 2017-02-24 11:37:33 -08:00
bryanvu
eb490b8833 lnwire: add FundingLocked message
When the funding transaction has been confirmed, the FundingLocked
message is sent by the peers to each other so that the existence of the
newly funded channel can be announced to the network.

This commit also removes the SingleFundingOpenProof message.
2017-02-24 11:37:33 -08:00
bryanvu
e549a3f0ed fundingmanager: move final funding steps from wallet to funding manager.
Once a channel funding process has advanced to the point of broadcasting
the funding transaction, the state of the channel should be persisted
so that the nodes can disconnect or go down without having to wait for the
funding transaction to be confirmed on the blockchain.

Previously, the finalization of the funding process was handled by a
combination of the funding manager, the peer and the wallet, but if
the remote peer is no longer online or no longer connected, this flow
will no longer work. This commit moves all funding steps following
the transaction broadcast into the funding manager, which is available
as long as the daemon is running.
2017-02-24 11:37:33 -08:00
Olaoluwa Osuntokun
3a647869b6
lnwire: fix features_test.go to not reference removed .String() method 2017-02-22 16:01:42 -08:00
Olaoluwa Osuntokun
f9b44567ed
lnwire: remove String() method from FeatureVector
This commit removes the String() method from the FeatureVector as it
can produce confusing output when revving a feature vector and not
knowing the strip mapping ahead of time.
2017-02-22 15:53:47 -08:00
Christopher Jämthagen
46d23919e7 lnwire: add serializing and deserializing for type [6]byte
and remove serialization for type [4]byte.
2017-02-22 15:46:59 -08:00
Christopher Jämthagen
97aa478ce1 channeldb: change [4]byte obsfucator to [6]byte in test 2017-02-22 15:46:59 -08:00
Christopher Jämthagen
3983e0693b lnwire: use [6]byte obsfucator 2017-02-22 15:46:59 -08:00
Olaoluwa Osuntokun
8024fd72f8
lnwire: create distinct type for UpdateFailHTLC failure reason
This commit creates a distint type for the opaque failure reason within
the UpdateFailHTLC message. This new type is needed as this is the only
variable length byte slice within the protocol and therefore requires a
length prefix in order to serialize/deserialize properly.
2017-02-21 01:43:36 -08:00
Olaoluwa Osuntokun
4aa7de7f58
lnwire: remove obsolete String() method from new wire messages 2017-02-21 01:43:34 -08:00
Olaoluwa Osuntokun
ccbbcf389b
lnwire: directly embed the wire.OutPoint in all commitment update msgs 2017-02-21 01:42:35 -08:00
Olaoluwa Osuntokun
5330513c7b
lnwire: morph HTLCSettleRequest into UpdateFufillHTLC
This commit modifies the prior HTLCSettleRequest to more closely match
the UpdateFufillHTLC defined within the specification. The only
semantic change is the move from a slice of pre-images (for “multi-sig”
LN) to a single payment preimage.
2017-02-21 01:42:32 -08:00
Olaoluwa Osuntokun
f1357e96b3
lnwire: morph CancelHTLC into UpdateFailHTLC, remove HTLCAddReject
This commit morphs the prior CancelHTLC into the new UpdateFailHTLC
message and also gets rid of the obsolete HLTCAddReject message while
we’re at it.

The primary change from the CancelHTLC message to the UpdateFailHTLC
message is that the CancelReason is now simply called Reason and that
it’s now an opaque encrypted set of bytes. With this update the failure
messages are now more flexible (they can even carry new
ChannelUpdate’s) and also don’t reveal the exact cause of failure to
intermediate nodes.
2017-02-21 01:42:29 -08:00
Olaoluwa Osuntokun
ec02060c9f
lnwire: rename HTLCAddRequest to UpdateAddHTLC 2017-02-21 01:42:26 -08:00
Olaoluwa Osuntokun
8a63c83283
lnwire: morph CommitSignature into CommitSig
This commit renames and modifies the CommitSignature message to more
closely match the CommitSig message defined within the current set of
draft specifications.

The major change within the new message is that we now longer
explicitly specify the update log index of the remote node that this
signature covers. This is due to the fact the revocation message now
also double as acknowledgements of the remote parties recevied
commitment update messages.
2017-02-21 01:42:23 -08:00
Olaoluwa Osuntokun
9a61bb3ae1
lnwire: rename CommitRevocation to RevokeAndAck
This commit renames the prior CommitRevocation message to RevokeAndAck
in order to better align the set of wire messages implemented by the
`lnwire` message with those currently defined within the specification.
2017-02-21 01:42:09 -08:00
Andrey Samokhvalov
ae15a193e2 lnwire+features: transition to the user friendly list of features 2017-02-21 01:25:05 -08:00
Andrey Samokhvalov
3dd619fb35 lnwire: Add BOLT#1 'init' message
'init' message is the first message reveals the features supported or required
by this node. Nodes wait for receipt of the other's features to simplify error
diagnosis where features are incompatible. This message will help negotioate the
the features which are supported by both sides.
2017-02-17 13:27:29 +08:00
Olaoluwa Osuntokun
384fe61e73
multi: fix go vet warnings throughout code base 2017-02-16 19:33:19 +08:00
Olaoluwa Osuntokun
a658fabf48
funding: disallow channel creation before lnd is synced to the chain
This commit adds a new restriction around funding channels at the
daemon level: lnd nodes will not allow either the initiation or the
acceptance of a channel before the node is fully synced to the best
known chain.

This fixes a class of bug that arises when a new node joins the network
and either attempts to open a channel or has a channel extended to them
before the node is fully synced to the network.
2017-01-24 17:12:57 -08:00
Trevin Hofmann
40c7bac3aa multi: fix a variety of typos throughout the repo 2017-01-17 17:02:56 -08:00