2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-09 19:10:47 +00:00
Commit Graph

1570 Commits

Author SHA1 Message Date
Boris Nagaev
8c97c60bb4
Merge pull request #803 from starius/loop-cli-path-opts-fix
cmd/loop: fix path options and loopDir interaction
2024-08-05 10:44:19 -03:00
Boris Nagaev
dd57e8fb4e
cmd/loop: fix path options and loopDir interaction
According to the comment in the code, loopdir should affect tls cert path and
macaroon path only if custom values were not set for them. However the actual
code ignored custom tls cert path and macaroon path if loopdir and/or network
was changed. For instance, the following call:

loop --network regtest --tlscertpath tls.cert --macaroonpath loop.macaroon

resulted in using ~/.loop/regtest/tls.cert and ~/.loop/regtest/loop.macaroon
instead of the files provided.

This commit fixes the code to match the description in the comment.
Also the comment was updated to mention custom network setting in addition
to custom loopdir.
2024-08-05 00:37:41 -03:00
András Bánki-Horváth
d8361e3105
Merge pull request #795 from yingshanghuangqiao/master
chore: fix some comments
2024-07-22 10:59:13 +02:00
yingshanghuangqiao
57ebc3ff16 chore: fix some comments
Signed-off-by: yingshanghuangqiao <yingshanghuangqiao@foxmail.com>
2024-07-22 16:11:16 +08:00
András Bánki-Horváth
70b0af1452
Merge pull request #794 from crystalstall/master
chore: fix some comments for struct field
2024-07-19 08:36:47 +02:00
crystalstall
27a234db66 chore: fix some comments for struct field
Signed-off-by: crystalstall <crystalruby@qq.com>
2024-07-19 14:20:07 +08:00
Boris Nagaev
4c490398e4
Merge pull request #787 from starius/sweepbatcher-greedy-batch-selection
sweepbatcher: add greedy batch selection algorithm
2024-07-18 14:19:03 -03:00
Boris Nagaev
7a61d5e743
loopout_test: enable logging in sweepbatcher 2024-07-18 13:38:57 -03:00
Boris Nagaev
026cf0d47a
sweepbatcher: always try greedy batch selection
Now that sweep.minFeeRate is always set, greedy batch selection has all needed
inputs to work even without customFeeRate provider.
2024-07-18 13:38:57 -03:00
Boris Nagaev
75641c3573
sweepbatcher: always fill sweep.minFeeRate
Use customFeeRate if it is provided, otherwise use wallet's EstimateFeeRate.

Added flag SkipNextBump to rbfCache to avoid extra bumping upon updating
fee rate externally.

Fix test TestSweepBatcherCloseDuringAdding, it didn't have confTarget and
failed in wallet.EstimateFeeRate call.
2024-07-18 13:38:57 -03:00
Boris Nagaev
5dac7ca75b
sweep: fix godoc of GetSweepFeeDetails 2024-07-18 13:38:57 -03:00
Boris Nagaev
f5e97c035d
sweepbatcher: log batcher failures
This is useful to debug. It used to fail silently.
2024-07-18 13:38:57 -03:00
Boris Nagaev
db5e0d1d27
sweepbatcher: fix inaccuracies in fee estimations
Use SigHashDefault instead of SigHashAll in weight estimations.
Actual code uses SigHashDefault, not SigHashAll. SigHashAll is 1wu larger.

Use the actual destination address in weight estimator, not taproot always.
In the test the type of address is P2WPKH, not taproot.

Updated testSweepFetcher to calculate fee, fee rate and weight accurately and
to compare the data observed in the published transaction with the estimates.
2024-07-18 13:38:57 -03:00
Boris Nagaev
44d9147175
sweepbatcher: add greedy batch selection algorithm
If custom fee rates are used, the algorithm is tried. It selects a batch for the
sweep using the greedy algorithm, which minimizes costs, and adds the sweep to
the batch. If it fails, old algorithm is used, trying to add to any batch, or
starting a new batch.
2024-07-18 13:38:57 -03:00
Boris Nagaev
019d3c613f
sweep: factor out function AddOutputEstimate
It adds output to transaction weight estimator depending on address type.
2024-07-18 13:38:57 -03:00
Boris Nagaev
e8141578ac
sweepbatcher: MinFeeRate -> WithCustomFeeRate
The reason is because we want to know in advance if fee rates come from
an external source or are determined by sweepbatcher internally.

Also remove WithNoBumping option. It is now a part of WithCustomFeeRate:
if WithCustomFeeRate is passed, automatic fee bumping by sweepbatcher
is disabled.
2024-07-18 13:38:57 -03:00
Boris Nagaev
ccd1b312ca
sweepbatcher: fix copy-paste with batch kit 2024-07-18 13:38:57 -03:00
Boris Nagaev
1f1a27447c
sweepbatcher: fix copy-paste with batchConfig 2024-07-18 13:38:57 -03:00
Boris Nagaev
1290ebe535
sweepbatcher: fix copy-paste in sweep creation 2024-07-18 13:38:57 -03:00
Slyghtning
e8384be227
Merge pull request #793 from hieblmi/instantout-fixes
instantout: assign chaincfg in sql store
2024-07-16 20:26:01 +02:00
Slyghtning
9af205de09
instantout: assign chaincfg in sql store 2024-07-16 19:41:51 +02:00
Slyghtning
424ed2c000
Merge pull request #792 from longxiangqiao/master
chore: fix some comments for struct field
2024-07-14 20:22:49 +02:00
longxiangqiao
273422eef7 chore: fix some comments for struct field
Signed-off-by: longxiangqiao <longxiangqiao@qq.com>
2024-07-13 13:50:12 +08:00
András Bánki-Horváth
b48059482d
Merge pull request #790 from lightninglabs/alexbosworth-patch-4 2024-07-11 23:18:02 +02:00
Alex Bosworth
3f9b61fa55
version: bump version to v0.28.6-beta 2024-07-11 13:20:46 -07:00
András Bánki-Horváth
e75ebaee86
Merge pull request #789 from bhandras/sweep-batcher-db-parent-batch-fixup
sweepbatcher: fix spawning condition "unattached" spend notifiers
2024-07-11 15:24:34 +02:00
Andras Banki-Horvath
6a4ef3683a
sweepbatcher: fix spawning condition "unattached" spend notifiers
Previously, when handling a sweep we assumed that if a sweep status
was completed, the parent batch was also finished. However, since the
batch confirmation status depends on three on-chain confirmations, it
is possible that a spend notifier was started for a sweep of an active
batch. The notifier would fetch the parent batch from the database, but
because we incorrectly assumed that  the parent was confirmed (when it
was not), the DB call would fail with a 'no rows returned' error.
This failure would cause the sweep to fail and the sweep batcher to
stop, resulting in a permanent failure state.
2024-07-11 13:15:39 +02:00
Boris Nagaev
2024791e15
Merge pull request #784 from starius/sweepbatcher-custom-musig2
sweepbatcher: add option WithCustomSignMuSig2
2024-06-28 13:33:36 -03:00
Boris Nagaev
c06b6190af
sweepbatcher/test: test tx is signed and published
Also fix the tests that used to fail to sign and broadcast transactions.
2024-06-28 13:13:45 -03:00
Boris Nagaev
909bf5e264
sweepbatcher/testFeeBumping: reuse dummyNotifier 2024-06-28 13:13:45 -03:00
Boris Nagaev
569c35da20
sweepbatcher: enable all logs in tests 2024-06-28 13:13:45 -03:00
Boris Nagaev
aa6d748647
sweepbatcher: add option WithCustomSignMuSig2
It is needed to provide a custom MuSig2 signer.
2024-06-28 13:13:35 -03:00
Boris Nagaev
38e86a1b0f
sweepbatcher: log tx weight in addition to feerate
Also log fee before applying clampBatchFee.

This is useful to debug fee ralated issues.
2024-06-28 10:26:38 -03:00
Boris Nagaev
3d5b7db1f7
sweepbatcher: factor out method musig2sign
It is long and is going to be even longer and hard to keep it inside a loop.
2024-06-28 10:26:13 -03:00
Boris Nagaev
822e4746c1
sweepbatcher: wrap error from MuSig2CreateSession
Make it more clear in the logs, what is the source of the error.
2024-06-26 17:22:01 -03:00
Boris Nagaev
99d3fd520e
Merge pull request #785 from starius/sweepbatcher-feerate
sweepbatcher: add field SweepInfo.MinFeeRate
2024-06-26 17:20:39 -03:00
Boris Nagaev
fd971d4951
sweepbatcher: add field SweepInfo.MinFeeRate
MinFeeRate is minimum fee rate that must be used by a batch of
the sweep. If it is specified, confTarget is ignored.

This is useful for external source of fees.
2024-06-26 14:21:59 -03:00
Boris Nagaev
4e085f11a3
Merge pull request #783 from starius/sweepbatcher-WithNoBumping
sweepbatcher: add option WithNoBumping
2024-06-26 10:32:39 -03:00
Boris Nagaev
1b9e3069a8
sweepbatcher: add option WithNoBumping
It disables fee bumping. It is useful when fee rate is set externally.

Add test for fee bumping, testing both modes.
2024-06-26 10:19:49 -03:00
Boris Nagaev
bff1fd8004
Merge pull request #782 from starius/sweep-GetSweepFeeDetails
sweep: factor out method GetSweepFeeDetails
2024-06-25 11:51:10 -03:00
Boris Nagaev
84ae3667d5
sweep: factor out method GetSweepFeeDetails
It was factored out from GetSweepFee method. It provides fee rate
and weight in addition to absolute fee.
2024-06-21 23:49:06 -03:00
Boris Nagaev
0ec63a61d4
Merge pull request #778 from starius/sweepbatcher-sql-test
sweepbatcher: unit tests with SQL loopdb as well
2024-06-21 23:45:57 -03:00
Boris Nagaev
029d0870b5
sweepbatcher: unit tests with SQL loopdb as well
This is needed to cover the code of SQLStore with tests.

To achieve compatibility with loopdb (SQLite), the following changes were done:

 - DestAddr is filled to avoid crash in SQL layer
 - Preimage is filled to avoid uniqueness checks by the DB
 - the code working with batch IDs was changed to work correctly
   when batch_id starts with 1 instead of 0
 - SQL swap store has to have a swap with swap_hash from sweep
   to satisfy foreign key constraint of the DB
2024-06-21 23:33:11 -03:00
Boris Nagaev
137dd80d39
sweepbatcher: use %w for wrapped errors
Fix errors.Is(err, context.Canceled) check in tests.
2024-06-20 14:14:24 -03:00
Boris Nagaev
a4e01027ea
Merge pull request #781 from starius/sweepbatcher-exectx
loopdb: parameterize ExecTx with subset of methods used by a package
2024-06-20 12:04:36 -03:00
Boris Nagaev
d6aa4fe8a9
loopdb: all BaseDB's methods use receiver name db 2024-06-20 11:58:46 -03:00
Boris Nagaev
4c2d874b8d
loopdb: use passed transaction in ExecTx calls
Some calls used external queries instead of the passed one,
bypassing the transaction.
2024-06-19 10:38:55 -03:00
Boris Nagaev
1947b90842
multi: typed callback in ExecTx
Provide a wrapped store type, exposing ExecTx method with a subset
interface in the callback argument. BaseDB interfaces in instantout,
reservation and sweepbatcher use ExecTx with their subset Querier
instead of whole sqlc.Querier (*sqlc.Queries).

This is needed to make the packages more reusable, so they don't
depend on methods of *sqlc.Queries they don't use.
2024-06-19 10:38:55 -03:00
Boris Nagaev
d341448568
loopdb: fix description of BaseDB.ExecTx 2024-06-19 10:38:55 -03:00
Boris Nagaev
2847e83fcf
multi: separate Querier from BaseDB interfaces
A Querier holds the methods of sqlc.Querier interface relevant for a package.
BaseDB has Querier + ExecTx method.

This change is needed to simplify further rework of ExecTx.
2024-06-19 10:38:55 -03:00