The mock event consumer waited a fixed 10ms before returning consumed
events, which was not always enough on slow CI runners and caused flaky
failures (e.g. TestMarkSettled_App_BudgetWarning missing its
nwc_budget_warning event). It also appended to the events slice from
concurrent goroutines without synchronization, a data race that could
drop events.
- guard the consumed events slice with a mutex and return copies
- add WaitForConsumedEvents which polls until the expected number of
events arrived (up to 5s) instead of relying on a fixed sleep
- use it in tests that assert on consumed events; tests asserting that
no event was published keep the short grace period
- normalize event order in the keysend self-payment test, matching the
existing approach in the self-payment test, since async publishing
does not guarantee ordering
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* fix: publish transaction events only after the database transaction commits
markTransactionSettled and markPaymentFailed published nwc_payment_sent /
nwc_payment_received / nwc_payment_failed (and checkBudgetUsage published
nwc_budget_warning) while still inside the caller's database transaction, so
connected apps and the Alby API could be notified of a payment whose row was
never committed, and subscribers reading the database in response to an event
could race with the commit.
Every function that writes transaction state now owns its own database
transaction and publishes its events only after the commit succeeds:
- markTransactionSettled and markPaymentFailed open their own transaction;
callers no longer wrap them in db.Transaction
- new createSettledTransactionFromNotification inserts transactions reported
by LNClient notifications for payments the hub has no record of (external
payments, received keysends) directly in their settled state, removing the
transient PENDING row and the zombie row left behind on duplicate events
- markPaymentFailed now refuses to mark a settled transaction as failed,
replacing CancelHoldInvoice's in-transaction ACCEPTED re-check and also
protecting the SendPaymentSync error path from a racing settle
- checkBudgetUsage returns the budget warning event instead of publishing it
Closes#2506
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: serialize payment failure with settlement and propagate lock errors
Address review findings on the previous commit:
- markPaymentFailed now takes the same payment-hash row lock as settlement
(postgres), so the settled-state guard cannot be bypassed by a concurrent
settle between the state check and the update; it also returns not-found
instead of publishing an event when the transaction row no longer exists,
and reports whether this call transitioned the row so CancelHoldInvoice
only publishes nwc_hold_invoice_canceled when it performed the cancellation
- findSettledTransaction propagates errors from the lock query and the
settled-transaction lookup instead of treating a failed lookup as
"no settled transaction exists", which could defeat the dedup guard
- TestMarkSettled_Twice no longer shares one transaction struct between
concurrent goroutines and collects errors instead of asserting inside them
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: mark failed keysend payments via markPaymentFailed
The SendKeysend failure path updated the transaction directly, which never
zeroed the fee reserve, recorded no failure reason, published no
nwc_payment_failed event, and had no guard against overwriting a
concurrently settled payment. Route it through markPaymentFailed like
SendPaymentSync, and allow MockLn keysends to fail so the path is testable.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feat: filter transactions
* fix: harden transaction filters
* refactor: use explicit nullable transaction filters with HideFailed polarity
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat: set transaction filters in a dialog from wallet actions menu
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat: filter transactions by search term and type
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: reject invalid transaction filters and reset page synchronously
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: parse complete minimum amount value in transactions filter dialog
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feat: just in time channels with lsps2
* fix: clarify JIT receive channel fee
* fix: fees
* fix: fees 2
* fix: don't show low inbound when LSPS2 is active
* fix: remove the receive limit below the input if LSPS2 is being used
* fix: simplify
* fix: bring back fee % for outgoing
* fix: remove unneeded changes
* fix: typo
* fix: unneeded
* fix: don't show open first channel is LSPS2
* feat: clearer JIT channel fee copy on receive screen
* fix: add LSPS2 var info
* fix: don't duplicate JIT fee hint on create invoice form
* fix: make paymentDone a standard boolean
* fix: update to golang:1.26 in Dockerfile
* feat: read LSPS2 sources from channel suggestions, set minimum receive amount, update guide link
* docs: update LDK_LSPS2_ADDRESSES to be used as an override
* fix: only show minimum jit receive amount on validation error
* fix: add more detail to receive error when receiving low amounts with jit
* fix: do not use JIT when user has public channels
* feat: add option to disable JIT
* fix: isTrusted check, add jit property to event
* fix: do not require node restart for toggling JIT
* chore: simplify JIT alert
* chore: add guide link on node settings JIT description
* feat: fetch the lsp2info to have access to params like minimum/maximum payment size
* refactor: share single learn-more link across JIT fee hint branches
* fix: remove variable amount invoice support
* fix: use lsps2info for min payment size and remove channelPeerSuggestion usage of minimumChannelSize
* fix: only do amount validation according to lsps2Info values if jit is enabled in settings
* feat: add jit first payment fee alert on receive via lightning address
* fix: remove unnecessary conditional
* fix: ensure at least one sat is left over when opening JIT channel
* chore: remove hardcoded suggestions
* chore: rename JIT enabled config variable
* fix: ui checks when JIT is disabled
* fix: amount input validation message
* fix: formatting
---------
Co-authored-by: anon <anon@anon.com>
Co-authored-by: saunter <68239231+stackingsaunter@users.noreply.github.com>
Co-authored-by: fmar <fmar@fmar>
Co-authored-by: René Aaron <rene@twentyuno.net>
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
* feat: user labels poc
* feat: backend for transaction user labels
Add PATCH /api/transactions/:paymentHash/label that merges a
user-supplied {key:value} map into the existing transaction metadata
under the user_label key, preserving NIP-47 fields. Empty map clears
the labels. Trims whitespace, drops blank rows, caps key/value length.
Wire the frontend editor to call the endpoint and revalidate the
transactions SWR cache on success.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: include user labels as columns in CSV export
Collect the union of user_label keys across all exported transactions
and emit each one as its own label_<key> column. The existing metadata
JSON column is preserved so importers like Raccoin keep working.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: drop hardcoded label suggestions, autocomplete from prior keys
Open the editor with a single blank row instead of four pre-seeded
fields. Suggest label keys via a datalist populated from any
user_label keys already present in the SWR transactions cache, so
suggestions reflect the user's own taxonomy.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: inline label editor and indicator-only list row
Replace the nested label dialog with an inline editor that toggles
within the existing transaction detail dialog, removing dialog
stacking. In the transactions list, replace per-label badges with a
single tag icon next to the timestamp so row height stays uniform; the
full labels remain visible in the detail view.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: don't bump updated_at on metadata-only edits
GORM's Update auto-touches updated_at, which made the transactions
list reorder labeled transactions to the top. Switch
SetTransactionMetadata to UpdateColumn so only the metadata column
changes. Add regression test.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: route PATCH transaction label requests in wails
The desktop app routes API calls through WailsRequestRouter rather
than HTTP. Add a handler for PATCH /api/transactions/:hash/label
before the existing transaction lookup so labels work in Wails too.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: finalize backend
* chore: rename to labels
* chore: finalize frontend
* chore: use tx id to add user labels
* chore: address minor nits
* fix: linting
* fix: use explicit primary key lookups
* chore: simplify transaction csv label export
* fix(frontend): drop label count from transaction list badge
The count adds visual weight without informing any decision from the
list view. The icon-as-badge already signals labels exist; the actual
values are in the details dialog.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(frontend): revert transaction list label indicator to bare icon
The Badge wrapper made the icon-only indicator wider than tall, which
looked off. Restores the pre-PR look — a small TagIcon next to the
timestamp — since the in-dialog editor is the place to see actual labels.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
* feat: add both Sat and Msat companion fields for all ambiguous balance/amount properties
* feat: add sat and msat companion fields to backend API responses
* chore: align frontend types and other missing fields
* chore: keep old formula for calculating total fee sat
* chore: remove unnecessary balance assignments in cashu and phoenix
* chore: add deprecated comment to non unit fields
* chore: rename callers and variable to specify units
* chore: remove msat fields for channel size and liquidity fields
* chore: drop msat fields from onchain channel size and liquidity responses
* chore: further changes
* chore: remove amount msat field onchain tx
* chore: remove msats from onchain balance response
* chore: remove msat fields for swaps
* chore: remove msat fields for punishment reserves
* chore: simplify rebalancing fee calculation
* chore: remove unnecessary fields
* chore: mark deprecated fields in frontend types
---------
Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
* feat: track last settled transaction time for apps
* fix: use default subwallet ordering and app_id logging in event handler
* chore: rename to last_settled_transaction_at and remove last tx migration
* chore: split app settlement update and budget check
* chore: extract app display name helper into utils function
* fix: intercept self hold payments based on invoice rather than payment hash
* fix: generate test invoices with long expiry
* fix: add timeout seconds for standard lnd payments
* feat: allow self-paying invoices generated externally from LND
* chore: update self payment detection test to check for outgoing payment with same hash
---------
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
* chore: move out swaps from settings
* chore: link to swaps in wallet and node page
* chore: add frontend for swap ins
* chore: update all swap redirects
* chore: remove swap dialogs
* chore: remove auto swap-ins frontend
* feat: add support for one time swap outs
* chore: remove unused code
* chore: use separate endpoint for one off swap outs
* chore: further changes
* chore: separate one off and auto swaps
* chore: naming changes
* fix: tests
* feat: add one off swap in
* feat: add auto swap ins
* chore: remove comments
* fix: tests
* chore: further changes
* chore: further changes
* chore: rename to swap in and swap out
* chore: do not show swaps for non LDK/LND users
* chore: add receive limit checks for swap ins
* chore: remove probing
* chore: dark mode
* fix: swap link
* chore: add extra swap links
* fix: fee rates log
* fix: fee rates log
* chore: color changes
* Feat: swap out improvements (#1403)
* feat: swap out improvements
- add lockup transaction id to hold payment metadata
- return swap ID and payment hash in swap out response
- retries to get fee rates
- separate swap out success page with status
* chore: rename
* chore: show current balance on swap out form
* chore: add pulse animation to badge while pending
* chore: minor typo
* chore: update fee rate retry interval to 10 seconds
* chore: use icons instead of badges
---------
Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
* chore: update comment
* chore: remove comment
* chore: update boltz client to v2.6.1
* feat: swap in improvements (WIP) (#1411)
* feat: swap in improvements (WIP)
* feat: new swap in status page
* fix: hide pay button when already paid
* chore: improve swap in UI
* chore: more swap in ui improvements
* chore: minor improvements and fixes
* fix: typo
* feat: add swap in refund logic in case of failure
* fix: tests
* chore: add swap expired case for refunds
---------
Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
* feat: add swaps table (#1419)
* feat: add swaps table
* fix: test
* chore: bump LDK-node to v0.6.0 (#1418)
* [Freepilot] fix: startup error handling (#1413)
* fix: handle errors from service.NewService() in startup code
Previously, both HTTP and Wails startup code ignored errors from
service.NewService(ctx) using blank identifier (_), which could
cause panics later if NewService fails (e.g., unable to connect
to postgres database).
Now properly handle the error and exit gracefully with a fatal
log message when service initialization fails.
* fix: compile error
---------
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
* feat: add hd key derivation
* Chore: add albyhub region cookie to developer page (#1421)
* docs: add AlbyHub-Region cookie instructions to developer page
* fix: use region from alby api
---------
Co-authored-by: achaldps@gmail.com <achaldps@gmail.com>
* build(deps): bump golang.org/x/crypto from 0.38.0 to 0.39.0 (#1415)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.38.0 to 0.39.0.
- [Commits](https://github.com/golang/crypto/compare/v0.38.0...v0.39.0)
---
updated-dependencies:
- dependency-name: golang.org/x/crypto
dependency-version: 0.39.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump gorm.io/driver/sqlite from 1.5.7 to 1.6.0 (#1416)
Bumps [gorm.io/driver/sqlite](https://github.com/go-gorm/sqlite) from 1.5.7 to 1.6.0.
- [Commits](https://github.com/go-gorm/sqlite/compare/v1.5.7...v1.6.0)
---
updated-dependencies:
- dependency-name: gorm.io/driver/sqlite
dependency-version: 1.6.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump github.com/btcsuite/btcd/btcec/v2 from 2.3.4 to 2.3.5 (#1417)
Bumps [github.com/btcsuite/btcd/btcec/v2](https://github.com/btcsuite/btcd) from 2.3.4 to 2.3.5.
- [Release notes](https://github.com/btcsuite/btcd/releases)
- [Changelog](https://github.com/btcsuite/btcd/blob/master/CHANGES)
- [Commits](https://github.com/btcsuite/btcd/compare/btcec/v2.3.4...btcec/v2.3.5)
---
updated-dependencies:
- dependency-name: github.com/btcsuite/btcd/btcec/v2
dependency-version: 2.3.5
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat: allow setting LDK node alias (#1398)
* feat: add node alias customization for LDK nodes with public channels
- Add new NodeAlias field to InfoResponse in API
- Add SetNodeAlias method to API with config storage
- Add HTTP endpoint POST /node/alias for setting node alias
- Add corresponding Wails endpoint support
- Create new Node settings page in frontend
- Add conditional navigation item for LDK nodes with public channels
- Include upgrade dialog and paid subscription check
- Display success message prompting node restart after alias change
- Show error toast for non-paid users attempting to change alias
* chore: use node alias from config in LDK init
* fix: make upgrade button non-absolute, remove disabled attribute
* chore: move node alias page to be consistent with other node management pages
* chore: remove redundant comment
* chore: show upgrade dialog when clicking node alias option, show also for private channels
---------
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
* fix: always pass in fee and handle mempool errors (#1408)
* fix: always pass in fee and handle mempool errors
* chore: improve withdraw on-chain funds UI
---------
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
* feat: derive keys from id and add fields to swap table
* feat: use bip 85 to derive swap mnemonic
* chore: mark swaps as failed if payment fails
* feat: add process refund method for swap ins
* chore: add process refund to swap service interface
* feat: add frontend
* fix: swap out failure message
* feat: add process refund button in swap in status screen
* chore: further improvements
* fix: wails routes
* feat: add frequency selector for ZapPlanner payments (#1312) (#1317)
* feat: add frequency selector for ZapPlanner payments (#1312)
* feat: add frequency selector for ZapPlanner payments (#1312) +corrections
* feat(zapplanner): add USD/BTC selector and frequency option
Budget renewal still has to be adjusted
* feat(zapplanner): set default frequency to 1 month
* feat(zapplanner): set default amount to usd and added (sats) to clarify BTC unit
* feat(zapplanner): convert months to days for subscriptions
* feat(zapplanner): add open to convertCurrency deps to allow consecutive subscriptions
* feat(Zapplanner freq¤cy selector): added all currencies to the selector
* feat(Zapplanner freq¤cy selector): removed bug about 2xBTC(sats) on the menu
* feat(zapplanner): frequency & currency all comments addressed
* chore: zapplanner fixes
- currency sorting
- sats currency usage for ZapPlanner
- force whole values for ZapPlanner
- pass correct currency to ZapPlanner
- rename field
- fix input width
---------
Co-authored-by: jpl-btc <>
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
* chore: add reconnection logic
* chore: specify fees while locking btc
* fix: do not use context background
* chore: improve auto swaps frontend
* chore: add boltz logo to tx item
* Updated Primal app connection (#1428)
* Updated Primal app connection
* fix: lint
---------
Co-authored-by: René Aaron <rene@twentyuno.net>
* chore: bump uniffi-bindgen-go and revert error handling in the LDK client (#1434)
* chore: revert error handling in the LDK client
* chore: update ldk-node-go dependency
---------
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
* Read.me adjustments (#1440)
* Update README.md
1) We spend a lot of time helping users to fix their problems with Raspi PIs.
2) Computers that are offline regularly create a bad UX because payments in external apps do not work and channels are closed earlier.
* Update README.md
* feat: add expired state to nip47 transactions (#1441)
* fix: use custom mempool url (#1431)
* fix: use custom mempool url
* chore: return mempool url in info endpoint
* chore: use mempool url from info response in frontend
* chore: remove default mempool url in frontend
* fix: tests
* feat: add LDK bitcoind rpc chain source (#1367)
* feat: add LDK bitcoind rpc chain source
* fix: crash in bitcoindrpc due to not enabling continuous sync
* chore: renaming
* chore: mark swap status as failed
* chore: use mempool url from info
* chore: poll balances on node page
* fix: when opening outbound channel, extract host part if full peer connection url is pasted
* chore: use mempool url from backend info endpoint
* docs: add boltz regtest setup instructions
* chore: separate swap in and out status pages
* fix: remove duplicate useInfo
* fix: mnemonic derivation logic
* chore: address comments
* chore: add tests for swap mnemonic generation
* chore: add refunded state
* chore: rename columns
* chore: simplify swap status frontend
* chore: mark swap out as successful after claim tx conf
* chore: add address to refund
* fix: wails
* feat: add resubscription
* chore: add logging
* chore: save refund address to db and use new address
* chore: add comment
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
Co-authored-by: Freepilot <215356755+freepilot-bot@users.noreply.github.com>
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
Co-authored-by: achaldps@gmail.com <achaldps@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nodii <13803869+NodeDiver@users.noreply.github.com>
Co-authored-by: Moritz Kaminski <moritz.kaminski@gmail.com>
Co-authored-by: René Aaron <rene@twentyuno.net>
Co-authored-by: Roman D <roman@dmitrienko.com>
* chore: rename to receive_amount
* chore: remove auto swap success and add boltz link
* chore: use constant and rename variables
* fix: mark swaps as failed
* fix: show receive amount in swap in success screen
* chore: remove duplicate endpoint and reorder
* chore: add comment in wails handler
* chore: use markSwapState
* chore: add retries
* fix: use one websocket per swap
* chore: frontend fixes
* feat: add swap mnemonic to debug tools
* fix: tx list
* fix: tests
* chore: further changes
* chore: improve copy
* chore: improve copy
* chore: improve copy
* chore: rename, add autofocus on swap inputs
* fix: swap in failed state when no lockup tx exists
* chore: add interval note to active swap component
* chore: remove boltz image
* chore: use hasChannelManagement check
* chore: use link instead of navigate
* chore: mark swaps as failed in case of errors
* chore: add comment
* chore: only mark swaps as failed in defer function
* chore: improve copy
* chore: update boltz client to v2.7.2
* chore: use refundSwapRequest param
* fix: refund swap method
* chore: minor changes
* chore: add retries
* chore: add retries and use single ws connection for pending swaps
* fix: swap fee error message
* chore: remove sending partial signature in swap in
* chore: log error when update channel is not ok
* fix: add tx claimed state in swap in listener
* chore: add nwc_swap_succeeded to whitelist and readme
* feat: use single boltz ws connection
* chore: only check for tx claimed state
* chore: use lock while sending updates
* chore: handle boltz update error
* chore: remove swap id from success event
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
Co-authored-by: Freepilot <215356755+freepilot-bot@users.noreply.github.com>
Co-authored-by: achaldps@gmail.com <achaldps@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nodii <13803869+NodeDiver@users.noreply.github.com>
Co-authored-by: Moritz Kaminski <moritz.kaminski@gmail.com>
Co-authored-by: René Aaron <rene@twentyuno.net>
Co-authored-by: Roman D <roman@dmitrienko.com>
* fix: sqlite pragma statement not applying to all sqlite connections
* fix: add migration to delete orphaned records
* fix: migrate postgres transaction amount column to bigint
* chore: simplify migration, update comment
* fix: sqlite uri when running tests
* fix: check that breaks tests
* fix: db locking within transaction
* fix: sqlite3 driver wrapper to execute PRAGMAs on each new connection (#1464)
* fix: sqlite3 driver wrapper to execute PRAGMAs on each new connection
* chore: add test to check temp_store value
---------
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
---------
Co-authored-by: Roman D <roman@dmitrienko.com>
* feat: add LND hold invoices support
* fix: add HOLD_INVOICE_ACCEPTED_NOTIFICATION to notifications list returned by get_info
* fix: revert
* fix: remove unneeded null checks
* docs: add extra event type to README
* feat: add LND hold invoices support
* fix: add HOLD_INVOICE_ACCEPTED_NOTIFICATION to notifications list returned by get_info
* fix: revert
* fix: remove unneeded null checks
* docs: add extra event type to README
* fix: remove 0 expiry checking in the make_hold_invoice_controller
* fix: use JSON logging
* revert fly.toml
* fix: duplicated check
* fix: move publishing nwc_hold_invoice_accepted out of the transaction
* fix: move publishing nwc_hold_invoice_accepted out of the transaction
* fix: check the invoice state ACCEPTED before calling the lnClient.SettleHoldInvoice
* fix: check the invoice state ACCEPTED before calling the lnClient.SettleHoldInvoice
* fix: check the invoice state ACCEPTED before calling the lnClient.SettleHoldInvoice
* fix: check the invoice state ACCEPTED before calling the lnClient.SettleHoldInvoice
* fix: cancel hold invoice tests
* fix: make hold invoice tests
* fix: make hold invoice tests
* fix: settle hold invoice tests
* fix: resubscribe to pending hold invoices
* fix: missing WatchHoldInvoice
in the mocks
* feat: add LDK impl
* fix: cleanup
* fix: payment_hash
* fix: remove unneeded update
* feat: add support for self payments for hold invoices (#1304)
Co-authored-by: frnandu <frnandu@gmail.com>
* fix: remove hold invoices scope
* fix: remove hold invoices scope
* fix: mock hold bolt11 expiry to 10 years
* fix: sleep 1 second to give a change of lookupinvoice to read cancelled
* fix: missing timeout param
* feat: add hold invoice settle deadline to transactions (#1324)
* chore: update mockery, remove unused hold invoice method
* chore: remove unnecessary comment
* chore: remove unused code
* fix: do not return hold transaction if lookup failed
* chore: remove unused code
* fix: return correct errors from nip47 controllers, remove unused code
* fix: failing test
* chore: remove unnecessary code
* fix: make error message more general
* chore: remove unused code
* fix: use correct context in lnd service
* fix: unstable hold payments test
---------
Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
Fixes#1263
Leaves out a few things mentioned in the issue:
- Persisting a request event and response event (updates are covered
though)
- Fetching user config by a particular key (key is already indexed and
are very less, not sure why this is happening)
- Listing apps from the http API, the ideal solution is to have the
permissions within the apps table, we should do a migration for that)
## Indexes removed
- `idx_transactions_app_id` (we never filter only on app_id, added
composite indexes to cover all cases)
- `idx_transactions_request_event_id` (same as above)
- `idx_transactions_created_at` (same as above)
- `idx_transactions_settled_at` (same as above)
-
`idx_transactions_app_id_type_state_created_at_settled_at_payment_hash`
(we should always use most differing column first, so it can use the
index when required, and payment_hash is at the end, also we never
filter based on created and settled at dates, so we can remove it)
## Indexes added
- `idx_transactions_state_type` (used while listing txs)
- `idx_transactions_state_type_updated_at` (used while listing txs)
- `idx_transactions_app_id_state_type_updated_at` (used while listing
txs)
- `idx_transactions_payment_hash_settled_at_created_at` (for lookup
transaction)
### List Transactions - Possible queries
- We always chain on `state` and `type`
- `updated_at` is not used much, unless it's via NWC controller
- Also pushed `updated_at desc` ordering to do it after counting to save
some time
- Conditionally `app_id` (I took out code to find `isIsolated` outside
to reduce multiple requests to db at once)
So for all these possibilities, I added `idx_transactions_state_type`,
`idx_transactions_state_type_updated_at` and
`idx_transactions_app_id_state_type_updated_at`
(`idx_transactions_app_id_type_state` already exists)
### Lookup Transactions - Possible queries
- We don't use `type` at all - both internally and via NWC, we should
remove the param itself in a separate issue
- We do a find query on `payment_hash` by ordering by `settled_at` and
`created_at`
- Conditionally `app_id` (I took out code to find `isIsolated` outside
to reduce multiple requests to db at once)
And this time app_id doesn't make much difference so I only added
`idx_transactions_payment_hash_settled_at_created_at`
* chore: add test for postgres race condition in transaction service
* fix: payments race condition when using postgres backend
* chore: reduce delay in concurrent payment tests