469 Commits
Author SHA1 Message Date
ziggie 22ac4082a4 chainntfs: zero out pkscript in logging when taproot is enabled 2025-09-16 14:25:42 +02:00
Nishant Bansal 7bc6331402 chainntnfs: notify BlockHeight in Updates event
Enhance the ConfirmationEvent's Updates channel by including the
BlockHeight alongside NumConfsLeft.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
2025-09-11 18:25:49 +05:30
Nishant Bansal aa9c3272e3 chainntnfs: signal reorg notification before required confirmations
In this commit, we send the reorg notification even when the
transaction has not yet reached the required confirmations, in
case the caller is interested in knowing about it.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
2025-09-11 18:24:54 +05:30
ffranr 5cea874709 chainntnfs: export NotifierOptions and internal field for interface use
Export NotifierOptions and its internal field to enable external
satisfaction of the protofsm.DaemonAdapters interface.
2025-07-02 16:32:46 +01:00
yyforyongyu 881e044fe3 chainntnfs: use spent height as height hint if found
Previously when deciding whether a UTXO is spent or not, we accept a
height hint as the starting block to look for the spending tx in the
rescan process. When it's already found spent before the rescan starts,
we will update the height hint to be the spent height, only if the
latter is greater. This means if the user-specified hint is greater than
the actual spending height, this UTXO will never be found as spent. We
now fix it by always using the spent height as the hint.
2025-06-12 08:30:55 +08:00
yyforyongyu 6fb81b2250 chainntnfs: patch debug logs and fix StartHeight
Make sure we patch the `StartHeight` for btcd notifier.
2025-06-12 08:30:54 +08:00
ziggie cadc8d0fba btcdnotify: change order of rpc calls.
We have to make sure we register the block notifier before we
fetch the best block for block notifications.
2025-04-17 09:51:44 +02:00
ziggie 8dde8cfc59 chainntnfs: increase logging of the subsystems 2025-04-15 15:20:22 +02:00
yyforyongyu 4bfcfea2ee lntest+chainntnfs: make sure bitcoind node is synced
This commit makes sure the bitcoind node is synced to the miner when
initialized and returned from `NewBitcoindBackend`.
2025-02-26 19:51:52 +08:00
yyforyongyu 99d49dec6a multi: change NewBitcoindBackend to take a miner as its param
Prepares for the following commit where we assert the chain backend is
synced to the miner.
2025-02-26 19:51:52 +08:00
yyforyongyu 1618d2c789 chainntnfs+lntest: fix sync to miner block flake
In this commit we document an unexpected behavior found when connecting
a bitcoind node to a btcd node. We mitigate this in our test by
reconnecting the nodes when the connection is broken. We also limit the
connection made from `bitcoind` to be v1 only.
2025-02-26 19:51:52 +08:00
yyforyongyu 121116cff7 sweep: remove dead code and add better logging 2025-02-20 14:40:52 +08:00
Oliver Gugger 1b0f41da48 Merge pull request #9378 from yyforyongyu/fix-unit-test
chainntnfs: fix test `testSingleConfirmationNotification`
2025-01-13 03:13:02 -06:00
chloefeal 852a8d8746 chore: fix typo 2025-01-05 20:45:35 +08:00
yyforyongyu bafe5d009f chainntnfs: fix test testSingleConfirmationNotification 2024-12-20 22:08:32 +08:00
yyforyongyu cc60d2b41c chainntnfs: skip dispatched conf details
We need to check `dispatched` before sending conf details, otherwise the
channel `ntfn.Event.Confirmed` will be blocking, which is the leftover
from #9275.
2024-12-20 17:54:08 +08:00
yyforyongyu f03e242515 chainntnfs: ensure previous test succeeded before running 2024-12-10 19:56:01 +08:00
Keagan McClelland ed2989ae33 multi: update to fn v2 2024-12-04 13:19:00 -07:00
Elle Mouton ab7aae0708 multi: rename nolint:lll to nolint:ll
Find and replace all nolint instances refering to the `lll` linter and
replace with `ll` which is the name of our custom version of the `lll`
linter which can be used to ignore log lines during linting.

The next commit will do the configuration of the custom linter and
disable the default one.
2024-12-02 09:14:21 +02:00
Elle Mouton 439a6c7d6c multi: rename chan DB Open method to OpenForTesting 2024-11-28 13:51:15 +02:00
yyforyongyu db6901c9f3 chainntnfs: skip duplicate numConfsLeft notifications
This commit adds a new state to the `ConfNtfn` struct to start tracking
the number of confs left to be notified to avoid sending duplicate
notifications.
2024-11-19 16:27:26 +08:00
yyforyongyu 7695880c13 chainntnfs: add new method notifyNumConfsLeft
So it's easier to handle the following commit where we start skipping
duplicate notifications.
2024-11-19 16:02:19 +08:00
yyforyongyu 4ff1f19fbf chainntnfs: make sure notification is sent to the whole set
This commit fixes a bug where the confirmation details may be missed.
When the same tx is subscribed via `RegisterConfirmationsNtfn`, we will
put them into the same set and notify the whole set. However, this logic
is missing when performing the rescan - once the confirmation detail is
found, we only notify the current subscriber. Later we will skip
notifying other subscribers in `UpdateConfDetails` due to the
`confSet.details != nil` check. We now fix it by immediately notify all
the subscribers when the confirmation detail is found during the rescan.
2024-11-19 15:56:08 +08:00
yyforyongyu 1200b75546 chainntnfs: always notify txns before block
This commit changes the order of notifications when a relevant tx is
found in a block and now we will always notify the tx subscribers before
notifying the block, which has implications in the upcoming blockbeat.

When a block notification is subscribed via `RegisterBlockEpochNtfn` and
a confirm or spend is subscribed via `RegisterConfirmationsNtfn` or
`RegisterSpendNtfn`, we would always notify the block first before the
tx, causing the subsystem to think there's no relevant txns found in
this block, while the notifications are sent later. We now fix it by
always sending the txns notifications first, so the subsystem can
receive the txns, process them, then attempt to advance its state based
on the block received.
2024-11-19 15:55:22 +08:00
yyforyongyu 523ecc0653 multi: wait for rpcclients shutdown to complete
We need to call `WaitForShutdown` after stopping the rpc clients of the
chain backends.
2024-11-14 01:22:31 +08:00
yyforyongyu 611405f59c chainntnfs/btcdnotify: remove redundant config params re-assignment 2024-10-30 02:01:14 +08:00
Elle Mouton 23602e017e multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
ziggie 02c1264c53 multi: prevent nil panics in stop methods.
With this PR we might call the stop method even when the start
method of a subsystem did not successfully finish therefore we
need to make sure we guard the stop methods for potential panics
if some variables are not initialized in the contructors of the
subsystems.
2024-07-31 14:43:34 +02:00
yyforyongyu 48a0efe40c bitcoindnotify: add debug logs in unit test 2024-07-24 18:05:06 +08:00
yyforyongyu 9fee656d70 chainntnfs+lntest: fix TestInterfaces
This commit upgrades the test to always use a segwit v0 witness program
when creating testing txns.
2024-07-24 17:43:27 +08:00
Oliver Gugger f2759dcb1a Merge pull request #8759 from largemouth/master
chore: fix some function names
2024-07-10 12:16:49 -06:00
yyforyongyu 6de1b026dd chainntnfs: add verbose logging in unit test 2024-06-13 17:54:34 +08:00
yyforyongyu 347537791e sweep: improve loggings based on feedback
This commit changes the logging levels and add a few more loggings based
on the testing results from the testnet/mainnet.
2024-05-21 00:53:24 +08:00
largemouth a1f36e48d3 chore: fix some function names
Signed-off-by: largemouth <largemouth@aliyun.com>
2024-05-15 11:41:23 +08:00
yyforyongyu 11f7e455d1 lnwallet+sweep: introduce TxPublisher to handle fee bump
This commit adds `TxPublisher` which implements `Bumper` interface. This
is part one of the implementation that focuses on implementing the
`Broadcast` method which guarantees a tx can be published with
RBF-compliant. It does so by leveraging the `testmempoolaccept` API,
keep increasing the fee rate until an RBF-compliant tx is made and
broadcasts it.

This tx will then be monitored by the `TxPublisher` and in the following
commit, the monitoring process will be added.
2024-04-19 21:33:29 +08:00
yyforyongyu 5fce91caf9 chainntnfs+sweep: add LookupInputMempoolSpend and use it in the
sweeper

This commit implements a new method, `LookupInputMempoolSpend` to do
lookups in the mempool. This method is useful in the case when we only
want to know whether an input is already been spent in the mempool by
the time we call.
2024-04-19 21:33:24 +08:00
yyforyongyu ebef3679ac btcdnotify: use chain.NewRPCClientWithConfig to init RPC client
So we can use the methods implemented on the chain RPC client.
2024-04-19 21:33:24 +08:00
yyforyongyu 47478718d4 multi: query mempool spend when a new input is received
This commit changes how a new input sweep request is handled - now we
will query the mempool and see if it's already been spent. If so, we'll
update its state as we may need to RBF this input.
2024-04-19 21:33:22 +08:00
Oliver Gugger 648fb22f63 multi: wrap all errors 2024-04-11 15:04:03 +02:00
yyforyongyu bf799719b5 chainntnfs: fix race in TestInterfaces 2024-03-26 12:59:02 +08:00
Oliver Gugger 17b93db5cc chainntnfs: fix race unit test issue
Because we pass in the same config into multiple notifiers, we sometimes
get a data race in the unit tests. By creating a copy of the config we
avoid that.
2024-03-18 17:08:17 +01:00
Oliver Gugger d40312c36b multi: move unit test backend funcs to new package
To avoid circular dependency issues between packages, we move the unit
test backend creation function to a new package in the lntest parent
package.
2024-03-18 16:13:39 +01:00
Oliver Gugger c170a9830b multi: use chainntnfs.NewMiner for miners in unit tests
With the chainntnfs.NewMiner now being optimized for not creating
nodes with colliding ports, we use it in all unit tests that spin up
temporary miners.
2024-03-18 16:13:39 +01:00
Oliver Gugger 2884389ce4 chainntnfs: fix issues with NewBitcoindBackend
This commit fixes a number of issues with our temporary bitcoind nodes
that we spin up for unit tests:
 - We didn't remove the node's temporary data dir after tests finished.
 - We used random ports which lead to unwanted port collisions.
 - We used ipc:// unix sockets for ZMQ which currently isn't supported
   in bitcoind v26.0 due to a regression. Since we can reliably create
   new non-colliding ports now, we should use TCP for ZMQ anyway.
2024-03-18 16:13:39 +01:00
Oliver Gugger 2cc28baa84 chainntnfs: re-try miner connection more often
Make sure we wait for the initial connection long enough.
2024-03-18 16:13:39 +01:00
Oliver Gugger 11ba14ab02 chainntnfs: add netParams arg to backend funcs 2024-03-18 16:13:39 +01: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
Mohamed Awnallah 99908ed2dc routing: deep copy any transaciton we obtain from GetBlock call. 2024-01-15 11:35:55 +02:00
yyforyongyu ee883c332f chainntnfs: stop lnd when received witness stack is empty
This commit uses `Criticalf` to gracefully stop `lnd` when the received
witness data is empty.
2023-10-31 01:44:43 +08:00
yyforyongyu 28c3c835bf chainntnfs: return an error when witness stack is empty
This commit adds a check when receiving transactions from
`BitcoindClient` so an error is returned when empty witness is found.
2023-10-31 01:44:43 +08:00