Commit Graph

40 Commits

Author SHA1 Message Date
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
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
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
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
Olaoluwa Osuntokun
f47e7a9bf4
lnwire: update the ChannelAnnouncement message to match BOLT-0007 2017-08-22 00:52:07 -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
b174ae80bf
lnwire: convert all relevant fields to use the MilliSatoshi type 2017-08-22 00:51:51 -07:00
Olaoluwa Osuntokun
de30c14aea
lnwire: update testing/quick tests to new wire message updates 2017-07-30 17:47:55 -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
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
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
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
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
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
c06894a2e6
lnwire: replace ChannelPoint with ChannelID, use new PendingChanID 2017-04-16 15:22:27 -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
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
ccbbcf389b
lnwire: directly embed the wire.OutPoint in all commitment update msgs 2017-02-21 01:42:35 -08:00
Olaoluwa Osuntokun
d884efea29
lnwire+lnd: Make Logging Messages Great Again
This commit modifies the login of sent/recv’d wire messages in trace
mode in order utilize the more detailed, and automatically generated
logging statements using pure spew.Sdump.

In order to avoid the spammy messages due to spew printing the
btcec.S256() curve paramter within wire messages with public keys, we
introduce a new logging function to unset the curve paramter to it
isn’t printed in its entirety. To insure we don’t run into any panics
as a result of a nil pointer defense, we now copy the public keys
during the funding process so we don’t run into a panic due to
modifying a pointer to the same object.
2017-01-14 17:52:18 -08:00
Olaoluwa Osuntokun
5affed38fc
multi: update btcsuite API's to latest upstream changes
This commit makes a large number of minor changes concerning API usage
within the deamon to match the latest version on the upstream btcsuite
libraries.

The major changes are the switch from wire.ShaHash to chainhash.Hash,
and that wire.NewMsgTx() now takes a paramter indicating the version of
the transaction to be created.
2017-01-05 13:56:34 -08:00
Olaoluwa Osuntokun
5ee201e712
lnwire: embed ChannelID within the announcement structs rather than pointer 2016-12-27 16:43:21 -08:00
Andrey Samokhvalov
b440005219
lnwire: add ChannelAnnoucement,NodeAnnoucement,ChannelUpdateAnnoucement messages 2016-12-27 16:43:02 -08:00
Olaoluwa Osuntokun
bba9b665ef
lnwire: all hashes within the protocol are now 32-bytes
We now enforce that the site of all revocation pre-images+hashes (used
for HTLC’s) are now 32-bytes.

Additionally, all payment pre-images are now required to be 32-bytes
not he wire. There also exists a Script level enforcement of the
payment pre-image size at a lower level.

This commit serves to unify the sizes of all hashes/pre-images across
the codebase.
2016-06-30 11:53:21 -07:00
Olaoluwa Osuntokun
8dc284db02
lnwire: update tests to new wire.TxIn API
Syncing to match upstream btcd segwit branch.
2016-05-23 13:47:29 -07:00
Olaoluwa Osuntokun
fcff17c336
multi: change all imports to roasbeef's forks
This commit will allow the general public to build lnd without jumping
through hoops setting up their local git branches nicely with all of
our forks.
2016-05-15 17:22:37 +03:00
Joseph Poon
f2a1c0368a Cleanup comments & removed notes on escrow 2016-01-16 17:14:35 -08:00
Joseph Poon
f3849f5c10 Structs for Wire Protocol HTLCs and Commitments
* Structs and wire messages for HTLCs
* Wire protocol for a state machine with no blocking(!!!)
  (I will write the state machine)
  TL;DR: Can do multiple HTLC modifications in-flight, dead simple wire
  protocol. Both sides can update their Commitments unliaterally without
  waiting for the other party's signature. Will have basic/preliminary
  notes in the README
* Added **swp to .gitignore because of vim annoyances
2016-01-14 23:56:10 -08:00
Joseph Poon
8cc057bbd4 Cooperative Close 2016-01-14 23:56:09 -08:00
Joseph Poon
266c121510 Changed type in Accept/Complete & lnwire refactor
* FundingSignAccept and FundingSingComplete had *[]btcec.Signature and
  instead it's now []*btcec.Signature to match other slice types.
* Refactored lnwire's when doing readElement/writeElement on slices
2016-01-14 23:56:09 -08:00
Joseph Poon
0d4c78e90d FundReq/FundResp update / Refactor tests
* Added field
* Renamed FundingAmount and ReserveAmount to specify in FundingRequest
  and FundingResponse that it is for RequesterFundingAmount or
  ResponderFundingAmount
* Added PaymentAmount field to FundingRequest
* Added MinDepth field to FundingRequest and FundingResponse
* Fixed .Serialize() to show inputs/etc. only if there are fields
  available (prevents trying to dereference nil value)
* Add a bunch of Validate() conditions
* MASSIVE REFACTOR of tests (removed tons of redundancy)
2016-01-14 23:56:08 -08:00
Joseph Poon
161b1b5e4c Message interface and stuff.
* Added Message interface (similar to btcd's)
* Moved Funding Request to its own file
* Refacored Funding Request Code (*MUCH* better)
* Various fixes
2015-12-28 03:24:16 -08:00
Joseph Poon
f51a5a6458 Holy shit pointer crap was annoying! Serialize/deserialize works now.
Running "go test -v" will show the serialization and deserialization.

Doing the rest of the wire stuff should be *much* faster since I figured
everything out...
2015-12-26 23:52:20 -08:00
Joseph Poon
0c0900006d Upon further reflection Our/Their seperation makes no sense 2015-12-26 20:37:17 -08:00
Joseph Poon
09f07770fd Funding request serialize/deserialize (io reader/writer and pointers
were very confusing -_-;)
2015-12-26 18:20:25 -08:00