Commit Graph

48 Commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun
afe77853b7
server+lnwire: pre-allocate address slices 2017-03-29 19:00:31 -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
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
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
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
ccbbcf389b
lnwire: directly embed the wire.OutPoint in all commitment update msgs 2017-02-21 01:42:35 -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
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
Trevin Hofmann
40c7bac3aa multi: fix a variety of typos throughout the repo 2017-01-17 17:02:56 -08:00
Olaoluwa Osuntokun
d079c88702
lnwire: add cancellation reason to htlc cancel messages
This commit adds a new field to the CancelHTLC message which describes
the event that led to an HTLC being cancelled up stream.

A new enum has been added which describers the “why” concerning the
cancellation of the HTLC. Currently the encoding and back propagation
of the errors aren’t properly implemented as defined within the spec.
As a result the current error types provide to privacy as the error are
in plain-site rather doing being properly encrypted.
2017-01-07 21:20:54 -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
b5dd462e13
lnwire: remove old routing/discovery messages
This commit removes the older routing/discovery messages from the
unwire package, as we’ll be converging towards BOLT07 in the near-term.
In the mid to far term we’ll be revisiting integrating Flare into the
newer scheme in order to take advantage of its scaling characteristics.
2016-12-27 16:44:20 -08:00
Olaoluwa Osuntokun
e5490b55f4
lnwire: modify Alias to only track the non-zero portion of wire msg
This commit modifies the Alias type to only hold the non-zero portion
of the alias as encoded on the wire. Previously the entire 32-bytes
would be read and stored, including the zeroes at the end used as
padding. Within the constructor, we now parse the alias properly,
discarding the trailing zeroes within the passed byte slice.
Additionally, the .String() method of Alias will now also only print
the non-zero prefix of the decoded alias.
2016-12-27 16:43:46 -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
Andrey Samokhvalov
5a82240c6a lnwire+lnwallet+fundingmanager: general improvements 2016-12-13 11:01:57 -08:00
Alex Akselrod
a20594b0bf lnwire: switch to using a fixed 64-byte encoding for signatures (#86)
This commit modifies the encoding of signatures on the wire to use 
a fixed-size 64-byte format. This change is required as the current spec
draft dictates that all signatures be encoded as `R` and `S` as 32-byte
big-endian integers. With this, signatures are now always a _fixed_ size 
slice of bytes on the wire, which is nice to have. 

Fixes #83.
2016-12-08 12:56:37 -08:00
BitfuryLightning
327768f4ad routing: Move tools inside lnd. Refactor and delete unneeded stuff
Use [33]byte for graph vertex representation.
Delete unneeded stuff:
1. DeepEqual for graph comparison
2. EdgePath
3. 2-thread BFS
4. Table transfer messages and neighborhood radius
5. Beacons

Refactor:
1. Change ID to Vertex
2. Test use table driven approach
3. Add comments
4. Make graph internal representation private
5. Use wire.OutPoint as  EdgeId
6. Decouple routing messages from routing implementation
7. Delete Async methods
8. Delete unneeded channels and priority buffer from manager
9. Delete unneeded interfaces in internal graph realisation
10. Renamed ID to Vertex
2016-11-23 20:37:43 -06:00
Olaoluwa Osuntokun
1ef218a73d
lnwire: add the state hint obsfucator to the SingleFundingComplete msg 2016-11-14 19:04:03 -08:00
Olaoluwa Osuntokun
afae7aad2a
lnwire: add concrete error type to ErrorGeneric 2016-10-23 13:41:23 -07: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
6c7880ef76
lnwire: channels are now identified by outpoint
This commit modifies most of the wire messages to uniquely identify any
*active* channels by their funding output. This allows the wire
protocol to support funding transactions which open several channels in
parallel.

Any pending channels created by partial completion of the funding
workflow are to be identified by a uint64 initialized by both sides as
follows: the initiator of the connection starts from 0, while the
listening node starts from (1 << 63). These pending channel identifiers
are expected to be monotonically increasing with each new funding
workflow between two nodes. This identifier is volatile w.r.t to each
connection initiation.
2016-06-21 13:13:07 -07:00
Olaoluwa Osuntokun
83b11c5efe
lnwire: fix writeElement [][20]byte bug
Passing the [20]byte as a *[20]byte results in a type switch error as
there isn’t a case for that type within writeElement.
2016-05-30 20:52:17 -07:00
Olaoluwa Osuntokun
9978d889b7
lnwire: add missing cases in [read/write]Element
Add cases to encode/decode wire.OutPoint, and a final line to properly
write out signatures fully.
2016-05-30 15:45:01 -07:00
Olaoluwa Osuntokun
b202831868
lnwire: update/document [read/write]Element funcs 2016-05-23 13:51:26 -07:00
Olaoluwa Osuntokun
2073fa42a7
lnwire: document lnwire specific data structures 2016-05-23 13:50:39 -07:00
Olaoluwa Osuntokun
0563205e6d
lnwire: update isValidPkScript for segwit scripts 2016-05-23 13:48:17 -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
bf4b43d3f2 Updated coin amounts to use int64
(currently for convenience on development)
2016-02-29 00:45:38 -08:00
Tadge Dryja
2367300d71 Merge branch 'uspvdev' 2016-02-26 13:23:00 -08:00
Joseph Poon
e940e92823 Updated wire to use int64 2016-02-18 04:29:08 -08:00
Tadge Dryja
0d3639435f can sync with segnet in hard mode
lots of changes but they seem to work
2016-02-15 22:13:17 -08:00
Joseph Poon
f2a1c0368a Cleanup comments & removed notes on escrow 2016-01-16 17:14:35 -08:00
Joseph Poon
1981001a29 Started working on state machine
* Added description in lnwire/README.md for state machine
* Figured out mutex stuff...
* Started the State Machine (using dummy functions for net/db)
* Minor corrections in wire protocol (changed some names/types)
    - Renamed StagingID to HTLCKey of type HTLCKey (uint64)
2016-01-14 23:58:04 -08:00
Joseph Poon
b4c644c99a Added Error message type to wire protocol 2016-01-14 23:56:10 -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
b3f812e5da Notes on payment amount 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
2d3253b95d Cleanup
* Bugfixes
* Removed whether to include sigs in txin for readElement/writeElement
2016-01-14 23:56:09 -08:00
Joseph Poon
a93b6dcee4 Messages for funding flow.
This is the most different due to segwit (the rest of the messages are
simple).

I still need to simplify/refactor the tests, they're "messy".
2015-12-30 05:38:57 -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
b79d0cc65a (still need to fix deserialize... io wasn't working so I'm using bytes) 2015-12-26 18:23:58 -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
Joseph Poon
fc9ebb52f3 Refactor funding request, will separate to multiple files later 2015-12-23 00:08:34 -08:00