Commit graph

2254 commits

Author SHA1 Message Date
Slyghtning
3e526faf82
openchannel: cancel shims with a live context
In manager.go, deferred shim cleanup was calling
FundingStateStep with the original request ctx.
If the user had already canceled that context,
the cleanup RPC would run with a canceled context
and could fail to remove the pending shim. I changed
that cleanup path to use context.WithoutCancel(ctx)
so the cancellation RPC still has a live context.
2026-03-09 14:39:45 +01:00
Slyghtning
0b295123e7
staticaddr: remove dead code across managers
Remove unused errChan fields from the loopin, openchannel, and withdraw
managers. These channels were declared and initialized but never read
from or written to.

Remove the unused activeLoopIns map from the loopin manager. The map
was only written to but never read, making it dead code.

Remove the stale withdraw.Store interface whose method signatures no
longer match the concrete SqlStore API used by the manager.

Remove unused config fields from openchannel.Config (Server,
AddressManager, ChainNotifier, Signer) and deposit.ManagerConfig
(AddressClient, SwapClient, ChainParams) along with their daemon
wiring. Also remove the now-orphaned openchannel.AddressManager
interface.

Remove the unused GetStaticAddress and Close methods from
address.SqlStore and the GetStaticAddress method from the address.Store
interface, as the codebase only uses GetAllStaticAddresses.
2026-03-09 14:39:44 +01:00
Slyghtning
f80aee4dae
staticaddr: avoid startup SendEvent data races 2026-03-09 14:39:44 +01:00
Slyghtning
a9977dd5f4
godoc: address copy-paste errors accross the codebase 2026-03-09 14:39:44 +01:00
Slyghtning
c1036ff705
withdraw: handle confirmation registration failures 2026-03-09 14:39:44 +01:00
Slyghtning
d39e247a74
withdraw: use %v instead of %w in log.Errorf
The %w formatting verb is only meaningful for fmt.Errorf where it
enables error wrapping. In log.Errorf it prints as %%!w(error=...),
producing garbled log output. Use %v and add the missing colon
separator.
2026-03-09 08:37:50 +01:00
Slyghtning
33891ae6ae
withdraw: check error from RegisterSpendNtfn before using channels
handleWithdrawal did not check the error returned by
RegisterSpendNtfn before spawning a goroutine to read from the
notification channels. If registration failed, spentChan would be nil
and the goroutine would block forever on a nil channel read.

Add the missing error check so the function returns early on
registration failure.
2026-03-09 08:37:50 +01:00
Slyghtning
4a6ccd3d29
loopin: fix data race on activeLoopIns map during recovery
recoverLoopIns wrote to the activeLoopIns map from inside a goroutine
without any synchronization. The map is shared state accessed from
the manager's main Run loop, creating a data race.

Move the map write before the goroutine spawn so it happens
synchronously during recovery. Also fix the stale log message that
said "OnStart" instead of "OnRecover".
2026-03-09 08:37:49 +01:00
Slyghtning
aadf6e2daa
loopin: exit htlc timeout sweep retry loop on context cancellation
SweepHtlcTimeoutAction used a select with a default case containing a
blocking time.After. When the context was canceled, it logged the error
but continued the retry loop instead of returning. The default case
also meant that ctx.Done was only checked when it was already signaled,
while an hour-long sleep blocked without listening for cancellation.

Replace the default+time.After pattern with a proper select on both
ctx.Done and time.After so the function exits promptly on shutdown.
2026-03-09 08:37:49 +01:00
Slyghtning
63d8f5560e
loopin: enforce HTLC output index invariant in sweep tx construction
createHtlcTx always places the HTLC output at index 0 and the change
output (if any) at index 1. Previously, createHtlcSweepTx attempted to
dynamically find the HTLC index but then unconditionally read
TxOut[0].Value, ignoring the computed index.

Replace the dynamic search with a const htlcInputIndex=0 and a fail-fast
check that errors if the layout invariant is ever violated. Add a test
that verifies the sweep value is derived from the HTLC output, not the
change output.
2026-03-09 08:37:48 +01:00
Alex Bosworth
3b54b19eeb
Merge pull request #1084 from lightninglabs/alexbosworth-patch-13
version: bump version to v0.32.1-beta
2026-03-02 13:49:55 -08:00
Alex Bosworth
19cf3b3ad8
version: bump version to v0.32.1-beta 2026-03-02 12:54:28 -08:00
Boris Nagaev
b3cbf2c84e
Merge pull request #1083 from starius/up-go-126
release: use Go 1.26.0
2026-03-02 15:53:18 -05:00
Boris Nagaev
d3aae949dc
release: use Go 1.26.0 2026-03-02 15:08:11 -05:00
Alex Bosworth
3f045ba19c
version: bump version to v0.32.0-beta
version: bump version to v0.32.0-beta
2026-03-02 11:38:55 -08:00
Boris Nagaev
bfaacb1a56
Merge pull request #1081 from starius/dep-up
build: otel/sdk 1.38.0 -> 1.40.0
2026-03-02 12:31:16 -05:00
Alex Bosworth
ea4b2381d2
version: bump version to v0.32.0-beta 2026-03-02 07:52:30 -08:00
dependabot[bot]
294f8b6852
build: otel/sdk 1.38.0 -> 1.40.0 2026-03-01 22:52:15 -05:00
Boris Nagaev
e7a9cb0774
Merge pull request #1077 from lightninglabs/dependabot/go_modules/looprpc/github.com/opencontainers/runc-1.2.8
build(deps): bump github.com/opencontainers/runc from 1.1.14 to 1.2.8 in /looprpc
2026-03-01 22:50:00 -05:00
Boris Nagaev
b00c737ec6
Merge pull request #1076 from lightninglabs/dependabot/go_modules/looprpc/github.com/go-viper/mapstructure/v2-2.4.0
build(deps): bump github.com/go-viper/mapstructure/v2 from 2.3.0 to 2.4.0 in /looprpc
2026-03-01 22:49:22 -05:00
Boris Nagaev
36bb8716e7
Merge pull request #1075 from lightninglabs/dependabot/go_modules/looprpc/github.com/sirupsen/logrus-1.9.3
build(deps): bump github.com/sirupsen/logrus from 1.9.2 to 1.9.3 in /looprpc
2026-03-01 22:48:32 -05:00
Slyghtning
802cf873cd
Merge pull request #1040 from hieblmi/static-open-channel
staticaddr: channel funding with deposits
2026-02-26 21:38:59 +01:00
Slyghtning
c7006500e2
docs: update loop.md 2026-02-26 21:22:17 +01:00
Slyghtning
79120cc4bc
cmd: open channel command 2026-02-26 21:16:49 +01:00
dependabot[bot]
4ac0da21d4
build(deps): bump github.com/opencontainers/runc in /looprpc
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.1.14 to 1.2.8.
- [Release notes](https://github.com/opencontainers/runc/releases)
- [Changelog](https://github.com/opencontainers/runc/blob/main/CHANGELOG.md)
- [Commits](https://github.com/opencontainers/runc/compare/v1.1.14...v1.2.8)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runc
  dependency-version: 1.2.8
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-26 19:59:21 +00:00
dependabot[bot]
420eccfa2d
build(deps): bump github.com/go-viper/mapstructure/v2 in /looprpc
Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.3.0 to 2.4.0.
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.3.0...v2.4.0)

---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
  dependency-version: 2.4.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-26 19:59:04 +00:00
dependabot[bot]
b5489710b9
build(deps): bump github.com/sirupsen/logrus in /looprpc
Bumps [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) from 1.9.2 to 1.9.3.
- [Release notes](https://github.com/sirupsen/logrus/releases)
- [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sirupsen/logrus/compare/v1.9.2...v1.9.3)

---
updated-dependencies:
- dependency-name: github.com/sirupsen/logrus
  dependency-version: 1.9.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-26 19:59:02 +00:00
Slyghtning
6cb54edf06
openchannel: optimize open channel request creation and err handling 2026-02-26 20:57:28 +01:00
Slyghtning
cd377f35f8
openchannel: recover deposits at runtime after PSBT finalize failure
If the PSBT finalize step succeeds but the stream fails before
ChanPending, deposits would remain stuck in OpeningChannel until the
next daemon restart. Run the recovery logic immediately so deposits are
resolved without requiring a restart.

Also, add tests for the following edge cases requested in review:

- Reorg: channel tx reorged, UTXOs reappear as unspent, deposits
  return to Deposited state.
- Daemon restart during channel opening: deposits in OpeningChannel
  recovered based on UTXO status (spent → ChannelPublished, unspent →
  Deposited).
- Mempool eviction: tx evicted, UTXOs unspent, deposits return to
  Deposited.
- Mempool rejection: tx never accepted, same recovery as eviction.
- Stream errors: lnd stream fails before PSBT finalize, error returned
  without errPsbtFinalized so deposits can be safely rolled back.
- PSBT finalize then stream abort: finalize succeeds but stream dies
  before ChanPending, error wrapped with errPsbtFinalized so caller
  triggers recovery instead of blind rollback.
- Duplicate outpoints: already covered by TestOpenChannelDuplicateOutpoints.
2026-02-26 20:57:27 +01:00
Slyghtning
e710ea5e8f
openchannel: reject duplicate outpoints in open channel request
Duplicate outpoints in the request lead to fee miscalculation and an
invalid PSBT with the same input listed twice. Validate early and return
a clear error message.
2026-02-26 20:57:27 +01:00
Slyghtning
dbac12ed78
deposit: add OnExpiry self-transitions to OpeningChannel and ChannelPublished
Both OpeningChannel and ChannelPublished lacked OnExpiry transitions.
handleBlockNotification fires OnExpiry on every new block once the
deposit is expired, regardless of the current state. Since both states
use NoOpAction or FinalizeDepositAction which release the FSM mutex
briefly, an OnExpiry SendEvent can sneak in. Add self-transitions so
the event is safely absorbed.
2026-02-26 20:57:27 +01:00
Slyghtning
52d884cec1
openchannel: return error on hash creation failure
Return an error instead of just logging when chainhash.NewHash fails in
the ChanPending handler. The hash variable would be nil and crash on the
subsequent String() call.
2026-02-26 20:57:27 +01:00
Slyghtning
eaf7883bcf
openchannel: fix shimPending data race
Protect the shimPending variable with a sync.Mutex since it is accessed
from multiple goroutines: the main loop goroutine and the server error
handling goroutine. Without synchronization this is a data race.
2026-02-26 20:57:27 +01:00
Slyghtning
d2d8e71ea0
notifications: fix test race 2026-02-26 20:57:27 +01:00
Slyghtning
b74dab8af4
loopd: instantiate static address open channel manager 2026-02-26 20:57:27 +01:00
Slyghtning
63097ee220
staticaddr: close quit channel only once 2026-02-26 20:57:26 +01:00
Slyghtning
dfc75f2e1a
staticaddr: open channel manager 2026-02-26 20:57:26 +01:00
Slyghtning
d12663ea7c
staticaddr: channel open states for deposit and fsm 2026-02-26 20:57:26 +01:00
Slyghtning
81012de948
staticaddr: replace block-based deposit detection with polling
Block-based deposit fetching from the internal lnd wallet was
susceptible to wallet syncing issues. Replace it with interval-based
polling. Reconciliation errors are now logged instead of being fatal,
improving resilience during transient failures.
2026-02-26 20:57:26 +01:00
Slyghtning
f1c138abf5
deposit: remove dead code in reconcileDeposits
Remove unreachable error check after filterNewDeposits which does not
return an error. The err variable was already handled from the
ListUnspent call above and could never be non-nil at this point.
2026-02-26 20:57:26 +01:00
Slyghtning
9800ee3891
go.mod: go mod tidy 2026-02-26 20:57:26 +01:00
Slyghtning
95f7a83653
Merge pull request #1073 from hieblmi/looprpc-static-open
looprpc: preparatory commits for static open channel
2026-02-26 20:56:53 +01:00
Slyghtning
d4c9ab0630
looprpc: add StaticOpenChannel permissions and fix StaticAddressLoopIn
Add macaroon permissions for the new StaticOpenChannel RPC method
and change StaticAddressLoopIn action from read to execute to match
other swap operations.
2026-02-26 09:37:26 +01:00
Slyghtning
6e4569f916
notifications: fix test race 2026-02-26 09:37:26 +01:00
Slyghtning
f47b611557
looprpc: extend client.proto with lnrpc.OutPoint and lnrpc.OpenChannelRequest
In this commit we import the lnd's lightning.proto into client.proto to
then be able to use lnrpc.OutPoint and lnrpc.OpenChannelRequest instead
of the looprpc.OutPoint type.
This is safe because the lnrpc and looprpc versions of OutPoint are the
same type.
2026-02-26 09:37:26 +01:00
Slyghtning
6aaacf8b93
looprpc: prepare for lnrpc usage
In successive commits we want to access lnrpc specifc methods
and objects, so here we import github.com/lightningnetwork/lnd v0.20.1-beta
into looprpc and update relevant versions.
2026-02-26 09:35:59 +01:00
George Tsagkarelis
6a2a863bed
Merge pull request #1071 from lightninglabs/alexbosworth-patch-12
version: bump version to v0.31.8-beta
2026-02-03 19:49:45 +01:00
Alex Bosworth
d2699ee7cc
version: bump version to v0.31.8-beta
bump version to v0.31.7-beta
2026-02-03 10:00:53 -08:00
Boris Nagaev
9590fafae8
Merge pull request #1066 from starius/sweephtlc5
Add a command to manually sweep loop-out HTLC
2026-02-03 12:38:25 -05:00
Boris Nagaev
579ea31979
cmd/loop: add command "loop out sweephtlc"
The command is hidden, it is not for everyday use.
2026-01-29 17:40:58 -05:00