Commit Graph

1168 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
7feb8b21e1
multi: upgrade new taproot TLVs to use tlv.OptionalRecordT
In this commit, we update new Taproot related TLVs (nonces, partial sig,
sig with nonce, etc). Along the way we were able to get rid of some
boiler plate, but most importantly, we're able to better protect against
API misuse (using a nonce that isn't initialized, etc) with the new
options API. In some areas this introduces a bit of extra boiler plate,
and where applicable I used some new helper functions to help cut down
on the noise.

Note to reviewers: this is done as a single commit, as changing the API
breaks all callers, so if we want things to compile it needs to be in a
wumbo commit.
2024-02-29 11:32:26 -06:00
Olaoluwa Osuntokun
72764b1473
Merge pull request #8100 from bhandras/updateinvoice-refactor
channeldb: refactor `UpdateInvoice` to make it simpler to create SQL specific implementation
2024-02-27 16:50:02 -08:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
Elle Mouton
dc25b425c0
channeldb+lnwallet: add ShutdownInfo with read and write methods
ShutdownInfo contains any info about a previous Shutdown message that we
have sent. This commit adds this type along with read and write methods
for it in the channel db. The existence of the ShutdownInfo on disk
represents the fact that we have previously sent the Shutdown message
and hence that we should resend it on re-establish.
2024-02-21 11:56:15 +02:00
Andras Banki-Horvath
5e746b4d2c
invoices: move InvoiceDB tests unrelated to kvdb to invoices package 2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
6b0931af82
invoices: move UpdateInvoice implementation to the invoices package
With the introducation of the `InvoiceUpdater` interface we are now
able to move the non-kv parts of `UpdateInvoice` completely under
the invoices package. This is a preprequisite for being able to use
the same code-base for the sql InvoiceDB implementation of
UpdateInvoice.
2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
ecbfc46312
invoices+channeldb: add InvoiceUpdater interface and the KV impl
This commit introduces the InvoiceUpdater interface which is meant
to abstract and assist the in-memory invoice update procedure with
the accompanying database updates. These abstract updater steps will
enable further refactoring later while also ensuring that a full
SQL implementation of the InvoiceDB interface will be possible.
2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
998156930f
invoices: refactor updateInvoiceAmpState to return new state
With this commit updateInvoiceAmpState becomes getUpdatedInvoiceAmpState
which will only return the new AMP state but that needs to be applied at
the call site. This is a part of a larger refactor to gather all
mutations of an invoice update to be later applied by the invoice
updater.
2024-02-19 20:47:24 +01:00
Andras Banki-Horvath
08df7f4175
invoices: change cancelSingleHtlc to be purely used for validation
This change moves the HTLC state change out of the cancelSingleHtlc
function. This is part of the larger refactor of collecting all changes
to be later applied by the invoice updater.
2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
87044b815c
invoices: rename updateInvoiceState to getUpdatedInvoiceState
This commit turns updateInvoiceState "const" by moving preimage update
out of the function while also removing it to getUpdatedInvoiceState.
2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
342eb4eac2
invoices: refactor updateHtlc to return new state
With this refactor updateHtlc is renamed to getUpdatedHtlcState and
changed such that it won't change the HTLC's state and resolve time but
instead returns whether the change is needed. This change is part of a
multi-commit refactor to ensure that all changes to the invoice will be
tracked individually.
2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
ef5a31733e
channeldb: do not change the update descriptor when cancelling htlcs 2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
7298b2d190
channeldb: extract AMP state updates to updateInvoiceAmpState() 2024-02-19 20:47:23 +01:00
Andras Banki-Horvath
4bf6b52158
channeldb: fetch the invoice before calling into updateInvoice 2024-02-19 20:47:22 +01:00
Andras Banki-Horvath
eb4198b970
channeldb: extract store update methods when updaing an invoice
This commit is a small refactor to move all actual DB updates after
an invoice state is update to separate methods. This is a small
preliminary change before we completely decouple DB updates from
in-memory invocie update.
2024-02-19 20:47:22 +01:00
yyforyongyu
605211823d
multi: fix timestamp filters for payment query
This commit fixes the timestamp precision to always compare the dates
using unix seconds for payments.
2024-02-05 15:26:49 +08:00
yyforyongyu
18333e8c7d
multi: fix timestamp filters for invoice query
This commit fixes the timestamp precision to always compare the dates
using unix seconds for invoices.
2024-02-05 15:26:43 +08:00
Yong
59feec44ca
Merge pull request #7976 from w3irdrobot/serialize-deserialize-amp
Serialize/deserialize AMP struct in hop
2024-01-29 09:48:05 +08:00
Elle Mouton
6c427a6ba9
multi: update FetchChanInfos to take in an optional tx
In this commit, the FetchChanInfos ChannelGraph method is updated to
take in an optional read transaction for the case where it is called
from within another transaction.
2024-01-22 21:07:55 +02:00
Elle Mouton
8cf4044215
channeldb: rename delChannelEdge to delChannelEdgeUnsafe
In order to emphasise the fact that the ChannelGraph's cacheMu should be
acquired before calling the `delChannelEdge` method, we add the `Unsafe`
postfix and add a comment to alert readers.
2024-01-22 21:07:55 +02:00
Elle Mouton
ab06665fde
channeldb: acquire mutexes in the same order throughout
In this commit, we ensure that the channeldb cacheMu mutex is only ever
aquired _before_ acquiring the main DB lock in the cases where the two
locks need to be held simultaneously.

With this commit, the deadlock demonstrated in the previous commit is
now fixed.
2024-01-22 21:07:55 +02:00
Elle Mouton
76748bdbf7
channeldb: add ChannelGraph stress test
This commit adds a test that calls many of the ChannelGraph methods
concurrently and in a random order. This test demonstrates that a
deadlock currently exists in the ChannelGraph since the test does not
complete. This is fixed in the next commit.
2024-01-22 21:07:54 +02:00
Oliver Gugger
2b83ea309a
Merge pull request #8407 from mohamedawnallah/fix-typo-channel.go
fix: fix typo "(cltv_expiry" to "(cltv_expiry)" in `channeldb/channel.go` [skip ci]
2024-01-22 00:46:06 -06:00
Mohamed Awnallah
8407e6989e
fix: fix typo "(cltv_expiry" to "(cltv_expiry)" [skip ci] 2024-01-20 17:31:19 +02:00
Keagan McClelland
239103c2b3 multi: make tlv onion compulsory 2024-01-11 09:43:31 -08:00
Alex Sears
4521894ed2
channeldb: Serialize/deserialize AMP struct in hop
The AMP struct in a hop was never being set when deserizlied. Also,
the AMP TLV record was not being added when the hop was serialized.
This sets the TLV record when serializing and correctly sets the
AMP struct on the hop when that record is present.

Co-authored-by: BitcoinCoderBob <90647227+BitcoinCoderBob@users.noreply.github.com>
Co-authored-by: Tee8z <tee8z@protonmail.com>
2024-01-09 10:02:16 -05:00
bitcoin-lightning
b72fc9529e docs: fix typos 2023-12-21 15:21:35 +00:00
Elle Mouton
a242ad5acb
channeldb+discovery: use timestamps to maybe revive zombie 2023-12-11 09:12:05 +02:00
Elle Mouton
ebe0755a97
channeldb: make MarkEdgeLive logic reusable
This commit is a set-up commit. It extracts the logic from
`MarkEdgeLive` to a helper `markEdgeLive` method so that the logic can
be called from within other kvdb.Update blocks. This will be used in the
next commit.
2023-12-11 09:12:05 +02:00
Elle Mouton
0ad4ef373a
channeldb+discovery: fetch timestamps from DB if required 2023-12-11 09:12:05 +02:00
Elle Mouton
50e17dab59
channeldb: reformat TestFilterChannelRange 2023-12-11 09:12:04 +02:00
Elle Mouton
893147d83e
channeldb: don't initialise edge index bkt as top level
The `edgeIndexBucket` key name is used to key a sub-bucket within the
`edgeBucket` bucket. And so the `edgeIndexBucket` is not a top level
bucket.
2023-12-11 09:12:04 +02:00
yyforyongyu
85f4b13632
multi: enhance logging around channel reestablishment 2023-11-28 14:06:53 +08:00
Elle Mouton
0193274c10
multi: return error from MarkEdgeLive if not found
Let MarkEdgLive return a new ErrNotZombieEdge error if an entry with the
given channel ID cannot be found. In processZombieUpdate, we then
check for this error and log accordingly.
2023-11-13 20:58:06 +02:00
Elle Mouton
034283db10
channeldb: update TestGraphZombieIndex to use require 2023-11-13 20:58:05 +02:00
yyforyongyu
da8f1c084a
channeldb+routing: add new interface method TerminalInfo
This commit adds a new interface method `TerminalInfo` and changes its
implementation to return an `*HTLCAttempt` so it includes the route for
a successful payment. Method `GetFailureReason` is now removed as its
returned value can be found in the above method.
2023-11-13 16:09:11 +08:00
yyforyongyu
e8c0226e1c
routing: add AllowMoreAttempts to decide whether more attempts are allowed 2023-11-13 16:09:11 +08:00
yyforyongyu
7209c65ccf
routing: split launchShard into registerAttempt and sendAttempt
This commit removes the method `launchShard` and splits its original
functionality into two steps - first create the attempt, second send the
attempt. This enables us to have finer control over "which error is
returned from which system and how to handle it".
2023-11-13 16:09:10 +08:00
Elle Mouton
0e82293e45
multi: address linter issues 2023-11-08 14:50:35 +02:00
Elle Mouton
84cdcd6847
multi: move DB schemas to channeldb/models
This commit moves the ChannelEdgePolicy, ChannelEdgeInfo,
ChanelAuthProof and CachedEdgePolicy structs to the `channeldb/models`
package.
2023-11-08 14:50:35 +02:00
Elle Mouton
78ff28fea1
channeldb: remove unused func arguments 2023-11-08 14:50:35 +02:00
Elle Mouton
3a17479ff4
multi: remove LightningNode from ChannelEdgePolicy
Finally, The LightningNode object is removed from ChannelEdgePolicy.
This is a step towards letting ChannelEdgePolicy reflect exactly the
schema that is on disk.

This is also nice because the `Node` object is not necessarily always
required when the ChannelEdgePolicy is loaded from the DB, so now it
only get's loaded when needed.
2023-11-08 14:50:34 +02:00
Elle Mouton
6c76d31e89
multi: let FetchLightningNode take an optional tx
In preparation for the next commit which will remove the
`*LightningNode` from the `ChannelEdgePolicy` struct,
`FetchLightningNode` is modified to take in an optional transaction so
that it can be utilised in places where a transaction exists.
2023-11-08 14:50:34 +02:00
Elle Mouton
9a62a46aa3
channeldb: remove kvdb.Backend from ChannelEdgePolicy 2023-11-08 14:50:34 +02:00
Elle Mouton
f06f08f596
channeldb: remove kvdb.Backend from ChannelEdgeInfo 2023-11-08 14:50:34 +02:00
Elle Mouton
9dc1a1dfec
channeldb: convert FetchOtherNode to ChannelGraph method
To prepare for the `kvdb.Backend` member of `ChannelEdgeInfo` being
removed, the `FetchOtherNode` method is moved from the `ChannelEdgeInfo`
to the `ChannelGraph` struct.
2023-11-08 14:50:34 +02:00
Elle Mouton
6d878c65fc
channeldb: remove kvdb.Backend from LightningNode
Now that the kvdb.Backend is no longer required, it is removed from the
LightningNode struct.
2023-11-08 14:50:34 +02:00
Elle Mouton
fa7c1e250b
multi: let ForEachChannel be a method on ChannelGraph
Having a `ForEachChannel` method on the `LightningNode` struct itself
results in a `kvdb.Backend` object needing to be stored within the
LightningNode struct. In this commit, this method is replaced with a
`ForEachNodeChannel` method on the `ChannelGraph` struct will perform
the same function without needing the db pointer to be stored within the
LightningNode. This change, the LightningNode struct more closely
represents the schema on disk.

The existing `ForEachNodeChannel` method on `ChannelGraph` is renamed to
`ForEachNodeDirectedChannel`. It performs a slightly different function
since it's call-back operates on Cached policies.
2023-11-08 10:51:50 +02:00
Andras Banki-Horvath
8bf7503aa4
invoices: remove the now unused ScanInvoices method 2023-10-18 16:15:58 +02:00
Andras Banki-Horvath
8ab267ad90
channeldb: add k/v implementation for InvoiceDB.DeleteCanceledInvoices method 2023-10-18 16:15:58 +02:00
Andras Banki-Horvath
1f8065de35
channeldb: add k/v implementation for InvoiceDB.FetchPendingInvoices 2023-10-18 16:15:57 +02:00
András Bánki-Horváth
ad5cd9c8bb
multi: extend InvoiceDB methods with a context argument (#8066)
* multi: extend InvoiceDB methods with a context argument

This commit adds a context to InvoiceDB's methods. Along this refactor
we also extend InvoiceRegistry methods with contexts where it makes
sense. This change is essential to be able to provide kvdb and sqldb
implementations for InvoiceDB.

* channeldb: restrict invoice tests to only use an InvoiceDB instance

* docs: update release notes for 0.18.0
2023-10-11 13:42:59 +02:00
Carla Kirk-Cohen
fee0e05708 multi: add blinded path TLVs to onion payload / hops
This commit adds the encrypted_data, blinding_point and total_amt_msat
tlvs to the known set of even tlvs for the onion payload. These TLVs
are added in two places (the onion payload and hop struct) because
lnd uses the same set of TLV types for both structs (and they
inherently represent the same thing).

Note: in some places, unit tests intentionally mimic the style
of older tests, so as to be more consistently readable.
2023-10-06 16:38:33 -07:00
yyforyongyu
20e7e801c0 routing+channeldb: use HTLCAttempt instead of HTLCAttemptInfo
This commit refactors the params used in lifecycle to prefer
`HTLCAttempt` over `HTLCAttemptInfo`. This change is needed as
`HTLCAttempt` also wraps settled and failure info, which is useful in
the following commits.
2023-10-06 16:38:33 -07:00
yyforyongyu
34d0e5d4c5 routing+channeldb: make MPPayment into an interface
This commit turns `MPPayment` into an interface inside `routing`. Having
this interface gives us the benefit to write more granular unit tests
inside payment lifecycle. As seen from the modified unit tests, several
hacky ways of testing the `SendPayment` method is now replaced by a mock
over `MPPayment`.
2023-10-06 16:38:33 -07:00
yyforyongyu
e5840f6216 channeldb+routing: add NeedWaitAttempts to decide waiting for attempts
This commit adds a new method, `NeedWaitAttempts`, to properly decide
whether we need to wait for the outcome of htlc attempts based on the
payment's current state.
2023-10-06 16:38:33 -07:00
yyforyongyu
89ac071e56 channeldb: add HasSettledHTLC and PaymentFailed fields to state 2023-10-06 16:38:33 -07:00
yyforyongyu
52c00e8cc4 multi: move payment state handling into MPPayment
This commit moves the struct `paymentState` used in `routing` into
`channeldb` and replaces it with `MPPaymentState`. In the following
commit we'd see the benefit, that we don't need to pass variables back
and forth between the two packages. More importantly, this state is put
closer to its origin, and is strictly updated whenever a payment is read
from disk. This approach is less error-prone comparing to the previous
one, which both the `payment` and `paymentState` need to be updated at
the same time to make sure the data stay consistant in a parallel
environment.
2023-10-06 16:38:31 -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
Jamal James
cbb4c27a44
docs: fix simple-taproot-channels typo [skip ci] (#7926) 2023-08-25 15:48:37 -07:00
Elle Mouton
dfec4a65cb
multi: update lightning-onion version
Update the lighting-onion dependency to include the lates changes which
support route blinding.
2023-08-23 12:09:53 +02:00
Olaoluwa Osuntokun
76f0f67b7c
channeldb: update ChanSyncMsg to populate nonce info
In this commit, we update the ChanSyncMsg to populate nonce information.
With this change, we can now hide nonce generation further down in the
pipeline and ensure that all callers will have the expected fields
populated.
2023-08-22 16:31:49 -07:00
Olaoluwa Osuntokun
349eee3263
input: ensure sessionOpts is properly threaded through 2023-08-22 16:31:47 -07:00
Olaoluwa Osuntokun
39d5dffd56
lnwallet: update genHtlcSigValidationJobs to be taproot aware
In this commit, we update the genHtlcSigValidationJobs function to be
taproot aware. As we actually need a schnorr signature for the taproot
validation, we need to coerce the entire wire type into a schnorr sig
with the ForceSchnorr() method.
2023-08-22 16:31:31 -07:00
Olaoluwa Osuntokun
05b5391614
channeldb: add new db type for taproot channels 2023-08-22 16:30:52 -07:00
Olaoluwa Osuntokun
b368e476c5
lnwire: update Sig to support both ECDSA and schnorr sigs
In this commit, we update the Sig type to support ECDSA and schnorr
signatures. We need to do this as the HTLC signatures will become
schnorr sigs for taproot channels. The current spec draft opts to
overload this field since both the sigs are actually 64 bytes in length.
The only consideration with this move is that callers need to "coerce" a
sig to the proper type if they need schnorr signatures.
2023-08-22 16:29:19 -07:00
Oliver Gugger
59b5fb1565
channeldb+funding: move policy encoding into channel DB 2023-08-22 06:22:33 +08:00
Oliver Gugger
36fcf65e97
funding+channeldb: rename fwding -> forwarding 2023-08-18 09:44:23 +02:00
Oliver Gugger
eda34a8d2a
channeldb: move fwding policy code to new file 2023-08-18 09:44:06 +02:00
ziggie
87fc58ecfe
multi: Add a channel.db migration.
The new migration removes the sweeper-last-tx top level bucket
from the channel.db database.
2023-08-15 10:00:30 +02:00
Olaoluwa Osuntokun
7f95810359
Merge pull request #7710 from carlaKC/7297-updateaddtlvs
Channeldb: Store HTLC Extra TLVs in Onion Blob Varbytes
2023-06-16 14:31:11 -05:00
Oliver Gugger
56dba2df03
multi: update linter, fix new issues 2023-06-13 11:58:33 +02:00
Carla Kirk-Cohen
7b1a288320
channeldb: store extra HTLC data in variable onion blob slot
Take advantage of the variable byte encoding for a known length field
to extend HLTCs with additional data.
2023-06-02 11:01:44 -04:00
Carla Kirk-Cohen
2fc8e9d617
multi: update channel db HTLC OnionBlob to array
We know that onion blobs in lightning are _exactly_ 1366 bytes in
lightning, but they are currently expressed as a byte slice in
channeldb's HTLC struct. Blobs are currently serialized as var bytes,
so we can take advantage of this known length and variable length
to add additional data to the inline serialization of our HTLCs, which
are otherwise not easily extensible (without creating a new bucket).
2023-06-02 11:01:43 -04:00
shaurya947
396a4cb6c4
channeldb: persist channel Memo field and read it when fetching
We add a Memo field to the OpenChannel DB struct. We also persist
it using a tlv record. We then pass the Memo value from the
InitFundingReserveMsg when creating a new reservation for the channel.
Finally, we also read Memo field when fetching channel from DB.
2023-05-18 13:02:30 -04:00
Elle Mouton
9ea3f55694
multi: update "funding locked" comments
Replace a few un-caught instances of "funding locked" in some comments
with "channel_ready"
2023-04-27 20:02:34 +02:00
Elle Mouton
fe2304efad
channeldb: add a FetchChannelByID method
Add a FetchChannelByID method that allows a caller to fetch an
OpenChannel using an lnwire.ChannelID.
2023-04-24 13:15:40 +02:00
Elle Mouton
63442cbe51
channeldb: factor out generic FetchChannel logic
This commit introduces a new `channelSelector` method and moves all
generic logic from `FetchChannel` to it. This refactor will make it
easier to add new methods that require the same open-channel db
traversal with slightly different channel selection logic.
2023-04-24 13:15:39 +02:00
Elle Mouton
908cb6060b
channeldb: optimise FetchChannel method
This commit adds a small optimisation to the FetchChannel method.
Instead of iterating over each channel bucket, an identifiable error is
thrown once the wanted channel is found so that the iteration can stop
early.
2023-04-24 13:10:13 +02:00
Elle Mouton
aebdd2375c
channeldb: lint FetchChannel method
A few lint fixes of the FetchChannel method.
2023-04-24 13:10:12 +02:00
Oliver Gugger
3beaf7c4c1
channeldb: use input.GenMultiSigScript 2023-04-11 11:15:36 +02:00
Olaoluwa Osuntokun
f9f08079d0
Merge pull request #7576 from lightningnetwork/0-17-0-staging
lnd: merge v0.17.0 staging branch into master
2023-04-05 16:48:50 -07:00
yyforyongyu
6b9217acfc
multi: replace FundingLocked related docs
This commit replaces `FundingLocked` found in docs using the following
command,
```shell
find . -name "*.go" -exec sed -i '' 's/FundingLocked/ChannelReady/g' {} \;
find . -name "*.go" -exec sed -i '' 's/FundingLock/ChannelReady/g' {} \;
```
2023-03-17 18:21:59 +08:00
yyforyongyu
f8a8326141
multi: replace FundingLocked and funding_locked strings
This commit is created by running the following commands,
```shell
find . -name "*.go" -exec sed -i '' 's/\"FundingLocked/\"ChannelReady/g' {} \;
find . -name "*.go" -exec sed -i '' 's/FundingLocked\"/ChannelReady\"/g' {} \;
find . -name "*.go" -exec sed -i '' 's/\ funding_locked/\ channel_ready/g' {} \;
```
2023-03-17 18:21:59 +08:00
positiveblue
09e87ea99b
channeldb: add serializeAndStoreInvoice helper func 2023-03-14 19:26:18 -07:00
positiveblue
65fc8d72c6
channeldb: clean updateInvoice func
All the updates type are now catched in a switch statement, we can
delete the rest of the body of this function + add a default path for
not matched flows.
2023-03-14 19:26:18 -07:00
positiveblue
6ff6c45a6b
channeldb: split addHTLCs logic in the UpdateInvoice method 2023-03-14 19:26:18 -07:00
positiveblue
27fbc2f60b
channeldb: split cancelInvoice logic in the UpdateInvoice method 2023-03-14 19:26:15 -07:00
positiveblue
cbaec4382a
channeldb: split settleHodlInvoice logic in the UpdateInvoice method 2023-03-14 19:01:52 -07:00
positiveblue
a3f6d5c97e
channeldb: split cancelHTLCs logic in the UpdateInvoice method
Previous to this commit we were able to call `UpdateInvoice` with an
updated that added and cancelled htlcs at the same time. The function
returned an error if there was overlapping between the two htlc set.
However, that behavior was not used in the LND code itself.

Eventually we want to split this method in multiple ones, among them one
for canceling htlcs and another one for adding them. For that reason,
this behavior is not supported anymore.
2023-03-14 18:56:01 -07:00