Commit Graph

118 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
530c49f12e
funding: sent channel to breachArbiter as soon as it's open 2017-11-23 23:10:14 -06:00
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