Commit graph

2228 commits

Author SHA1 Message Date
Slyghtning
79120cc4bc
cmd: open channel command 2026-02-26 21:16:49 +01: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
Boris Nagaev
59140265ca
loopd: implement SweepHtlc RPC 2026-01-29 17:40:58 -05:00
Boris Nagaev
0b53296aa8
multi: factor out sweep fee clamping function 2026-01-15 03:06:22 -05:00
Boris Nagaev
9ee7a36f37
looprpc: add new method SweepHtlc 2026-01-15 03:06:22 -05:00
Slyghtning
1f1f668c5c
Merge pull request #1063 from starius/instantout-fix-log
reservation: fix log line
2026-01-07 13:27:41 +01:00
Boris Nagaev
edbef4987a
reservation: fix log line
Previously the log was corrupted:
confirmed in tx: &{2 [0xc000e802a0] [0xc00087fb80 0xc00087fba0] 205}
2025-12-21 12:53:40 -03:00
Slyghtning
1bdaff887c
Merge pull request #1058 from hieblmi/minor-fixes
multi: fix `staticcheck` flags
2025-12-20 06:49:08 +01:00
Boris Nagaev
d1c4a7da8a
loopd: test error reporting logic 2025-12-20 06:31:02 +01:00
Boris Nagaev
360af61005
loopdb: test error handling for bbolt.Open 2025-12-19 14:17:16 -03:00
Slyghtning
417e25463d
sweepbatcher: fix style issues in sweep_batcher_test.go
- Rename testPublishError to errTestPublish (ST1012)
- Add explicit type to all constants in const groups (SA9004)
- Fixes staticcheck style warnings
2025-12-19 10:18:09 +01:00
Slyghtning
76df55b240
loop: fix error return order in loopin_test.go
- Change return signature of startNewLoopIn from (*swapConfig, error, *loopInSwap) to (*swapConfig, *loopInSwap, error)
- Fixes ST1008: error should be returned as the last argument
2025-12-19 10:18:09 +01:00
Slyghtning
f4e7e676d4
loopd: fix errors.Is argument order 2025-12-19 10:18:09 +01:00
Slyghtning
5ec5875dd7
cmd: replace grpc.DialContext with grpc.NewClient 2025-12-19 10:18:08 +01:00
Slyghtning
175b7d601b
loooprpc: replace deprecated grpc.Dial with grpc.NewClient
- Update assets/client.go to use grpc.NewClient
- Update swap_server_client.go to use grpc.NewClient
- Replace grpc.WithInsecure() with insecure.NewCredentials()
2025-12-19 10:03:14 +01:00
Slyghtning
a3db145ced
loop: delete unused file uncharge_state.go 2025-12-18 08:55:27 +01:00
Slyghtning
34415750fb
Merge pull request #1059 from hieblmi/reregister
staticaddr: re-register on htlc tx conf error
2025-12-18 08:54:20 +01:00
Boris Nagaev
258d33cce5
staticaddr: clear stale HTLC confs on re-register
- reset htlcConfirmed when the HTLC conf subscription errors and we re-register
- add regression test ensuring re-registers after a conf error require a fresh
  confirmation instead of sweeping on a stale one
2025-12-17 10:11:30 +01:00
Boris Nagaev
f6ac0b5ebe
staticaddr: surface invoice subscription errors
- propagate invoice subscription errors in MonitorInvoiceAndHtlcTx via
  HandleError instead of silently logging
- add regression tests covering HTLC conf re-registration and invoice
  subscription error propagation
2025-12-17 10:10:31 +01:00
Boris Nagaev
f274c689b1
staticaddr: add unit test for HTLC re-registration 2025-12-17 09:21:51 +01:00
Slyghtning
1dd145bc32
staticaddr: re-register on htlc tx conf error 2025-12-17 09:21:51 +01:00
Slyghtning
2ed9e5bde6
Merge pull request #1061 from ViktorT-11/2025-12-replace-litd-swapserverrpc-dep
workflow: replace `swapserverrpc` in `lit-setup`
2025-12-17 08:42:29 +01:00
Viktor Torstensson
a0850f7e35
workflow: replace swapserverrpc in lit-setup
In order for the LiT CI jobs to use the `swapserverrpc` protos that
exist on the latest `master` version of the `loop` repo, we need to
update the `lit-setup` action to replace the litd `swapserverrpc`
dependency with the latest version that exists in the `loop` repo.
2025-12-16 16:47:57 +01:00
Slyghtning
c3f3199625
Merge pull request #1043 from hieblmi/withdraw-psbt
staticaddr: psbt withdrawals
2025-12-09 13:30:15 +01:00
Slyghtning
780584993b
staticaddr: unit test CalculateWithdrawalTxValues 2025-12-09 12:21:51 +01:00
Slyghtning
880694c8df
staticaddr: harden and test signMusig2Tx 2025-12-09 12:21:51 +01:00
Slyghtning
078399da80
staticaddr: replace ServerWithdrawDeposits rpc /w ServerPsbtWithdrawDeposits 2025-12-09 12:21:51 +01:00
Slyghtning
a918842374
staticutil: refactor methods into utils 2025-12-09 12:21:51 +01:00