Commit Graph

15387 Commits

Author SHA1 Message Date
yyforyongyu
17a0a8de06 cmd+lntest: use the new rpc field Payment_INITIATED 2023-10-06 16:34:47 -07:00
yyforyongyu
65879a45e6 lnrpc: update routerrpc to use the new status 2023-10-06 16:34:47 -07:00
yyforyongyu
c175386c4d channeldb+routing: apply method Terminated to decide a payment's terminal state
This commit applies the new method `Terminated`. A side effect from
using this method is, we can now save one query `fetchPayment` inside
`FetchInFlightPayments`.
2023-10-06 16:34:47 -07:00
yyforyongyu
fac6044501 channeldb: add unit test for decidePaymentStatus 2023-10-06 16:34:47 -07:00
yyforyongyu
390f3c8253 channeldb: expand PaymentStatus to explicitly represent payment status
This commit introduces more granular statuses to better determine a
payment's current state. Based on whether there are inflight HTLCs, the
state of each of the HTLCs, and whether the payment is failed, a total
of 5 states are derived, which can give a finer control over what action
to take based on a given state.

Also, `fetchPayment` now uses `decidePaymentStatus`. After applying the
new function, the returned payment status would be different,

```
| inflight | settled | failed | reason |       previous  ->   now          |
|:--------:|:-------:|:------:|:------:|:---------------------------------:|
|   true   |   true  |  true  |   yes  |    StatusInFlight(unchanged)      |
|   true   |   true  |  true  |   no   |    StatusInFlight(unchanged)      |
|   true   |   true  |  false |   yes  |    StatusInFlight(unchanged)      |
|   true   |   true  |  false |   no   |    StatusInFlight(unchanged)      |
|   true   |   false |  true  |   yes  |    StatusInFlight(unchanged)      |
|   true   |   false |  true  |   no   |    StatusInFlight(unchanged)      |
|   true   |   false |  false |   yes  |    StatusInFlight(unchanged)      |
|   true   |   false |  false |   no   |    StatusInFlight(unchanged)      |
|   false  |   true  |  true  |   yes  |    StatusSucceeded(unchanged)     |
|   false  |   true  |  true  |   no   |    StatusSucceeded(unchanged)     |
|   false  |   true  |  false |   yes  |    StatusSucceeded(unchanged)     |
|   false  |   true  |  false |   no   |    StatusSucceeded(unchanged)     |
|   false  |   false |  true  |   yes  |     StatusFailed(unchanged)       |
|   false  |   false |  true  |   no   |     StatusInFlight(unchanged)     |
|   false  |   false |  false |   yes  |     StatusFailed(unchanged)       |
|   false  |   false |  false |   no   |  StatusInFlight -> StatusInitiated|
```
2023-10-06 16:34:47 -07:00
yyforyongyu
09b67af48d channeldb: add method Registrable to decide adding HTLCs
This commit adds a new method, `Registrable`, to help decide whether
adding new HTLCs to a given payment is allowed. A new unit test,
`TestRegistrable` is also added to test it.
2023-10-06 16:34:47 -07:00
yyforyongyu
c71601124a channeldb: fix variable name used in RegisterAttempt
Renamed `p` to `payment` to since it's used by the method's pointer receiver.
2023-10-06 16:34:47 -07:00
yyforyongyu
105c275b91 channeldb: add method updatable to decide updating payments
This commit adds a new method, `updatable`, to help decide whether
updating a given payment is allowed.
2023-10-06 16:34:47 -07:00
yyforyongyu
a6f4f0dfc9 channeldb: add method removable to decide removing payments
This commit adds a new method, `removable`, to help decide whether
deleting a payment is allowed.
2023-10-06 16:34:47 -07:00
yyforyongyu
de33c3e009 channeldb: add method initializable to decide initiating payment
This commit adds a new method, `initializable`, to help decide whether
initiating a payment is allowed.
2023-10-06 16:34:47 -07:00
yyforyongyu
30fd29371c channeldb: add new payment status StatusInitiated
This commit adds a new payment status, `StatusInitiated`, to properly
represent the state where a payment is newly created without attempting
any HTLCs. Since the `PaymentStatus` is a memory representation of a
given payment's status, the enum used for the statuses are directly
updated.
2023-10-06 16:34:47 -07:00
yyforyongyu
6be3817eed channeldb: return error when payment is not initialized
This commit changes `fetchPaymentStatus` to return an error when the
payment creation info bucket cannot be found. Instead of using the
ambiguous status `StatusUnknown`, we tell the callsite explictly that
there's no such payment. This also means the vague `StatusUnknown` can
now be removed as it has multiple meanings.
2023-10-06 16:34:47 -07:00
yyforyongyu
21cecc40e1 channeldb: return error when payment is not found in duplicate payments
We also update the legacy code to return an error when the payment is
not found.
2023-10-06 16:34:47 -07:00
Suheb
b7d1c6666f docs/release-notes: add template for 0.18.0
Signed-off-by: saubyk <39208279+saubyk@users.noreply.github.com>
2023-10-06 16:34:47 -07:00
Vincent
80bfd17cf2
docs: add instructions to generate type hints (#8025)
* Add instructions to generate type hints 

Use mypy to generate .pyi files as well. These files are useful for type hinting in IDEs.

* Update python.md

fix lines that got swapped in copy-paste

* remove mypy 

mypy is not a dependency
2023-10-06 16:47:17 +02:00
Oliver Gugger
dce4bb16be
Merge pull request #8063 from guggero/fix-linter
cmd/lncli: fix linter complaint by running make fmt
2023-10-06 13:14:17 +00:00
Oliver Gugger
7ef11e8ae4
cmd/lncli: fix linter complaint by running make fmt 2023-10-05 22:47:02 +02:00
Olaoluwa Osuntokun
92fe545b0a
Merge pull request #8053 from kilrau/fix/lncli-desc
lncli: fix description of connect/disconnect peer
2023-10-05 13:27:46 -07:00
Kilian
682827c7af
lncli: fix description of connect/disconnect peer 2023-10-05 18:13:32 +02:00
Oliver Gugger
31ba616b1c
Merge pull request #7925 from Crypt-iQ/funding_maturity
funding: wait for coinbase maturity before sending channel_ready
2023-10-05 15:26:30 +00:00
Oliver Gugger
563d6d5427
Merge pull request #7970 from bartoli/master
Fix missing space in message
2023-10-05 15:20:14 +00:00
Oliver Gugger
529dc203a5
Merge pull request #8017 from Rooke/master
trivial: Fix spelling errors
2023-10-05 08:42:08 +00:00
Oliver Gugger
3ffd59a8c9
Merge pull request #7998 from bota87/master
sample-lnd.conf: fix typo
2023-10-05 08:06:31 +00:00
bota87
6041f97fb6 sample-lnd.conf: fix typo 2023-10-04 21:59:17 +02:00
Olaoluwa Osuntokun
13e1fd3f09
Merge pull request #8056 from guggero/release-template-link-fix
GitHub: fix link in release template
2023-10-04 11:13:49 -07:00
Oliver Gugger
3b0d918ea4
GitHub: fix link in release template
Fixes #8055.
This PR fixes a broken link in the release page template.
2023-10-04 09:36:51 +02:00
Olaoluwa Osuntokun
2fb150c8fe
build: bump version to v0.17.0 2023-10-03 10:20:31 -07:00
Olaoluwa Osuntokun
caa9bf9222
Merge pull request #8043 from Roasbeef/0-17-rc6
build: bump version to v0.17.0 rc6
2023-09-28 13:45:52 -05:00
Olaoluwa Osuntokun
4e6bb71c0f
build: bump version to v0.17.0 rc6 2023-09-28 12:00:41 -05:00
Olaoluwa Osuntokun
bb7a257359
Merge pull request #8037 from yyforyongyu/fix-weight-calc
lnwallet+rpcserver: fix weight calculation for taproot channels
2023-09-28 11:21:29 -05:00
Olaoluwa Osuntokun
edeb0d7db5
Merge pull request #8041 from Roasbeef/background-peer-prune
peer: launch persistent peer pruning in background goroutine
2023-09-28 11:18:10 -05:00
yyforyongyu
522518922f
lnwallet+rpcserver: fix weight calculation for taproot channels 2023-09-28 19:42:13 +08:00
yyforyongyu
62d240bba1
itest: add testSendDirectPayment
Adds a new test to check direct payments between two nodes. The fee rate
is tuned to 1 sat/vb to catch edge cases.
2023-09-28 19:42:11 +08:00
Olaoluwa Osuntokun
eae9dd07f0
peer: launch persistent peer pruning in background goroutine
This PR is a follow up, to a [follow
up](https://github.com/lightningnetwork/lnd/pull/7938) of an [initial
concurrency issue](https://github.com/lightningnetwork/lnd/pull/7856)
fixed in the peer goroutine.

In #7938, we noticed that the introduction of `p.startReady` can cause
`Disconnect` to block. This happens as `Disconnect` cannot be called
until `p.startReady` has been closed. `Disconnect` is also called from
`InboundPeerConnected` (the case of concurrent peers, so we need to
remove one of the connections) while the main server mutex is held. If
`p.Start` blocks for any reason, then this leads to the deadlock as: we
can't disconnect until we've finished starting, and we can't finish
starting as we need the disconnect caller to exit as it has the mutex.

In this commit, we now make the call to `prunePersistentPeerConnection`
async. The call to `prunePersistentPeerConnection` eventually wants to
grab the server mutex, which triggers the circular waiting scenario
above.

The main learning here is that no calls to the main server mutex path
can block from `p.Start`. This is more or less a stop gap to resolve the
issue initially introduced in v0.16.4. Assuming we want to move forward
with this fix, we should reexamine `p.startReady` all together, and also
revisit attempt to refactor this section of the code to eliminate the
mega mutex in the server in favor of a dedicated event loop.
2023-09-27 21:24:50 -05:00
Olaoluwa Osuntokun
1ebfe95772
Merge pull request #8035 from Roasbeef/0-17-rc5
build: bump version to v0.17.0 rc5
2023-09-26 18:21:07 -05:00
Olaoluwa Osuntokun
f63a2b9507
build: bump version to v0.17.0 rc5 2023-09-26 16:11:45 -05:00
Olaoluwa Osuntokun
01a05fdea7
Merge pull request #8031 from guggero/chan-acceptor-taproot-chan
chanacceptor+lnrpc: add simple taproot channel support
2023-09-26 16:08:19 -05:00
Oliver Gugger
d16e7a5eef
itest: add itest for externally funded taproot chans 2023-09-26 21:45:17 +02:00
Oliver Gugger
d94ae3f509
lnrpc+rpcserver: add musig2 to ChanPointShim 2023-09-26 21:45:17 +02:00
Oliver Gugger
ebf98c6d51
chanacceptor: add simple taproot channels 2023-09-26 21:45:16 +02:00
Oliver Gugger
3821baa0c8
Merge pull request #8024 from Roasbeef/htlc-resolver-c-queue
contractcourt: modify the incoming contest resolver to use concurrent…
2023-09-26 16:03:10 +00:00
Olaoluwa Osuntokun
abe888f719
contractcourt: modify the incoming contest resolver to use concurrent queue
In this commit, we modify the incoming contest resolver to use a
concurrent queue. This is meant to ensure that the invoice registry
subscription loop never blocks. This change is meant to be minimal and
implements option `5` as outlined here:
https://github.com/lightningnetwork/lnd/issues/8023.

With this change, the inner loop of the subscription dispatch method in
the invoice registry will no longer block, as the concurrent queue uses
a fixed buffer of a queue, then overflows into another queue when that
gets full.

Fixes https://github.com/lightningnetwork/lnd/issues/7917
2023-09-25 18:48:30 -05:00
Michael Rooke
78d9996620
trivial: Fix spelling errors
- Fixes some spelling in code comments and a couple of function names
2023-09-21 22:35:33 -04:00
eugene
8f20cd82fb
funding: add TestFundingManagerCoinbase test
This tests that the funding manager doesn't immediately consider
a coinbase transaction that is also a funding transaction usable
until the maturity has been reached.
2023-09-21 11:33:42 -04:00
eugene
5e6ebf561b
chanfunding: introduce NewShimIntent for testing
This is needed so that the next commit can create a ShimIntent
without having to export the ShimIntent's fields.
2023-09-21 11:33:42 -04:00
eugene
0cf3552515
funding: wait for coinbase maturity before sending channel_ready 2023-09-21 11:33:38 -04:00
Oliver Gugger
a1b0a7eb02
Merge pull request #8021 from petertodd/2023-09-fix-ots-name
Fix capitalization of OpenTimestamps in release notes
2023-09-21 10:56:46 +00:00
Peter Todd
d5b88dde72
Fix capitalization of OpenTimestamps in release notes 2023-09-21 02:10:14 -04:00
Olaoluwa Osuntokun
ec585431a9
Merge pull request #8004 from Roasbeef/0-17-rc4
build: bump version to v0.17.0 rc4
2023-09-18 18:44:29 -07:00
Olaoluwa Osuntokun
8948dfa113
build: bump version to v0.17.0 rc4 2023-09-18 13:58:41 -07:00