Commit Graph

252 Commits

Author SHA1 Message Date
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 3b6e456371
lnwire: revamp previous encode/decode tests to passing state 2016-05-30 20:52:25 -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 4d763e07f7
lnwire: add basic encode/decode tests for single funder workflow 2016-05-30 20:52:13 -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 913ae259de
lnwire: document commitment+HTLC update msgs
This commit adds some cursory documentation along wit minor field
modifications to all messages which deal with adding HTLC’s, or
updating remote commitment transactions.

The messages for dual funding of channel is left purposefully
undocumented as all initial negotiations will be single funder by
default.

A revamp of the testing infrastructure of lnwire will be committed in
the near future.
2016-05-23 13:54:41 -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 a30831aef8
lnwire: update and document message.go 2016-05-23 13:49:14 -07:00
Olaoluwa Osuntokun 0563205e6d
lnwire: update isValidPkScript for segwit scripts 2016-05-23 13:48:17 -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 1a617fcccb
lnwire: add SingleFundingOpenProof message
The SFOP is the final message sent during the single funding channel
negotiation protocol. Once Alice sends the SFOP message to Bob, Bob
will then commit resources to watching and updating the newly created
channel with Alice.
2016-05-23 13:46:48 -07:00
Olaoluwa Osuntokun 18314f73ae
lnwire: document and update SingleFundingResponse 2016-05-23 13:46:26 -07:00
Olaoluwa Osuntokun 3bf2d62035
lnwire: document start of single funder workflow
This commit adds some additional documentation in the form of comments
to the start of the revised single funder workflow.

A primary change lies in the introduction of the exchange of Channel
Derivation Points (CDP’s) for both sides. Using CDP’s we can derive
channel authentication proofs which are both unforgettable and binding.
2016-05-23 13:40:45 -07:00
Olaoluwa Osuntokun f799ff3b66
lnwire: add SingleFundingSignComplete msg to workflow
This commit adds the SingleFundingSignComplete message to the single
funder transaction workflow. This marks the second to last message sent
in the workflow. The message transports Bob’s signature for the
commitment transaction, allowing Alice to broadcast the funding
transaction as she can now refund her inputs.
2016-05-22 22:29:52 -07:00
Olaoluwa Osuntokun 59a65518c1
lnwire: add SingleFundingComplete to single funder
This commit adds the SingleFundingComplete message to the single funder
channel workflow. This is the 3rd message sent in the workflow,
traveling from Alice to Bob once Alice is able to construct the final
commitment transaction.
2016-05-22 22:25:52 -07:00
Joseph Poon 566bf47cbf Wire update
More in sync with other code! :D
2016-05-17 21:28:42 -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 5218dca5b6 Simplified the commitment messages 2016-04-11 00:55:48 -07:00
Joseph Poon 48667bdcbe Updated Commit Revocation 2016-03-17 16:51:30 -07:00
Joseph Poon 4b8a8f410a Commit message update
Doesn't need to use a list, only needs to show each party's most recent
state.
2016-03-15 16:22:41 -07: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 84c0f56330 lnwire/README.md: Hopefully this will be legible 2016-01-16 17:11:04 -08:00
Joseph Poon f3ce558eb1 typo fix 2016-01-14 23:58:05 -08:00
Joseph Poon 5fc1ff52fc Typo correction 2016-01-14 23:58:04 -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
Tadge Dryja 919b0002b1 put MSGID bytes back in to lnwire 2016-01-14 23:56:09 -08:00
Joseph Poon 8cc057bbd4 Cooperative Close 2016-01-14 23:56:09 -08:00
Joseph Poon bf8e0d727d Added ReservationID for funding_requeset 2016-01-14 23:56:09 -08:00
Joseph Poon 84df87255f Oops typo 2016-01-14 23:56:09 -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 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 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 47801bd927 Script fix and notes reflecting wire protocol change 2015-12-29 17:10:00 -08:00
Joseph Poon 6a9011654a "typo" correction 2015-12-29 05:46:51 -08:00
Joseph Poon ba56797b43 Ohhh... right. 2015-12-29 05:46:03 -08:00
Joseph Poon 1e79ad7236 Minor note 2015-12-29 05:43:07 -08:00
Joseph Poon 02a9b1e237 While making things match closely with Rusty's wire protocol, I noticed
he didn't allow for multiple HTLCs. Gotta explain the rationale for that
that... will merge the progress in the next commit tomorrow.
2015-12-29 05:24:02 -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