Commit Graph

295 Commits

Author SHA1 Message Date
Joost Jager
55ff1131de
fundingmanager: check remote min htlc against our defaults 2019-12-11 00:16:59 +01:00
Joost Jager
ddb98fcc41
multi: distinguish between htlc in and out constraints 2019-12-11 00:16:57 +01:00
Joost Jager
dbce59d4e1
fundingmanager: do not calculate unused policy values 2019-12-11 00:16:53 +01:00
Olaoluwa Osuntokun
abb44e18e2
Revert "funding: ensure the chan policy max htlc size is below max pay size"
This reverts commit 9b3385e87de8b2da51a9c979cd4e8ef770078ae2.
2019-12-06 15:12:17 -08:00
Olaoluwa Osuntokun
183797f102
Merge pull request #3655 from carlaKC/fundingmgr-optionupfrontshutdown
Add Option Upfront Shutdown
2019-12-04 21:05:24 -08:00
Olaoluwa Osuntokun
9b3385e87d
funding: ensure the chan policy max htlc size is below max pay size 2019-12-04 15:11:01 -08:00
carla
9b35c349de
multi: Set upfront shutdown from open and accept chanel messages
This commit gets upfront shutdown scripts from openchannel and
acceptchannel wire messages sent from our peer and sets upfront
shutdown scripts in our open and accept channel messages when
the remote peer supports option upfront shutdown and we have
the feature enabled.
2019-12-03 11:38:29 +02:00
Olaoluwa Osuntokun
6e9cbc19f9
lnwallet+funding: pass the pending channel ID into the reservation context
In this commit, we start to thread the pending channel ID from wire
protocol all the way down into the reservation context. This change will
allow negotiation to take place _outside_ the protocol that may result
in a particular chanfunding.Assembler being dispatched.
2019-12-02 17:11:46 -06:00
Olaoluwa Osuntokun
f9d22cd900
funding: only broadcast the funding transaction if we actually have it 2019-12-02 17:11:21 -06:00
Johan T. Halseth
8755a35860
Merge pull request #3667 from cfromknecht/log-fixes
fundingmanager+routing log touch ups
2019-11-20 15:57:05 +01:00
Conner Fromknecht
16318c5a41
multi: merge local+global features from remote peer 2019-11-08 05:31:47 -08:00
Conner Fromknecht
52b3d5bbf7
fundingmanager: print hex of pending chan id, use snake case 2019-11-05 15:04:43 -08:00
Olaoluwa Osuntokun
4592f87033
Merge pull request #3653 from Roasbeef/external-funding-chainfees
chainfees: create new chainfees package extracting fees from lnwallet
2019-10-31 17:44:00 -07:00
Olaoluwa Osuntokun
777ed104a3
chainfee: create new chainfee package extracting fees from lnwallet
In this commit, we create a new chainfee package, that houses all fee
related functionality used within the codebase. The creation of this new
package furthers our long-term goal of extracting functionality from the
bloated `lnwallet` package into new distinct packages. Additionally,
this new packages resolves a class of import cycle that could arise if a
new package that was imported by something in `lnwallet` wanted to use
the existing fee related functions in the prior `lnwallet` package.
2019-10-31 16:41:57 -07:00
Olaoluwa Osuntokun
a73ee28e46
multi: convert the existing channeldb.ChannelType uint8 into a bit field
In this commit, we convert the existing `channeldb.ChannelType` type
into a _bit field_. This doesn't require us to change the current
serialization or interpretation or the type as it is, since all the
current defined values us a distinct bit. This PR lays the ground work
for any future changes that may introduce new channel types (like anchor
outputs), and also any changes that may modify the existing invariants
around channels (if we're the initiator, we always have the funding
transaction).
2019-10-31 16:34:37 -07:00
Johan T. Halseth
12a1d05127
fundingmanager: make SendToPeer sync
Since the funding flow requires messages to go through, make use of
sync version of SendToPeer. Using the async version we would risk that
the message was dropped and the process would stall (it would properly
continue after a restart though).
2019-10-24 13:08:08 +02:00
Olaoluwa Osuntokun
0e13c5ac3f
lnwallet+funding: expose new ValidateChannel method for 1st party validation
In this commit, we use the recently added `chanvalidate` package to
verify channels once they have been confirmed in the funding manager. We
expose a new method on the `LightningWallet` struct: `ValidateChannels`
which calls the new shared 1st party verification code.

After the channel is fully confirmed in the funding manager, we'll now
use this newly exposed method to handle all validation. As a result, we
can remove the existing validation code in the funding manager, and rely
on the new code in isolation.
2019-10-03 16:23:23 -07:00
Olaoluwa Osuntokun
2dddbc84d9
lncfg+lnd: gate usage of tweakless commitments based on local/global feature bits
In this commit, we add a new legacy protocol command line flag:
`committweak`. When set, this forces the node to NOT signal usage of the
new commitment format. This allows us to test that we're able to
properly establish channels with legacy nodes. Within the server, we'll
now gate our signalling of this new feature based on the legacy protocol
config. Finally, when accepting/initiating a new channel funding, we'll
now check both the local and remote global feature bits, only using the
new commitment format if both signal the global feature bit.
2019-09-25 18:26:04 -07:00
Olaoluwa Osuntokun
b1d122773e
Merge pull request #1910 from halseth/fundingmanager-state-machine
Fundingmanager state machine cleanup
2019-09-25 16:31:51 -07:00
nsa
4d02100e12
fundingmanager+server: adding ChannelAcceptor to the fundingmanager 2019-09-25 12:07:30 -04:00
Johan T. Halseth
9f3fbda71f
fundingmanager: remove unnecessary Peer param to sendFundingLocked 2019-09-24 21:24:40 +02:00
Johan T. Halseth
5b8e97da29
funding: update comment aboute offline peers
Since fundingLocked now are being sent reliably, the only message left
to be sent reliably is the node announcement for private channels.
2019-09-24 21:24:40 +02:00
Johan T. Halseth
9ff6de5be1
funding: add TODO for consistency check 2019-09-24 21:24:39 +02:00
Johan T. Halseth
bda0e40dad
fundingmanager: save markedOpen before marking the channel open
This commit fixes a potential issue within the fundingmanager, where
failing to write the channel opening state could cause the channel being
marked open in the DB, but the opening state not being set. On startup
this would cause the channel state machine to not be able to resume.

We fix this by saving the channel opening state _first_. This works
because saving the opening state is idempotent, and in case a channel is
found pending at startup, it will re-register for confirmation
notifications and re-do the process.
2019-09-24 21:24:39 +02:00
Johan T. Halseth
88f5e06427
fundingmanager: unify handling of pending and non-pending channels at startup
Since the advanceFundingState now can handle pending channels, we'll
call it for both pending and non-pending channels, just making sure that
we re-initialize the channel barriers and re-publish the funding tx fro
pending channels.
2019-09-24 21:24:39 +02:00
Johan T. Halseth
8a61af6a55
fundingmanager: make advanceFundingState handle pending channels
This commit makes advanceFundingState check whether a channel is still
pending before checking the channel opening state. This lets us call it
directly, without checking whether a channel has confirmed first.
2019-09-24 21:24:39 +02:00
Johan T. Halseth
893c6cbc59
fundingmanager: make waitForFundingTimeout sync
This commit makes the waitForFundingTimeout method synchronous, and
return ErrConfirmationTimeout in case the timeout is reached.

We also simplify the internals by using waitForTimout defined earlier.
2019-09-24 21:24:35 +02:00
Johan T. Halseth
47fae26dc4
fundingmanager: define method waitForTimeout
This commit defines a new method waitForTimeout, that will be used to
listen for channels timing out. It handles a subset of what is already
handled by waitForFundingWithTimeout, but we want to break that one up
in smaller parts, and waitForTimeout is the first of these.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
ea196f6e8f
fundingmanager make waitForFundingConfirmation decrement waitgroup
Since waitForFundingConfirmation is always called in a goroutine, we
make this explicit by requireing the caller to always increment the
waitgroup before calling it.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
76857dbcdc
fundingmanager: move handleFundingConfirmation out of waitForFundingWithTimeout
Similarly to what we did in the previous commit, we move the
responsibility of marking the channel open by calling
handleFundingConfirmation out from waitForFundingWithTimeout to the
caller.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
25f6094802
fungingmanager: move handleFundingConfirmation out of waitForfundingConfirmation
This commit moves the handling of a funding confirmation out of
waitForFundingConfirmation, and instead let the caller handle marking
the channel opened.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
b51b76b469
fundingmanager: extract opening logic into new method handleFundingConfirmation
This commit moves the opening logic found within
waitForFundingConfirmation into a new method handleFundingConfirmation.
This will make it easier to later break up waitForFundingConfirmation,
and avoid code duplication.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
b2a7e42f44
fundingmanager: commit to new states in stateStep
This commit moves the saving of the new channelOpeningState to the
stateStep method.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
49bbf0eb61
fundingmanager: call advanceFundingState in place of handleFundingConfirmation
This commit removes the handleFundingConfirmation method, and instead
hands the newly confirmed channel of to advanceFundingState, which will
take the channel through the rest of the channel opening flow.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
e274c2fb7c
fundingmanager: call advanceFundingState from handleFundingSigned
Since the advanceFundingSigned now can resume a channel from any state,
we resue the logic in handleFundingSigned instead of manually executing
each step of the funding flow.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
cbf1fe6bb1
fundingmanager: define stateStep, make advanceFundingState sync
This commit make the advanceFundingStateMethod synchronous. It will now
query the database for a channel's opening state, and call the method
stateStep until the channel has finished the opening procedure.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
08cb313934
fundingmanager: move startup state check into advanceFundingState method
This commit extracts the funding state check we do at startup into a new
method advanceFundingState. In later commits we will modify this method
to work for all funding state machine flows, not only on restart.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
e189f78567
fundingmanager: remove dead code
Pending channels will never have a channel opening state, and hence will
never be pending.
2019-09-24 21:24:32 +02:00
Johan T. Halseth
e4301d3a8f
lnwire: rename ErrorCode -> FundingError
To make it clear that these errors are not part of the spec, rename them
to FundingError.
2019-09-20 10:55:21 +02:00
Johan T. Halseth
33fe09482b
lnwire+multi: define Error() for lnwire.Error
To make lnwire.Error actually satisfy the error interface, define the
Error method directly.
2019-09-20 10:55:21 +02:00
Johan T. Halseth
ff37b711c6
funding: dont's send ErrorCode on wire
Since the ErrorCodes are not part of the spec, they cannot be read by
other implementations.

Instead of only sending the error code we therefore send the complete
error message. This will have the same effect at the client, as it will
just get the full error instead of the code indicating which error it
is. It will also be compatible with other impls.

Note that the GRPC error codes will change, since we don't set them
anymore.
2019-09-20 10:55:20 +02:00
Joost Jager
3d7de2ad39
multi: remove dead code 2019-09-10 17:21:59 +02:00
Johan T. Halseth
b9816259cb
fundingmanager+server: define subtractFees
Let one initiate a funding request with the remaining funds in the
wallet.
2019-07-18 00:58:12 +02:00
Johan T. Halseth
fcf74debe6
lnwallet+funding: rename Capacity and FundingAmt
Instead use LocalFundingAmt and RemoteFundingAmt to make it clear who is
contributing funds.
2019-07-18 00:33:14 +02:00
Johan T. Halseth
e716251805
server+funding: remove unused remoteFundingAmt 2019-07-18 00:33:14 +02:00
Johan T. Halseth
452ee6aad4
fundingmanager+server: define MaxPendingChans. RejectPush in funding config
This commit makes the funding manager access the MaxPendingChannels and
RejectPush values from the fundingConfig instead of the global config
struct.

Done to avoid sharing state between tests.
2019-07-18 00:33:14 +02:00
Johan T. Halseth
00a86696a8
Merge pull request #3145 from federicobond/avoid-pubkey-serialization
discovery,fundingmanager: avoid serialization in NotifyWhenOnline
2019-06-12 10:50:35 +02:00
Federico Bond
9bd3055fb8 discovery,fundingmanager: avoid serialization in NotifyWhenOnline 2019-06-04 16:36:21 -03:00
Federico Bond
aea52f4bef multi: replace manual CAS with sync.Once in component start/stop
This guarantees callers that the method will not return until it
has executed completely at least once.
2019-05-30 17:14:04 -03:00
Joost Jager
dff0387363
lntest: move itest into package 2019-05-28 21:43:23 +02:00