Commit Graph

103 Commits

Author SHA1 Message Date
Johan T. Halseth
1923d40843
lnwallet+funding: enable AnchorsZeroFeeHtlcTx commit type if both nodes support
We assume the legacy anchor type is no longer advertised by us.
2020-12-15 10:13:18 +01:00
carla
f4136decae
multi: add max local csv config option
To allow nodes more control over the amount of time that their funds
will be locked up, we add a MaxLocalCSVDelay option which sets the
maximum csv delay we will accept for all channels. We default to the
existing constant of 10000, and set a sane minimum on this value so that
clients cannot set unreasonably low maximum csv delays which will result
in their node rejecting all channels.
2020-11-04 13:55:37 +02:00
Oliver Gugger
f2e0ed19ff
lnwallet+fundingmgr: ignore shim channels in pending count
Externally funded channels are expected by the user and explicitly
registered through the use of a funding shim and should therefore not
count towards the max pending channel count which is primarily there to
mitigate DoS attacks.
2020-08-28 12:28:43 +02:00
Oliver Gugger
56b916a313
lnwallet: don't publish funding TX if flag set on assembler
The first channels of a batch shouldn't publish the batch TX
to avoid problems if some of the funding flows can't be completed.
Only the last channel of a batch should publish. We set the channel flag
accordingly depending on the flag in the assembler.
2020-07-08 17:13:14 -07:00
Conner Fromknecht
0f94b8dc62
multi: return input.Signature from SignOutputRaw 2020-04-10 14:27:35 -07:00
Oliver Gugger
5a52420ab6
lnwallet+fundingmgr: interrupt funding flow for PSBT
In case the funding manager detects that a funding flow is requested
to be executed with the help of a PsbtIntent, the normal channel
negotiation with the remote peer is interrupted, as soon as the
accept_channel message was received. With the remote peer's funding
multisig key and our local key, we can derive the funding output
script and its address. This is enough to start the PSBT funding
and signing process which the user will do externally to the daemon.
2020-03-31 09:17:24 +02:00
Olaoluwa Osuntokun
c85f6bb364
lnwallet: mark channel as frozen based on ShimIntent
In this commit, we make the internal channel funding flow aware of
frozen channels. We also update the testSingleFunderReservationWorkflow
method to ensure that the created channels have the proper type bit set.
2020-03-23 16:57:00 -07:00
Johan T. Halseth
ea2a58e80f
fundingmanager+lnwallet: enable anchor commitments
If both nodes are signalling the feature, make all opened channels using
this type.
2020-03-09 12:59:35 +01:00
Johan T. Halseth
f95a82bf5f
lnwallet+funding: create CommitmentType enum 2020-03-09 12:59:34 +01:00
Johan T. Halseth
8741b93723
lnwallet/reservation: add non-initiator balance check
If we are the initiator, we check that our starting balance after
subtracting fees are not less than two times the default dust limit.

This commit adds a similar check for the non-initiator case, checking
that the remote party has a starting balance of reasonable size.
2020-03-09 12:59:34 +01: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
7a64a7d3a4
lnwallet: delegate all channel funding logic to the new chanfunding package
In this commit, we begin to integrate the new channel funding package
into the existing codebase. With this set of changes, we'll no longer
construct and sign the funding transaction within this package, instead
delegating it to the new chanfunding package. We use the new
chanfunding.WalletAssembler to carry out all channel funding, providing
it with an implementation of all its interfaces backed by the wallet.
2019-12-02 17:11:36 -06:00
Olaoluwa Osuntokun
4e955dfac6
lnwallet: remove unused openChanDetails struct
We also remove some related and also unused attributes as well along the
way.
2019-12-02 17:11:29 -06: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
Joost Jager
b58dbb2d70
multi: fix canceled spelling 2019-10-03 17:27:36 +02:00
Olaoluwa Osuntokun
0b62126067
multi: update funding workflow to be aware of new tweakless commits
In this commit, we update the funding workflow to be aware of the new
channel type that doesn't tweak the remote party's output within the
non-delay script on their commitment transaction. To do this, we now
allow the caller of `InnitChannelReservation` to signal if they want the
old or new (tweakless) commitment style.

The funding tests are also updated to test both funding variants, as
we'll still need to understand the legacy format for older nodes.
2019-09-25 18:25:46 -07:00
Johan T. Halseth
1a4ba97562
Merge pull request #3274 from esneider/fix-typo-in-doc
Fix typo in doc
2019-09-18 08:37:06 +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
esneider
66b5574f4c Fix typo in doc 2019-07-05 19:40:04 -03:00
AdamISZ
6e054886d8 Typo corrections in various comments 2019-05-10 17:15:54 +02:00
Joost Jager
9e012ecc93
multi: move Input interface and related code
This commit is a step to split the lnwallet package. It puts the Input
interface and implementations in a separate package along with all their
dependencies from lnwallet.
2019-01-31 13:25:33 +01:00
Olaoluwa Osuntokun
b220c47ce7
Revert "funding+lnwallet: ensure max_htlc_value_in_flight smaller than capacity"
This reverts commit 4aa52d267f000f84caf912c62fc14a5b8e7cacb5.

It turns out that the other implementations set values for this field
which aren't based on the actual capacity of the channel. As a result,
we'll no reject most of their channel offerings, since they may offer a
value of a max `uint64` or something else hard coded that's above the
size of the channel. As a result, we're reverting this check for now to
maintain proper compatibility.
2019-01-29 17:58:04 -08:00
Johan T. Halseth
4aa52d267f
funding+lnwallet: ensure max_htlc_value_in_flight smaller than capacity
Return an error to the remote if larger.
2019-01-22 08:42:29 +01:00
Olaoluwa Osuntokun
509bed614c
Merge pull request #2198 from Roasbeef/sendall-rpc
multi: add ability to sweep all coins in the the wallet to an addr to sendcoins
2019-01-15 14:49:17 -08:00
Wilmer Paulino
71410f6a08
lnwallet+fundingmanager: use ChannelConstraints struct with CommitConstraints 2019-01-11 17:01:27 -08:00
Olaoluwa Osuntokun
bd9ebbd5af
lnwallet: add more godoc to InputScript rename ScriptSig field to SigScript 2019-01-09 15:55:18 -08:00
Dave Kerr
1977d45de5 multi: fix function references in comments and clarify grammar 2018-09-27 20:59:59 -07:00
Johan T. Halseth
2a77b57788
lnwallet + funding: move funding tx publish to fundingmgr
This commit moves the responsibility for publishing the funding tx to
the network from the wallet to the funding manager. This is done to
distinguish the failure of completing the reservation within the wallet
and failure of publishing the transaction.

Earlier we could fail to broadcast the transaction, which would cause us
to fail the funding flow. This is not something we can do directly,
since the CompeteReservation call will mark the channel IsPending in the
databas.e
2018-07-31 14:53:21 +02:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Wilmer Paulino
3a982063a0
fundingmanager+lnwallet: ensure proposed channel reserve is above dust limit 2018-05-14 14:20:20 -04:00
Johan T. Halseth
3d55767838
lnwallet/reservation: remove RegisterMinHTLC
We remove this method, as our minHtlc value is set using the
CommitConstraints method.
2018-04-06 10:02:19 +02:00
PaddyQuinn
5410725306 lnwallet: update comments 2018-03-12 19:37:18 -04:00
Olaoluwa Osuntokun
8425a35684
lnwallet: in NewChannelReservation ensure commit fees are payable
In this commit, we fix a bug introduced by the recent change of
lnwire.MilliSatoshi to be an unsigned integer. After this change an
integer underflow was left undetected, as a result we’ll now
momentarily cast to a signed integer in order to ensure that both sides
can pay the proper fee.
2018-03-08 12:50:47 -05:00
Olaoluwa Osuntokun
5ecef17e0f
lnwallet: modify logging to display mSAT amount if funding constrains invalid 2018-03-08 12:50:47 -05:00
Johan T. Halseth
bb63ad7da6
lnwallet: send ReservationError for unacceptable constraints 2018-03-06 22:02:34 +01:00
Johan T. Halseth
e1bb762cf7
lnwallet: denominate in fee rate types 2018-02-26 22:42:25 +01:00
Johan T. Halseth
50f495fae1
lnwallet: cleanup of reservation.CommitConstraints, and move RemoteChanConstraints.
This commit adds some more comments and checks to
reservation.CommitConstraints, including making
MinHTLC value one of the passed constraints.

RemoteChanConstraints is also moved out of
reservation.
2018-02-08 18:35:24 -05:00
nsa
7e7516137d
lnwallet: validate commited channel constraints 2018-02-08 18:35:23 -05:00
MeshCollider
4b1cc98808 multi: apply roasbeef diff to support incoming socks.ProxiedAddr 2018-02-05 17:37:46 -08:00
Olaoluwa Osuntokun
3036fc0181 lnwallet: disallow creation of channels < 2x dust limit
Fixes #633.
2018-01-28 15:11:13 -08:00
Johan T. Halseth
fffe15f0fd lnwallet: add FundingFlag parameter to InitChannelReservation 2017-12-17 18:35:34 -08:00
Olaoluwa Osuntokun
5e5cc9b209
lnwallet: add new method to register our preferred minHTLC value
Before this commit, during a reservation, we wouldn’t ever specify our
minHTL value. We don’t yet fully validate all channel constrains, but
doing this now serves to ensure that once those features are merged,
we’ll actually be setting a valid value for minHTLC.
2017-12-13 17:15:43 -08:00
Olaoluwa Osuntokun
91bb95991e
lnwallet: make 1% reservation computation clearer
Adding 99 here didn’t really do anything but obfuscate when we were
trying to compute. We’re just using internet division to calculate 1%
of the channel capacity amount. This is the amount that the remote
party must remain above at all times.
2017-11-26 14:08:57 -06:00
Olaoluwa Osuntokun
24ad3e17de
lnwallet: reject funding flows if local amount is insufficient w.r.t fees 2017-11-26 14:08:56 -06:00
Olaoluwa Osuntokun
6d10677ef5
lnwallet: allow callers to specify fee for funding transaction in funding flow
In this commit, we modify the funding reservation workflow slightly to
allow callers to specify their own custom fee when initialization a
funding workflow. This gives power-users the ability to control exactly
how much in fees are paid for each new funding transaction.
2017-11-23 23:10:06 -06:00
Olaoluwa Osuntokun
7f667e2dbc
lnwallet: update funding flow to use new channeldb API's 2017-11-10 19:50:59 -08:00