Commit Graph

317 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
6e3d231619
funding: properly pass in channel state as argument of closure in Start 2017-11-23 23:10:13 -06:00
Olaoluwa Osuntokun
a3cd248404
funding+utxonursery+breacharbiter: use new FeeEstimator API 2017-11-23 23:10:13 -06:00
Olaoluwa Osuntokun
88d418c0ec
funding: add additional debug logging to during final funding flow stages 2017-11-16 20:00:06 -08:00
Olaoluwa Osuntokun
4700c1be04
funding: populate the HtlcPoint during the funding workflow 2017-11-16 20:00:02 -08:00
Jim Posen
78f8ddef72 lnd: Remove some sleeps in integration tests.
There is a sleep after channels are opened to ensure the channel is
removed from the set of pending reservations. We can avoid this sleep
and get better guarantees of the channel being opened by deleting the
reservation just before updating channel state to active instead of
after.
2017-11-13 20:52:07 -08:00
Olaoluwa Osuntokun
2862b6e6f1
funding: update to adhere to new channels API's 2017-11-10 19:51:08 -08:00
Olaoluwa Osuntokun
3764e5c65e
funding: by default, signal to announce initiated channel to network 2017-11-09 12:00:18 -08:00
nsa
9c0c889131 funding: decouple funding wait from fundingLocked and chanAnn
This commit decouples the wait for funding transaction confirmations
in the waitForFundingConfirmation function from the announcement of
the channel in the sendFundingLockedAndAnnounceChannel function.
Additionally, the sendFundingLockedAndAnnounceChannel function is
now decoupled into the sendFundingLocked and sendChannelAnnouncement
functions. There is also now a helper function that houses creation
of a lnwire.LightningChannel object, calls to both sendFundingLocked
and sendChannelAnnouncement.
2017-10-27 16:43:07 -07:00
Jim Posen
9fd77a6e40 multi: Update lnd to use new feature vector API. 2017-10-17 22:47:20 -07:00
Johan T. Halseth
ff2adf96a9
fundingManager: conditional select on arbiterChan and peer.newChannels
This commit adds a select statement for sending on the fundingManager's
arbiterChan and the peer's newChannels channel. This makes sure we won't
be blocked sending on these channels in case of a shutdown.
2017-10-02 13:29:56 +02:00
Johan T. Halseth
b8cadf881c
fundingManager: use NotifyWhenOnline when sending fundingLocked.
The fundingManager will register with the server to get notified
when the targetted peer comes online, in case of a failed send
of the fundingLocked message. This is necessary because if the
peer is not connected yet (or was disconnected while we were
waiting for the funding tx to confirm), we cannot continue the
the opening process before the peer successfully has received
the fundingLocked.
2017-10-02 13:29:52 +02:00
Johan T. Halseth
8244b7a78c
fundingManager: handle duplicate fundingLocked
This commit adds a channel barrier on fundingManager startup for
channels where the opening process is not finished. This fixes
a bug where we after restarting the fundingManager would receive
the fundingLocked message, and crash when trying to close the
non-existing barrier.

In case we received a fundingLocked message after our own opening
process was finished, we would crash with the same error. We
therefore check if the channel barrier exists before we try to
close it.

It also adds functionality to fundingManager that makes it
ignore a fundingLocked message it receives for a channel where
this is already received. This is necessary when we in case of
a reconnection resend the fundingLocked since we cannot be sure
the remote has received it.

The fundingmanager tests are also updated to check that the
fundingLocked messages are sent and handled correcly, and also
exercise the scanarios described above.
2017-10-02 13:29:49 +02:00
Olaoluwa Osuntokun
c06b82c3a2
funding: add a conditional send on quit for all process* methods
This commit adds a conditional send on quit to all methods used by
outside sub-systems to the funding manager. This ensures, that in the
case the funding manager is exiting, the caller won’t block
indefinitely.
2017-09-27 20:07:08 -07:00
Olaoluwa Osuntokun
31d53c6070
funding: properly display pending chan ID within logs
This commit corrects a minor formatting error when logging the pending
channel ID within the logs. Previously, the logging directives and
parameter could cause the pending chan ID to display in a double-hex
encoded format. We fix this by ensuring that we properly slice the chan
ID before printing it, and also ensure that we use the %x formatting
(which will hex encode the bytes) everywhere.

Fixes #331.
2017-09-18 19:33:43 +02:00
Olaoluwa Osuntokun
737eeedd49
funding: don't send a funding error in the case of a funding timeout 2017-09-13 01:04:09 +02:00
Olaoluwa Osuntokun
3b2ed69638
funding: in failFundingFlow properly embed passed error 2017-09-12 22:38:44 +02:00
Olaoluwa Osuntokun
769abb87ea
funding: properly verify and apply channel constraints during funding flow
This commit implements some missing functionality as we’ll now properly
validate and generate the various channel flow control constraints
during initial channel funding.

With this commit, we take an additional step towards full spec
compliance as we’ll now properly send over the required channel
reservation, max HTLC’s, and other parameters during the funding flow.

When processing the desired parameters by the remote party, if we think
they’re unreasonable, then we’ll send an Error message and end the
funding flow.
2017-09-12 18:07:50 +02:00
Olaoluwa Osuntokun
25766fc9ca
funding: use new failFundingFlow method when error encountered during funding 2017-09-12 17:31:29 +02:00
Olaoluwa Osuntokun
3701757cdc
funding: add new failFundingFlow method to fail flow and send funding error 2017-09-12 17:30:06 +02:00
Olaoluwa Osuntokun
1ce6c4668e
funding: unconditionally forward all received errors to client
Previously, our old lnwire.Error message used a special code to
indicate different types of errors. With the recent push for spec
compatibility, we removed this field and instead stuffed the error into
the first byte of the error data. This works between lnd nodes, but
with other implementations they may send different errors which use a
different error scheme.

To fix this, we’ll now unconditionally return the error to the end
caller (if one exists).
2017-08-30 20:31:40 -07:00
Olaoluwa Osuntokun
7be039adec
multi: ensure that BlockEpoch clients are cancelled
This commit fixes a prior goroutine leak that could result in a node
having thousands of goroutines, particularly due to many concurrent
channel fundings. We now ensure that for each BlockEpoch client
created, we ensure that the client is cancelled once the creating
grouting exits.
2017-08-30 20:26:17 -07:00
Olaoluwa Osuntokun
39ab177567
funding: populate ChainHash in announcement messages, update signing
This commit updates the tail end of the funding workflow to properly
include the ChainHash field when crafting ChannelAnnouncements and the
initial ChannelUpdate messages. Additionally, we now properly generate
the proper signatures to match the changes to BOLT0007.
2017-08-22 00:53:01 -07:00
Olaoluwa Osuntokun
8f25a73332
funding: abandon usage of Code field in lnwire.Error
This commit modifies the generation and parsing of errors to abandon
usage of the Code field, and instead use the first byte of the Data
field to store the error codes that we currently use. With this change,
we ensure that our error messages properly match BOLT-0002.
2017-08-22 00:52:58 -07:00
Olaoluwa Osuntokun
01b0ddf1c5
lnd+rpc: update RPC responses to convert mSAT to SAT 2017-08-22 00:52:56 -07:00
Conner Fromknecht
39344b6445 fundingmanager: removes NumPendingChannels 2017-08-10 16:14:01 -07:00
Johan T. Halseth
849d0b93b1 fundingManager: persist state in opening process.
Persists the state of a channel opening process after funding
transaction is confirmed. This tracks the messages sent to
the peer such that the process can be continued in case of a
restart. Also introduces that the receiver side forgets about
channel if funding transaction is not confirmed in 48hrs.
2017-08-10 13:14:25 -07:00
Johan T. Halseth
5c89ec6288 fundingManager: let CurrentNodeAnnouncement return copy instead of ref 2017-08-08 12:29:27 -07:00
Olaoluwa Osuntokun
f13c81eb6a
test: ensure all tests adhere to maximum funding amount 2017-08-07 16:31:32 -07:00
Olaoluwa Osuntokun
203d038b71
funding: enforce the 2^24 satoshi funding limit in BOLT-0002 2017-08-07 16:31:25 -07:00
Olaoluwa Osuntokun
43b736225b
multi: add new method to generate fresh node announcments 2017-08-04 18:32:33 -07:00
Johan T. Halseth
e2112702e7 fundingmanager: send node announcements after channel open.
Make the fundingmanager send an updated node announcement
each time it opens a new channel. This is to make sure
our node announcement is propagated in the network, since
peers will ignore our node announcements if we haven't
opened any channels yet.
2017-08-02 15:58:58 -07:00
Olaoluwa Osuntokun
5425eff09c
multi: ensure all lnwallet.LightningChannel's are stopped
This commit ensures that we always clean up the resources that are
created when a new instance of a lnwallet.LightningChannel is
instantiated. The is necessary due to the sigPool that’s now present as
an internal goroutine.
2017-07-31 21:07:02 -07:00
Olaoluwa Osuntokun
f963859524
funding+peer: rename processFundingResponse to processFundingAccept 2017-07-31 21:04:58 -07:00
Olaoluwa Osuntokun
747e0f57d1
multi: fix linter errors 2017-07-30 18:22:45 -07:00
Olaoluwa Osuntokun
07212588fc
funding: update funding workflow to adhere to BOLT-0002
This commit updates the main single-funder funding workflow within the
fundingManager (initiated via the rpcserver or by a message from a
connected peer) to fully adhere to the funding protocol outlined in
BOLT-0002.

The major changes are as follows:
  * All messages modified to use the new funding messages in BOLT-0002.
  * The initiator of a funding workflow no longer decides how many
confirmations must elapse before the channel can be considered open.
  * Rather than each side specifying their desired CSV delay, both
sides now specify the CSV delay for the _other_ party.
2017-07-30 17:51:57 -07:00
Olaoluwa Osuntokun
6128fc6971
funding: avoid dereferencing a nil localDiscoverySignal
This commit fixes a possible panic within the funding manger’s workflow
for pending channels. We now ensure that the local discovery signal
retrieved from the localDiscoverySignals map is always non-nil.
Otherwise, we risk a server panic in the case that a node retransmits
the FundingLocked message after a channel has been fully processed, or
even just sends a FundingLocked message for a non-existent channel.
2017-07-14 17:14:22 -07:00
BitfuryLightning
e324fe5818 test: ensure blocks are synchronized before opening channels, allow more time for sync payments
Fix bug with synchronizing blockchain by adding several retries. Allow
to launch individual tests. Increase timeout for async payments.

Fixes #213.
2017-06-19 15:53:52 +02:00
Olaoluwa Osuntokun
b47ffde4ad
funding: use default routing policy when advertising initial channel routing policy 2017-06-17 00:15:38 +02:00
Olaoluwa Osuntokun
26c14c7de5
funding: we process the funding locked message _after_ shortChanID is known
This commit adds a new bit of synchronization to the funding manager to
ensure that we only process the funding locked message directly _after_
the short channel ID has become available within the channel. This
fixes a possible bug wherein we would receive the funding locked
message, and register the channel with the switch without yet knowing
the short chan ID. This would then cause any HTLC’s routed to the new
channel to fail, as it would be using the incorrect short channel ID.
2017-06-16 23:19:45 +02:00
Olaoluwa Osuntokun
4173b9748d
funding: obtain and populate shortChanID for MarkChannelAsOpen
This commit modifies the funding process to use the short channel ID,
rather than only the opening block height to mark a channel as open
once it has been confirmed. With this change, the short channel ID
information will now be available immediately after the channel has
been confirmed in the chain.
2017-06-16 23:15:55 +02:00
Olaoluwa Osuntokun
e72b030054
funding: use FundingBrodcastHeight as height hint for conf registrations 2017-06-05 19:16:00 -07:00
Olaoluwa Osuntokun
33decbe6ab
fundingmanager: fix logging message 2017-06-05 19:12:56 -07:00
Olaoluwa Osuntokun
8b432f8ca6
funding: query fee estimator and scale to fee-per-kw when making chan
This commit modifies the funding workflow slightly to move the querying
to the fee estimator (for the new channel) into the fundingManager
rather than within the LightningWallet layer. When querying to
FeePerWeight, we now multiply by 1000 to arrive at fee-per-kw.

Additionally, we now also properly thread through the fee-per-kw
offered by the initiator the to the responder of the channel workflow.
2017-05-16 19:11:00 -07:00
Olaoluwa Osuntokun
38a80ba066
funding: add TODO to parametrize dust limit 2017-05-16 19:07:07 -07:00
bryanvu
abe2e502d5 lnwallet: add FeeEstimator interface, StaticFeeEstimator implementation
This commit adds the FeeEstimator interface, which can be used for
future fee calculation implementations. Currently, there is only the
StaticFeeEstimator implementation, which returns the same fee rate for
any transaction.
2017-05-15 20:26:11 -07:00
bryanvu
18f453a3e6 lnwallet: add dust limit to contribution
In order to make the node's dust limit available to the wallet during
the initial stages of the funding process, add and set a
DustLimit field in the Contribution.
2017-05-15 20:26:11 -07:00
Olaoluwa Osuntokun
77cf7ed085
funding: modify ChainNotifier usage due to recent API change 2017-05-11 15:20:53 -07:00
Olaoluwa Osuntokun
a5113c2439
channeldb+funding: track opening height using MarkChannelAsOpen
This commit modifies the OpenChannel structure on-disk to also track
that opening height of a channel. This change is being made in order to
make and more light client friendly. A follow up commit will modify
several areas of the codebase to use this new functionality.
2017-05-11 15:20:33 -07:00
Olaoluwa Osuntokun
20bbe1e12d
funding: fix bug that double counts "pending channels" in GetInfo
This commit fixes a bug that double counts the number of pending
channels in GetInfo. Previously we weren’t yet storing the pending
channels on disk, we are now but comparing both the disk channel and
the channels within memory leads us to double count channels. To fix
this, we now only count the database channels.

Note that this NumPendingChannels method can now be removed as it’s no
longer needed.
2017-05-04 17:39:37 -07:00
Olaoluwa Osuntokun
0ab1c47d31
discovery+funding: update wire message usage to latest API changes 2017-04-19 16:20:53 -07:00
Olaoluwa Osuntokun
731f10eec0
funding: announce channel after confirmation, activate channel after FundingLocked
This commit modifies the order of operations after a channel has been
detected as fully opened. Rather than waiting until we receive the
FundingLocked message to announce the channel, we now do so immediately
after we detect the channel has been opened.

Additionally, we also patch a possible dead-lock bug by ensuring that
the RevokeAndAck message is always sent _after_ the FundingLocked
message. We do this by only passing the newly created channel too the
relevant sub-systems _after_ we receive the FundingLocked message. This
movement also serves to pave the way for our switch to the spec’s
funding workflow, as once we remove the initial revocation window,
there’ll be no way for us to initiate a state transition until we
receive the FundingLocked message from the remote party.
2017-04-16 15:39:21 -07:00
Olaoluwa Osuntokun
609cba95d7
funding+peer: switch to using new channel ID's
This commit modifies the way the fundingManager tracks pending funding
workflows internally. Rather than using the old auto-incrementing
64-bit pending channel ID’s, we now use a 32-byte pending channel ID
which is generated using a CSPRG. Additionally, once the final funding
message has been sent, we now de-multiplex the FundingLocked message
according to the new Channel ID’s which replace the old ChannelPoint’s
and are exactly 32-bytes long.
2017-04-16 15:34:29 -07:00
Olaoluwa Osuntokun
eb37dba3f6
funding: modify fundingManager config to use SignMessage for ann's
This commit modifies the fundingManager config to use the a SignMesage
function rather than two distinct functions for singing one half the
channel announcement proofs. This change unifies the signing of
messages under a single abstraction: the MessageSigner interface.
2017-04-14 11:17:48 -07:00
Olaoluwa Osuntokun
ca053e5273
multi: minor coding style and comment clean ups post-discovery merge
This commit implements some minor coding style, commenting and naming
clean up after the recent major discovery service was merged into the
codebase.

Highlights of the naming changes:
* fundingManager.SendToDiscovery -> SendAnnouncement
* discovery.Discovery -> discovery.AuthenticatedGossiper

The rest of the changes consist primary of grammar fixes and proper
column wrapping.
2017-04-01 20:14:05 +02:00
Andrey Samokhvalov
fbf766e3c6 discovery+funding: add 'AnnounceSignature' proof exchange
Add the interaction between nodes of announce signature messages, which
will allow us to exhcnage the half channel announcemen proofs later.
2017-03-29 19:49:05 -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
4c52b6e6a4 lnd: replace 'routing' with 'discovery' package
Add usage of the 'discovery' package in the lnd, now discovery service
will be handle all lnwire announcement messages and send them to the
remote party.
2017-03-29 19:49:05 -07:00
Olaoluwa Osuntokun
86a0b2f886
fundingmgr: fix logging message, correct column line wrap violation 2017-03-24 16:12:10 -07:00
Andrey Samokhvalov
61991a1c89 lnd: fix latest goclean.sh lint warning 2017-03-13 16:30:23 -07:00
Olaoluwa Osuntokun
7bdf02bc9e
routing: modify path finding routines use new EdgeInfo/EdgePolicy
This commit modifies the path finding routines to properly use the new
channel edge related API exposed by the database. Additionally, a new
type `ChannelHop` has been introduced which couples an edges routing
policy with the capacity and origin chain of the channel.
2017-03-08 14:25:05 -08:00
Olaoluwa Osuntokun
1e540b0f99
funding: modify channel announcements due to lnwire API change 2017-03-05 22:46:59 -06:00
Olaoluwa Osuntokun
c55e5f708f
funding: send the next revocation key within the FundingLocked msg 2017-02-24 16:32:17 -08:00
Olaoluwa Osuntokun
c1fbcae572
funding: fix bug that marks channel as open when ChainNotifier exist early
This commit fixes a bug that resulted from properly failing to do a
2-value read from the confirmation notification channel. If the
ChainNotifier was shutting down, then a nil read could be generated
which may prematurely mark the channel as open, and also trigger a nil
pointer panic exception below when the confDetails are accessed.

We fix this issue, by ensuring that we check the second value to see if
the channel has been closed or not.
2017-02-24 16:32:14 -08:00
Olaoluwa Osuntokun
02b7b911fb
funding: add assurance select to ensure goroutines exit on quit 2017-02-24 16:32:11 -08:00
Olaoluwa Osuntokun
cef81a6adf
funding: ensure reservations are cancelled if error'd at final stage 2017-02-24 16:32:07 -08:00
Olaoluwa Osuntokun
2d703d458d
funding: fix bug, ensure we exit if too may channels are pending 2017-02-24 16:32:03 -08:00
Olaoluwa Osuntokun
5cc0765b63
funding: rename ProcessRoutingMessage to SendToRouter
This commit renames routing processing method in the funding mangers
config from ProcessRoutingMessage to SendToRouter and also modifies the
signature to only require the message itself and not the server’s
identity public key.
2017-02-24 16:31:57 -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
bryanvu
0dd6cb99c1 fundingmanager: moved channel barriers from peer to funding manager.
Because peers may become disconnected or otherwise unavailable,
the channel barriers must be stored and managed within the fundingmanager.
2017-02-24 11:37:33 -08:00
bryanvu
3e02ea11ef channeldb: added isPending flag and queries
In order to facilitate persistence during the funding process, added
the isPending flag to channels so that when the daemon restarts, we can
properly re-initialize the chain notifier and update the state of
channels that were going through the funding process.
2017-02-24 11:37:33 -08:00
Olaoluwa Osuntokun
ace1adb13f
funding: fix logging display of node pub key upon recv funding req 2017-02-22 15:52:10 -08:00
Olaoluwa Osuntokun
e910b12d33
lnd: fix issues reported by golint+govet
github.com/lightningnetwork/lnd  master ✗

                                           0m ◒
▶ golint
htlcswitch.go:292:4: should replace numUpdates += 1 with numUpdates++
htlcswitch.go:554:6: var onionId should be onionID
htlcswitch.go:629:7: var onionId should be onionID
lnd_test.go:133:1: context.Context should be the first parameter of a
function
lnd_test.go:177:1: context.Context should be the first parameter of a
function
networktest.go:84:2: struct field nodeId should be nodeID
peer.go:1704:16: should omit 2nd value from range; this loop is
equivalent to `for invoice := range ...`
rpcserver.go:57:6: func newRpcServer should be newRPCServer

github.com/lightningnetwork/lnd  master ✗

                                        9m ⚑ ◒  ⍉
▶ go vet
features.go:12: github.com/lightningnetwork/lnd/lnwire.Feature
composite literal uses unkeyed fields
fundingmanager.go:380: no formatting directive in Errorf call
exit status 1
2017-02-22 14:58:37 -08:00
Olaoluwa Osuntokun
2636e654be
funding: ensure reservation contexts are remove in the case of workflow error 2017-02-22 14:51:45 -08:00
bryanvu
b21bd351e8 fundingmanager: change funding messages to use server.sendToPeer
Previously, during the channel funding process, peers sent wire
messages using peer.queueMsg. By switching to server.sendToPeer, the
fundingManager is more resilient to network connection issues or system
restarts during the funding process. With server.sendToPeer, if a peer
gets disconnected, the daemon can attempt to reconnect and continue the
process using the peer’s public key ID.
2017-02-21 19:21:19 -08:00
Olaoluwa Osuntokun
12f69692aa
multi: update sub-systems to use latest iteration of wire messages 2017-02-21 01:42:37 -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
Olaoluwa Osuntokun
de70175be6
lnwallet+funding: properly propagate NewLightningChannel errors
This commit ensures that we now properly handle and propagate errors
that arise when attempting to create a new channel after the funding
transaction is believed to be confirmed.

A previous edge case would arise when a user attempted to create a new
channel, but their corresponding btcd node wasn’t yet fully synced.
2017-01-22 15:06:41 -08:00
Trevin Hofmann
40c7bac3aa multi: fix a variety of typos throughout the repo 2017-01-17 17:02:56 -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
eb1509a1cf
funding: properly display channel funding point in handleFundingOpen 2017-01-12 18:31:21 -08:00
Olaoluwa Osuntokun
9965640349
lnd: add support for pushing funds as part of channel funding
This commit adds daemon level support for pushing funds as part of the
single funder channel workflow. This new feature allows the user to
open a channel and simultaneously make a channel at the same time which
can improve the UX when setting up a channel for the first time.
2017-01-09 19:05:36 -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
c965eda29e
lnd: fully integrate the ChannelRouter of the new routing package
This commit fully integrates the ChannelRouter of the new routing
package into the main lnd daemon.

A number of changes have been made to properly support the new
authenticated gossiping scheme.

Two new messages have been added to the server which allow outside
services to: send a message to all peers possible excluding one, and
send a series of messages to a single peer. These two new capabilities
are used by the ChannelRouter to gossip new accepted announcements and
also to synchronize graph state with a new peer on initial connect.

The switch no longer needs a pointer to the routing state machine as it
no longer needs to report when channels closed since the channel
closures will be detected by the ChannelRouter during graph pruning
when a new block comes in.

Finally, the funding manager now crafts the proper authenticated
announcement to send to the ChannelRouter once a new channel has bene
fully confirmed. As a place holder we have fake signatures everywhere
since we don’t properly store the funding keys and haven’t yet adapted
the Signer interface (or create a new one) that abstracts out the
process of signing a generic interface.
2016-12-27 16:44:31 -08:00
Olaoluwa Osuntokun
bd89a9312d
lnd: switch to using the connmgr for listening and persistent conns
This commit revamps the way in bound and outbound connections are
handled within lnd. Instead of manually managing listening goroutines
and also outbound connections, all the duty is now assigned to the
connmgr, a new btcsuite package.

The connmgr now handles accepting inbound (brontide) connections and
communicates with the server to hand off new connections via a
callback. Additionally, any outbound connection attempt is now made
persistent by default, with the assumption that (for right now),
connections are only to be made to peers we wish to make connections
to. Finally, on start-up we now attempt to connection to all/any of our
direct channel counter parties in order to promote the availability of
our channels to the daemon itself and any RPC users.
2016-12-14 18:15:55 -08:00
Andrey Samokhvalov
d01f1b5ff4 fundingmanager+lnwallet: add HTLC dust limit logic 2016-12-13 11:01:57 -08:00
Andrey Samokhvalov
5a82240c6a lnwire+lnwallet+fundingmanager: general improvements 2016-12-13 11:01:57 -08:00
Olaoluwa Osuntokun
494fcec874
breacharbiter: introduce new sub-system to watch for breaches
This commit introduces a new sub-system into the daemon whose job it is
to vigilantly watch for any potential channel breaches throughout the
up-time of the daemon. The logic which was moved from the utxoNursery
in a prior commit now resides within the breachArbiter.

Upon start-up the breachArbiter will query the database for all active
channels, launching a goroutine for each channel in order to be able to
take action if a channel breach is detected. The breachArbiter is also
responsible for notifying the htlcSwitch about channel breaches in
order to black-list the breached linked during any multi-hop forwarding
decisions.
2016-11-28 19:44:09 -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
Andrey Samokhvalov
5b9e4ae61e general: fix typos, rename variables, add comments 2016-11-23 20:02:29 -06:00
Olaoluwa Osuntokun
22074eb737
lnwallet: integrate obfuscated state hints into funding workflow
This commit finalizes the implementation of #58 by integrating passing
around the obfuscate state hints into the funding workflow of the
wallet, and also the daemon’s funding manager.

In order to amend the tests, the functions to set and receive the state
hints are now publicly exported.
2016-11-16 12:54:39 -08:00
Olaoluwa Osuntokun
4fe23a8b3e
lnd: switch over to using brontide for p2p connections
This commit modifies the existing p2p connection authentication and
encryption scheme to now use the newly designed ‘brontide’
authenticated key agreement scheme for all connections.

Additionally, within the daemon lnwire.NetAddress is now used within
all peers which encapsulates host information, a node’s identity public
key relevant services, and supported bitcoin nets.
2016-10-27 19:49:17 -07:00
Olaoluwa Osuntokun
81f7efe1e0
lnwallet+funding: include node net address in reservation workflow
This commit modifies the existing channel reservation workflow slightly
to thread through the IP address that we were able to reach the node
at, or the one which the node reached us via. Additionally, rather than
using OpenChannel.FullSync() at the end of the reservation workflow, we
now use OpenChannel.FullSyncWithAddr() in order to create the
relationship in the database between the channel, and the p2p node we
created the channel with.

All tests, as well as a portion of the fundingManager have been updated
accordingly,
2016-10-26 14:56:58 -07:00
Olaoluwa Osuntokun
290ea7ba5d
lnd: update peer+fundingManager due to channeldb field rename 2016-10-25 16:44:18 -07:00
Olaoluwa Osuntokun
bb7f41933f
funding: exit if pending channel doesn't exist for max pending error 2016-10-23 18:37:50 -07:00
Olaoluwa Osuntokun
afae7aad2a
lnwire: add concrete error type to ErrorGeneric 2016-10-23 13:41:23 -07:00
Andrey Samokhvalov
7196c4bb1c fundingmanager: add max pending channel check 2016-10-22 02:15:35 +03:00
Andrey Samokhvalov
14c6770b76 general: fix typos 2016-10-22 01:48:05 +03:00
Olaoluwa Osuntokun
9bd5105ae5
cmd/lncli: avoid unnecessarily re-encoding graph vertexes in routing table 2016-09-21 19:48:42 -07:00
Olaoluwa Osuntokun
5ebaf9d1e7
routing: vertexes are now serialized pub keys instead of pubkey hashes 2016-09-21 19:48:35 -07:00
andrew.shvv
2788dbeaa8 Add RPC to show current total available channel capacity #29 (#35)
This commit adds a new RPC command: `channelbalance` which returns the
sum of all available channel capacity across all open channels. The
total balance is currently returned in units of `satoshis`. Additionally
the `networkHarness` has been modified slightly to allow specifying the
additional "extra" command line parameters when creating the initial
seed nodes. Minor refactoring within the integration tests has been
undertaken in order to increase code re-use across tests.

Closes #29.
2016-09-15 12:00:56 -07:00
Olaoluwa Osuntokun
49ce1040d4
lnwallet: adopt simple fee structure for commitment transactions
This commit modifies the prior funding workflow to account for fees
when creating the funding output. As a stop gap, the current fee for
the commitment transaction is now hard-coded at 5k satoshis. Once the
fee models are in place this should instead be some high multiple of
the current “average” fee rate within the network, continuing, the
proper fee should be adjusted from the commitment transaction has
outputs are added/removed.
2016-09-12 19:08:01 -07:00
Olaoluwa Osuntokun
0d871dabb3
lnd: modify the daemon's initialization to use new wallet API's 2016-09-08 12:26:07 -07:00
BitfuryLightning
2bcff188e8 lncli: Add graphical output of routing table
LIGHT-131, LIGHT-140, LIGHT-138
`lncli showroutingtable` may output routing table as image.
Use graphviz for graph rendering.
Add explicit version dependency for tools. Add error checking.
2016-09-06 20:06:51 -04:00
BitfuryLightning
d8bceb16f9 routing: Fix bugs with not sending routing messages
LIGHT-138, LIGHT-141. Due to some issues in sending/receiving parts of lnd,
messages with zero length are not sent. So added some mock content to
NeighborAck. Moved sender/receiver from routing message to wrap message
which contains lnwire routing message.
2016-09-06 20:01:21 -04:00
Olaoluwa Osuntokun
832fd248cd
lnd: add async updates for [open|close]channel RPC's
This commit modifies the internal workflow for opening or closing a
channel in order to create a path in which RPC clients can receive
updates. Updates are now communicated via channels from the goroutines
spawned by the RPC server to process the request, and the sub-system
within the daemon that actually executes the request.

With this change clients can now receive updates that the request is
pending (final message has been sent to the target client), or that the
request has been completed. Confirmation related updates have not yet
been implemented as that will require some changes to the ChainNotifier
interface.
2016-08-30 16:53:07 -07:00
Olaoluwa Osuntokun
4bc315d061
lnd: minor clean up with comments + go fmt after latest PR merge 2016-08-11 11:56:03 -07:00
BitfuryLightning
f8c851769f multi: initial integration of routing module
This commit integrates BitFury's current routing functionality into lnd. The
primary ochestration point for the routing sub-system in the routingMgr. The
routingMgr manages all persistent and volatile state related to routing within
the network.

Newly opened channels, either when the initiator or responder are inserted into
the routing table once the channel is fully open. Once new links are inserted
the routingMgr can then perform path selection in order to locate an "optimal"
path to a target destination.
2016-08-11 11:20:27 -07:00
Olaoluwa Osuntokun
979b43a3b8
lnd: add log ticker to htlcSwitch, log metrics before forwarding
This commit adds a ticker which attempts to print the total volume
sent/recv over the last 10 seconds if any updates took place during
that interval.

Additionally, when selecting a link to forward an htlcPacket insert a
break after selection in order to properly terminate the loop.
2016-07-21 16:21:33 -07:00
Olaoluwa Osuntokun
a56ab46e97
lnd: properly switch RPC port with target net change
With this commit, support for changing the target network (testnet,
simnet, etc) has been finalized. Previously a command line option was
present to swap networks, but the RPC port wouldn’t automatically be
updated to reflect the network.
2016-07-13 18:37:59 -07:00
Olaoluwa Osuntokun
98fae7f329
lnd: properly disconnect peer and clean up resources after critical errors 2016-07-13 16:40:07 -07:00
Olaoluwa Osuntokun
9b29fa3a52
lnd: use channel barriers to synchronize on-chain events and a peer's readHandler 2016-07-12 17:38:14 -07:00
Olaoluwa Osuntokun
07166fe88b
lnd: implement pendingchannels RPC
This commit implements the “pendingchannels” RPC within the rpcserver.
This RPC allows callers to receive details concerning the current
pending channels associated with the daemon. Pending channels are those
waiting for additional confirmations before they can be considered
opened/closed.

At the time of this commit, only open channels are shown. A future
commit will also add the confirmation updates, along with information
for close channels.
2016-07-07 15:33:58 -07:00
Olaoluwa Osuntokun
c5cc96a524
lnd: implement the getinfo RPC call 2016-07-05 18:57:14 -07:00
Olaoluwa Osuntokun
927db9cfd5
lnd: update the FundingManager to new revoke key funding workflow 2016-06-30 12:15:06 -07:00
Olaoluwa Osuntokun
1188fd2bf6
lnd: implement open+close channel workflow in daemon
This commit adds the necessary plumbing within the server, peer, and
rpcServer to handle opening and cooperatively closing a channel with a
remote peer.

Many new data structures have been added to the peer in order to allow
it to efficiently manage opening+.losing new/existing lightning
channels. Additional documentation has been added to several methods
within the peer struct, with some minor renaming along with way. The
peer has also gained a dedicated goroutine whose job it is to manage
any requests pertaining to opening, or closing any channels with the
remote peer.

The messages have been added to lnrpc define the requests and responses
to channel open+close messages. Additional channel logic has been added
between the rpcServer, peer, and server in order to properly manage the
necessary synchronization.
2016-06-21 13:14:05 -07:00
Olaoluwa Osuntokun
31e5466692
lnd: introduce the fundingManager
This commit introduces the fundingManger which is used as a bridge
between the wallet’s internal ‘ChannelReservation’ workflow, and the
wire protocol’s funding messages.

 The funding manger is responsible for progressing the workflow, and
communicating any errors generated during the workflow back to the
source peer.
2016-06-21 13:13:49 -07:00