alby-hub/api/api.go

2329 lines
73 KiB
Go
Raw Normal View History

2024-05-30 00:06:06 +07:00
package api
import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/hex"
2024-05-30 00:06:06 +07:00
"encoding/json"
"encoding/pem"
2024-05-30 00:06:06 +07:00
"errors"
"flag"
2024-05-30 00:06:06 +07:00
"fmt"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"slices"
2025-04-16 20:58:32 +05:30
"strconv"
"strings"
"sync"
"sync/atomic"
2024-05-30 00:06:06 +07:00
"time"
"github.com/sirupsen/logrus"
"gopkg.in/macaroon.v2"
feat: add buzzpay internal app (#580) * feat: add uncle jim internal app * fix: wrong number in instructions * chore: simplify alby jim internal app copy * Feat: app metadata (#570) * chore: wg.Add() before go (#559) * chore: code cleanup (#558) * Update README.md Add command to make the install script executable in the instructions. * feat: add migration card in wallet screen (#555) * feat: add migration card in wallet screen * chore: transfer funds if channel exists * chore: typo * chore: improve copy * chore: add transfer funds button * fix: remove duplicate icon --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: run extra workflows on PR (#563) * chore: run extra workflows on PR * fix: pull request workflows * build(deps): bump github.com/nbd-wtf/go-nostr from 0.34.5 to 0.34.10 (#551) Bumps [github.com/nbd-wtf/go-nostr](https://github.com/nbd-wtf/go-nostr) from 0.34.5 to 0.34.10. - [Commits](https://github.com/nbd-wtf/go-nostr/compare/v0.34.5...v0.34.10) --- updated-dependencies: - dependency-name: github.com/nbd-wtf/go-nostr 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> * build(deps): bump gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0 (#552) Bumps gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0. --- updated-dependencies: - dependency-name: gopkg.in/DataDog/dd-trace-go.v1 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> * fix: do not render 0 on withdraw onchain funds page when reserve balance is 0 (#549) * chore: update fly default kill timeout to ensure app gracefully shuts down (#547) * feat: app metadata * fix(wails): parse max length in log output endpoint (#568) * fix: alby account image and name on transaction list * fix: vertically center transaction item content * fix: use slashed zero on wallet balance * chore: align app image with app name in transaction list * fix: ensure auth with correct user if refresh token expires (#572) * fix: do not allow editing name of Alby Account connection * fix: change "Create Wallet" to "Create Subaccount" * fix: subaccount copy * chore: update friends and family app icon * fix: update app store images (#574) * fix: update app store images * chore: update paper scissors hodl and zapplanner icons * chore: update lume and habla news icons * chore: resize and compress zapplanner and rps logos --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * feat: add new auto channel flow that works with existing channels (#556) * feat: add new auto channel flow that works with existing channels * chore: remove "first" from auto channel copy * feat: new transaction list item design --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: add buzzpay internal app * chore: remove connection secret from metadata * fix: make buzzpay isolated * chore: update buzzpay app UI and instructions * chore: extract app creation into shared method * fix: isolated app permission display * chore: update copy --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-03 21:31:28 +07:00
"gorm.io/datatypes"
2024-05-30 00:06:06 +07:00
"gorm.io/gorm"
2024-07-05 20:32:40 +07:00
"github.com/getAlby/hub/alby"
"github.com/getAlby/hub/apps"
2024-07-05 20:32:40 +07:00
"github.com/getAlby/hub/config"
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
"github.com/getAlby/hub/constants"
2024-07-05 20:32:40 +07:00
"github.com/getAlby/hub/db"
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
"github.com/getAlby/hub/db/queries"
2024-07-05 20:32:40 +07:00
"github.com/getAlby/hub/events"
"github.com/getAlby/hub/lnclient"
"github.com/getAlby/hub/logger"
permissions "github.com/getAlby/hub/nip47/permissions"
"github.com/getAlby/hub/service"
"github.com/getAlby/hub/service/keys"
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
"github.com/getAlby/hub/swaps"
2024-07-05 20:32:40 +07:00
"github.com/getAlby/hub/utils"
"github.com/getAlby/hub/version"
2024-05-30 00:06:06 +07:00
)
type api struct {
db *gorm.DB
appsSvc apps.AppsService
cfg config.Config
svc service.Service
permissionsSvc permissions.PermissionsService
keys keys.Keys
albyOAuthSvc alby.AlbyOAuthService
albySvc alby.AlbyService
startupError error
startupErrorTime time.Time
eventPublisher events.EventPublisher
// set after a migration file is created; the hub is halted at that point
// and the frontend should keep showing the migration success page
nodeMigrationFileCreated atomic.Bool
2024-05-30 00:06:06 +07:00
}
func NewAPI(svc service.Service, gormDB *gorm.DB, config config.Config, keys keys.Keys, albySvc alby.AlbyService, albyOAuthSvc alby.AlbyOAuthService, eventPublisher events.EventPublisher) *api {
2024-05-30 00:06:06 +07:00
return &api{
2024-06-17 19:42:09 +07:00
db: gormDB,
Feat: NWA auth for self-hosted hubs (#1016) * feat: nwc create_connection command (WIP) * feat: allow creating superuser apps from the ui * fix: pass methods rather than scopes in create_connection method * chore: add extra tests * fix: use browser router in http mode * fix: update links to not use hash router * fix: add redirect from hash router url * fix: return nostrWalletConnectUrl in nwc connection success event and message * feat: publish nwa event * chore: use nwc info event instead of nwa event * feat: create custom alby go detail page * chore: allow creating/editing apps with the same name * fix: convert budget from msats to sats (#1111) * chore: address NWA feedback * chore: address feedback - adjust button copy - make create_connection methods consistent with http deeplink flow - remove unused constant - add empty string check before adding lud16 tag - fix test * feat: add support for notification_types in create_connection method * fix: shorter button copy * fix: do not include lud16 tag in published info event * Feat: add lud16 to get_info response (#1128) feat: add lud16 to get_info response * chore: minor alby go screen improvements * fix: incorrect unlock password error message to create app with superuser access * chore: minor ui improvements on alby go detail page * chore: avoid duplicate app names by adding a suffix * chore: move scopes check to apps service, add new tests, DRY controller test setup * fix: scopes component full access scopes and isolated scope group check * fix: use supported capabilities for Alby Go * fix: return correct app name * chore: address minor comments --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
2025-02-27 19:12:55 +07:00
appsSvc: apps.NewAppsService(gormDB, eventPublisher, keys, config),
2024-06-17 19:42:09 +07:00
cfg: config,
svc: svc,
2024-06-29 22:29:55 +07:00
permissionsSvc: permissions.NewPermissionsService(gormDB, eventPublisher),
2024-06-17 19:42:09 +07:00
keys: keys,
albySvc: albySvc,
2024-06-17 19:42:09 +07:00
albyOAuthSvc: albyOAuthSvc,
eventPublisher: eventPublisher,
2024-05-30 00:06:06 +07:00
}
}
func (api *api) CreateApp(createAppRequest *CreateAppRequest) (*CreateAppResponse, error) {
Feat: NWA auth for self-hosted hubs (#1016) * feat: nwc create_connection command (WIP) * feat: allow creating superuser apps from the ui * fix: pass methods rather than scopes in create_connection method * chore: add extra tests * fix: use browser router in http mode * fix: update links to not use hash router * fix: add redirect from hash router url * fix: return nostrWalletConnectUrl in nwc connection success event and message * feat: publish nwa event * chore: use nwc info event instead of nwa event * feat: create custom alby go detail page * chore: allow creating/editing apps with the same name * fix: convert budget from msats to sats (#1111) * chore: address NWA feedback * chore: address feedback - adjust button copy - make create_connection methods consistent with http deeplink flow - remove unused constant - add empty string check before adding lud16 tag - fix test * feat: add support for notification_types in create_connection method * fix: shorter button copy * fix: do not include lud16 tag in published info event * Feat: add lud16 to get_info response (#1128) feat: add lud16 to get_info response * chore: minor alby go screen improvements * fix: incorrect unlock password error message to create app with superuser access * chore: minor ui improvements on alby go detail page * chore: avoid duplicate app names by adding a suffix * chore: move scopes check to apps service, add new tests, DRY controller test setup * fix: scopes component full access scopes and isolated scope group check * fix: use supported capabilities for Alby Go * fix: return correct app name * chore: address minor comments --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
2025-02-27 19:12:55 +07:00
if slices.Contains(createAppRequest.Scopes, constants.SUPERUSER_SCOPE) {
if !api.cfg.CheckUnlockPassword(createAppRequest.UnlockPassword) {
return nil, fmt.Errorf(
"incorrect unlock password to create app with superuser permission")
}
}
maxAmountSat := uint64(0)
resolvedMaxAmountSat := ResolveToSat(createAppRequest.MaxAmountSat, createAppRequest.MaxAmountMsat, createAppRequest.MaxAmount, nil)
if resolvedMaxAmountSat != nil {
maxAmountSat = *resolvedMaxAmountSat
}
2025-07-14 07:45:48 +02:00
if createAppRequest.Name == alby.ALBY_ACCOUNT_APP_NAME {
return nil, fmt.Errorf("Reserved app name: %s", alby.ALBY_ACCOUNT_APP_NAME)
}
2024-05-30 00:06:06 +07:00
expiresAt, err := api.parseExpiresAt(createAppRequest.ExpiresAt)
if err != nil {
return nil, fmt.Errorf("invalid expiresAt: %v", err)
}
for _, scope := range createAppRequest.Scopes {
if !slices.Contains(permissions.AllScopes(), scope) {
return nil, fmt.Errorf("did not recognize requested scope: %s", scope)
2024-06-17 19:42:09 +07:00
}
}
app, pairingSecretKey, err := api.appsSvc.CreateApp(
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
createAppRequest.Name,
createAppRequest.Pubkey,
maxAmountSat,
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
createAppRequest.BudgetRenewal,
expiresAt,
createAppRequest.Scopes,
feat: add uncle jim internal app (#557) * feat: add uncle jim internal app * fix: wrong number in instructions * chore: simplify alby jim internal app copy * Feat: app metadata (#570) * chore: wg.Add() before go (#559) * chore: code cleanup (#558) * Update README.md Add command to make the install script executable in the instructions. * feat: add migration card in wallet screen (#555) * feat: add migration card in wallet screen * chore: transfer funds if channel exists * chore: typo * chore: improve copy * chore: add transfer funds button * fix: remove duplicate icon --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: run extra workflows on PR (#563) * chore: run extra workflows on PR * fix: pull request workflows * build(deps): bump github.com/nbd-wtf/go-nostr from 0.34.5 to 0.34.10 (#551) Bumps [github.com/nbd-wtf/go-nostr](https://github.com/nbd-wtf/go-nostr) from 0.34.5 to 0.34.10. - [Commits](https://github.com/nbd-wtf/go-nostr/compare/v0.34.5...v0.34.10) --- updated-dependencies: - dependency-name: github.com/nbd-wtf/go-nostr 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> * build(deps): bump gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0 (#552) Bumps gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0. --- updated-dependencies: - dependency-name: gopkg.in/DataDog/dd-trace-go.v1 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> * fix: do not render 0 on withdraw onchain funds page when reserve balance is 0 (#549) * chore: update fly default kill timeout to ensure app gracefully shuts down (#547) * feat: app metadata * fix(wails): parse max length in log output endpoint (#568) * fix: alby account image and name on transaction list * fix: vertically center transaction item content * fix: use slashed zero on wallet balance * chore: align app image with app name in transaction list * fix: ensure auth with correct user if refresh token expires (#572) * fix: do not allow editing name of Alby Account connection * fix: change "Create Wallet" to "Create Subaccount" * fix: subaccount copy * chore: update friends and family app icon * fix: update app store images (#574) * fix: update app store images * chore: update paper scissors hodl and zapplanner icons * chore: update lume and habla news icons * chore: resize and compress zapplanner and rps logos --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * feat: add new auto channel flow that works with existing channels (#556) * feat: add new auto channel flow that works with existing channels * chore: remove "first" from auto channel copy * feat: new transaction list item design --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: copy * fix: less detailed icon for uncle jim app * fix: shorten app description --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: René Aaron <rene@twentyuno.net> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com>
2024-09-02 17:40:34 +07:00
createAppRequest.Isolated,
feat: app child key derived from wallet master key (#736) * feat(appwalletKey): add GetBIP32ChildKey * feat: fix interface * feat: adding subscription WiP * feat: handle nostr subscriptions for lifecycle of apps * Delete .idea/.gitignore * Delete .idea/hub.iml * Delete .idea/modules.xml * Delete .idea/vcs.xml * fix: remove unnecessary * fix: missing handling legacy app * fix: review fixes * fix: use app.ID for key calculation instead of passing in event * fix: add TODO * fix: remove unnecessary check * fix: improve err handling and remove check * chore: store master nostr key to avoid deriving each time * chore: rename app nostr_pubkey to app_pubkey, extract app consumers into separate files * chore: finish renaming * fix: update app wallet pubkey on app creation * fix: not NULL check * fix: fix HandleEvent * fix: error handling * fix: error handling * fix: move StartSubscription to start.go * fix: remove duplicated error check * fix: make tests use AppsService for creating apps * chore: remove unused code * chore: minor event handler improvements - fix error code response when failing to update request event - fix log content when failing to decrypt request event - move logging of app to correct place * fix: add event_handler tests for legacy app * chore: add comment about legacy apps in deleteAppConsumer * fix: remove unused app from tests * fix: error handling in startAppWalletSubscription * fix: only create event info and nostr subscription for master key if there are legacy apps * fix: add legacy tests * fix: move fetching of Nip47 event info to deleteAppConsumer * fix: fixed arguments * fix: use require instead of assert * fix: adapt GetAppWalletKey to use DeriveKey with path 1' * fix: for backends that don't use a mnemonic, create appKey from nostrSecretKey * fix: cleanup eventPublisher Subscribers when relay reconnects * fix: bip32.FirstHardenedChild + appID * fix: remove unused env vars * fix: generate new mnemonic if empty * fix: add tests.CreateTestServiceWithMnemonic to fix TestEncryptedBackup * fix: handle both relay and main ctx Done * chore: add keys tests * chore: add extra assertions to keys test * chore: log when legacy app subscription is created * chore: remove unnecessary break * chore: add log when relay is successfully connected * fix: only auto-start node if it has been started before --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2024-11-07 13:06:01 +01:00
createAppRequest.Metadata,
)
2024-05-30 00:06:06 +07:00
if err != nil {
return nil, err
}
relayUrls := api.cfg.GetRelayUrls()
2024-05-30 00:06:06 +07:00
lightningAddress, err := api.albyOAuthSvc.GetLightningAddress()
if err != nil {
return nil, err
}
2024-05-30 00:06:06 +07:00
responseBody := &CreateAppResponse{}
responseBody.Id = app.ID
Feat: NWA auth for self-hosted hubs (#1016) * feat: nwc create_connection command (WIP) * feat: allow creating superuser apps from the ui * fix: pass methods rather than scopes in create_connection method * chore: add extra tests * fix: use browser router in http mode * fix: update links to not use hash router * fix: add redirect from hash router url * fix: return nostrWalletConnectUrl in nwc connection success event and message * feat: publish nwa event * chore: use nwc info event instead of nwa event * feat: create custom alby go detail page * chore: allow creating/editing apps with the same name * fix: convert budget from msats to sats (#1111) * chore: address NWA feedback * chore: address feedback - adjust button copy - make create_connection methods consistent with http deeplink flow - remove unused constant - add empty string check before adding lud16 tag - fix test * feat: add support for notification_types in create_connection method * fix: shorter button copy * fix: do not include lud16 tag in published info event * Feat: add lud16 to get_info response (#1128) feat: add lud16 to get_info response * chore: minor alby go screen improvements * fix: incorrect unlock password error message to create app with superuser access * chore: minor ui improvements on alby go detail page * chore: avoid duplicate app names by adding a suffix * chore: move scopes check to apps service, add new tests, DRY controller test setup * fix: scopes component full access scopes and isolated scope group check * fix: use supported capabilities for Alby Go * fix: return correct app name * chore: address minor comments --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
2025-02-27 19:12:55 +07:00
responseBody.Name = app.Name
feat: app child key derived from wallet master key (#736) * feat(appwalletKey): add GetBIP32ChildKey * feat: fix interface * feat: adding subscription WiP * feat: handle nostr subscriptions for lifecycle of apps * Delete .idea/.gitignore * Delete .idea/hub.iml * Delete .idea/modules.xml * Delete .idea/vcs.xml * fix: remove unnecessary * fix: missing handling legacy app * fix: review fixes * fix: use app.ID for key calculation instead of passing in event * fix: add TODO * fix: remove unnecessary check * fix: improve err handling and remove check * chore: store master nostr key to avoid deriving each time * chore: rename app nostr_pubkey to app_pubkey, extract app consumers into separate files * chore: finish renaming * fix: update app wallet pubkey on app creation * fix: not NULL check * fix: fix HandleEvent * fix: error handling * fix: error handling * fix: move StartSubscription to start.go * fix: remove duplicated error check * fix: make tests use AppsService for creating apps * chore: remove unused code * chore: minor event handler improvements - fix error code response when failing to update request event - fix log content when failing to decrypt request event - move logging of app to correct place * fix: add event_handler tests for legacy app * chore: add comment about legacy apps in deleteAppConsumer * fix: remove unused app from tests * fix: error handling in startAppWalletSubscription * fix: only create event info and nostr subscription for master key if there are legacy apps * fix: add legacy tests * fix: move fetching of Nip47 event info to deleteAppConsumer * fix: fixed arguments * fix: use require instead of assert * fix: adapt GetAppWalletKey to use DeriveKey with path 1' * fix: for backends that don't use a mnemonic, create appKey from nostrSecretKey * fix: cleanup eventPublisher Subscribers when relay reconnects * fix: bip32.FirstHardenedChild + appID * fix: remove unused env vars * fix: generate new mnemonic if empty * fix: add tests.CreateTestServiceWithMnemonic to fix TestEncryptedBackup * fix: handle both relay and main ctx Done * chore: add keys tests * chore: add extra assertions to keys test * chore: log when legacy app subscription is created * chore: remove unnecessary break * chore: add log when relay is successfully connected * fix: only auto-start node if it has been started before --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2024-11-07 13:06:01 +01:00
responseBody.Pubkey = app.AppPubkey
2024-05-30 00:06:06 +07:00
responseBody.PairingSecret = pairingSecretKey
responseBody.WalletPubkey = *app.WalletPubkey
responseBody.RelayUrls = relayUrls
responseBody.Lud16 = lightningAddress
responseBody.ReturnTo = buildReturnToUrl(createAppRequest.ReturnTo, relayUrls, *app.WalletPubkey, lightningAddress, app.Isolated)
2024-05-30 00:06:06 +07:00
var lud16 string
if lightningAddress != "" && !app.Isolated {
lud16 = fmt.Sprintf("&lud16=%s", lightningAddress)
}
responseBody.PairingUri = fmt.Sprintf("nostr+walletconnect://%s?relay=%s&secret=%s%s", *app.WalletPubkey, strings.Join(relayUrls, "&relay="), pairingSecretKey, lud16)
feat: app child key derived from wallet master key (#736) * feat(appwalletKey): add GetBIP32ChildKey * feat: fix interface * feat: adding subscription WiP * feat: handle nostr subscriptions for lifecycle of apps * Delete .idea/.gitignore * Delete .idea/hub.iml * Delete .idea/modules.xml * Delete .idea/vcs.xml * fix: remove unnecessary * fix: missing handling legacy app * fix: review fixes * fix: use app.ID for key calculation instead of passing in event * fix: add TODO * fix: remove unnecessary check * fix: improve err handling and remove check * chore: store master nostr key to avoid deriving each time * chore: rename app nostr_pubkey to app_pubkey, extract app consumers into separate files * chore: finish renaming * fix: update app wallet pubkey on app creation * fix: not NULL check * fix: fix HandleEvent * fix: error handling * fix: error handling * fix: move StartSubscription to start.go * fix: remove duplicated error check * fix: make tests use AppsService for creating apps * chore: remove unused code * chore: minor event handler improvements - fix error code response when failing to update request event - fix log content when failing to decrypt request event - move logging of app to correct place * fix: add event_handler tests for legacy app * chore: add comment about legacy apps in deleteAppConsumer * fix: remove unused app from tests * fix: error handling in startAppWalletSubscription * fix: only create event info and nostr subscription for master key if there are legacy apps * fix: add legacy tests * fix: move fetching of Nip47 event info to deleteAppConsumer * fix: fixed arguments * fix: use require instead of assert * fix: adapt GetAppWalletKey to use DeriveKey with path 1' * fix: for backends that don't use a mnemonic, create appKey from nostrSecretKey * fix: cleanup eventPublisher Subscribers when relay reconnects * fix: bip32.FirstHardenedChild + appID * fix: remove unused env vars * fix: generate new mnemonic if empty * fix: add tests.CreateTestServiceWithMnemonic to fix TestEncryptedBackup * fix: handle both relay and main ctx Done * chore: add keys tests * chore: add extra assertions to keys test * chore: log when legacy app subscription is created * chore: remove unnecessary break * chore: add log when relay is successfully connected * fix: only auto-start node if it has been started before --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2024-11-07 13:06:01 +01:00
2024-05-30 00:06:06 +07:00
return responseBody, nil
}
// buildReturnToUrl adds the connection query parameters to the return_to
// URL the user will be redirected to. Only http and https URLs are accepted.
func buildReturnToUrl(returnTo string, relayUrls []string, walletPubkey string, lightningAddress string, isolated bool) string {
if returnTo == "" {
return ""
}
returnToUrl, err := url.Parse(returnTo)
if err != nil || (returnToUrl.Scheme != "http" && returnToUrl.Scheme != "https") {
return ""
}
query := returnToUrl.Query()
for _, relayUrl := range relayUrls {
query.Add("relay", relayUrl)
}
query.Add("pubkey", walletPubkey)
if lightningAddress != "" && !isolated {
query.Add("lud16", lightningAddress)
}
returnToUrl.RawQuery = query.Encode()
return returnToUrl.String()
}
2024-05-30 00:06:06 +07:00
func (api *api) UpdateApp(userApp *db.App, updateAppRequest *UpdateAppRequest) error {
resolvedMaxAmountSat := ResolveToSat(updateAppRequest.MaxAmountSat, updateAppRequest.MaxAmountMsat, updateAppRequest.MaxAmount, nil)
err := api.db.Transaction(func(tx *gorm.DB) error {
// Initialize name with current app name, update if provided
name := userApp.Name
// Update app name if provided and different
if updateAppRequest.Name != nil {
name = *updateAppRequest.Name
2024-05-30 00:06:06 +07:00
if name == "" {
return fmt.Errorf("won't update an app to have no name")
}
if name != userApp.Name {
err := tx.Model(&db.App{}).Where("id", userApp.ID).Update("name", name).Error
if err != nil {
return err
}
}
}
// Update app isolation if provided and different
if updateAppRequest.Isolated != nil {
isolated := *updateAppRequest.Isolated
if isolated != userApp.Isolated {
if !isolated {
var existingMetadata Metadata
if userApp.Metadata != nil {
err := json.Unmarshal(userApp.Metadata, &existingMetadata)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": userApp.ID,
}).Error("Failed to deserialize app metadata")
return err
}
if existingMetadata[constants.METADATA_APPSTORE_APP_ID_KEY] == constants.SUBWALLET_APPSTORE_APP_ID {
return errors.New("Cannot update sub-wallet to be non-isolated")
}
}
}
err := tx.Model(&db.App{}).Where("id", userApp.ID).Update("isolated", isolated).Error
if err != nil {
return err
}
}
}
// Update the app metadata if provided
feat: add buzzpay internal app (#580) * feat: add uncle jim internal app * fix: wrong number in instructions * chore: simplify alby jim internal app copy * Feat: app metadata (#570) * chore: wg.Add() before go (#559) * chore: code cleanup (#558) * Update README.md Add command to make the install script executable in the instructions. * feat: add migration card in wallet screen (#555) * feat: add migration card in wallet screen * chore: transfer funds if channel exists * chore: typo * chore: improve copy * chore: add transfer funds button * fix: remove duplicate icon --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: run extra workflows on PR (#563) * chore: run extra workflows on PR * fix: pull request workflows * build(deps): bump github.com/nbd-wtf/go-nostr from 0.34.5 to 0.34.10 (#551) Bumps [github.com/nbd-wtf/go-nostr](https://github.com/nbd-wtf/go-nostr) from 0.34.5 to 0.34.10. - [Commits](https://github.com/nbd-wtf/go-nostr/compare/v0.34.5...v0.34.10) --- updated-dependencies: - dependency-name: github.com/nbd-wtf/go-nostr 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> * build(deps): bump gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0 (#552) Bumps gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0. --- updated-dependencies: - dependency-name: gopkg.in/DataDog/dd-trace-go.v1 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> * fix: do not render 0 on withdraw onchain funds page when reserve balance is 0 (#549) * chore: update fly default kill timeout to ensure app gracefully shuts down (#547) * feat: app metadata * fix(wails): parse max length in log output endpoint (#568) * fix: alby account image and name on transaction list * fix: vertically center transaction item content * fix: use slashed zero on wallet balance * chore: align app image with app name in transaction list * fix: ensure auth with correct user if refresh token expires (#572) * fix: do not allow editing name of Alby Account connection * fix: change "Create Wallet" to "Create Subaccount" * fix: subaccount copy * chore: update friends and family app icon * fix: update app store images (#574) * fix: update app store images * chore: update paper scissors hodl and zapplanner icons * chore: update lume and habla news icons * chore: resize and compress zapplanner and rps logos --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * feat: add new auto channel flow that works with existing channels (#556) * feat: add new auto channel flow that works with existing channels * chore: remove "first" from auto channel copy * feat: new transaction list item design --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: add buzzpay internal app * chore: remove connection secret from metadata * fix: make buzzpay isolated * chore: update buzzpay app UI and instructions * chore: extract app creation into shared method * fix: isolated app permission display * chore: update copy --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-03 21:31:28 +07:00
if updateAppRequest.Metadata != nil {
var metadataBytes []byte
var err error
metadataBytes, err = json.Marshal(*updateAppRequest.Metadata)
feat: add buzzpay internal app (#580) * feat: add uncle jim internal app * fix: wrong number in instructions * chore: simplify alby jim internal app copy * Feat: app metadata (#570) * chore: wg.Add() before go (#559) * chore: code cleanup (#558) * Update README.md Add command to make the install script executable in the instructions. * feat: add migration card in wallet screen (#555) * feat: add migration card in wallet screen * chore: transfer funds if channel exists * chore: typo * chore: improve copy * chore: add transfer funds button * fix: remove duplicate icon --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: run extra workflows on PR (#563) * chore: run extra workflows on PR * fix: pull request workflows * build(deps): bump github.com/nbd-wtf/go-nostr from 0.34.5 to 0.34.10 (#551) Bumps [github.com/nbd-wtf/go-nostr](https://github.com/nbd-wtf/go-nostr) from 0.34.5 to 0.34.10. - [Commits](https://github.com/nbd-wtf/go-nostr/compare/v0.34.5...v0.34.10) --- updated-dependencies: - dependency-name: github.com/nbd-wtf/go-nostr 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> * build(deps): bump gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0 (#552) Bumps gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0. --- updated-dependencies: - dependency-name: gopkg.in/DataDog/dd-trace-go.v1 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> * fix: do not render 0 on withdraw onchain funds page when reserve balance is 0 (#549) * chore: update fly default kill timeout to ensure app gracefully shuts down (#547) * feat: app metadata * fix(wails): parse max length in log output endpoint (#568) * fix: alby account image and name on transaction list * fix: vertically center transaction item content * fix: use slashed zero on wallet balance * chore: align app image with app name in transaction list * fix: ensure auth with correct user if refresh token expires (#572) * fix: do not allow editing name of Alby Account connection * fix: change "Create Wallet" to "Create Subaccount" * fix: subaccount copy * chore: update friends and family app icon * fix: update app store images (#574) * fix: update app store images * chore: update paper scissors hodl and zapplanner icons * chore: update lume and habla news icons * chore: resize and compress zapplanner and rps logos --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * feat: add new auto channel flow that works with existing channels (#556) * feat: add new auto channel flow that works with existing channels * chore: remove "first" from auto channel copy * feat: new transaction list item design --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: add buzzpay internal app * chore: remove connection secret from metadata * fix: make buzzpay isolated * chore: update buzzpay app UI and instructions * chore: extract app creation into shared method * fix: isolated app permission display * chore: update copy --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-03 21:31:28 +07:00
if err != nil {
logger.Logger.WithError(err).Error("Failed to serialize metadata")
return err
}
err = tx.Model(&db.App{}).Where("id", userApp.ID).Update("metadata", datatypes.JSON(metadataBytes)).Error
if err != nil {
return err
}
}
// Handle permissions updates only if any permission-related field is provided
if updateAppRequest.Scopes != nil || resolvedMaxAmountSat != nil ||
updateAppRequest.BudgetRenewal != nil || updateAppRequest.ExpiresAt != nil || updateAppRequest.UpdateExpiresAt {
2024-05-30 00:06:06 +07:00
// Get current values or use provided ones
var maxAmountSat uint64
var budgetRenewal string
var expiresAt *time.Time
2024-05-30 00:06:06 +07:00
// Get existing permissions to use as defaults
var existingPermissions []db.AppPermission
if err := tx.Where("app_id = ?", userApp.ID).Find(&existingPermissions).Error; err != nil {
return err
}
Feat: NWA auth for self-hosted hubs (#1016) * feat: nwc create_connection command (WIP) * feat: allow creating superuser apps from the ui * fix: pass methods rather than scopes in create_connection method * chore: add extra tests * fix: use browser router in http mode * fix: update links to not use hash router * fix: add redirect from hash router url * fix: return nostrWalletConnectUrl in nwc connection success event and message * feat: publish nwa event * chore: use nwc info event instead of nwa event * feat: create custom alby go detail page * chore: allow creating/editing apps with the same name * fix: convert budget from msats to sats (#1111) * chore: address NWA feedback * chore: address feedback - adjust button copy - make create_connection methods consistent with http deeplink flow - remove unused constant - add empty string check before adding lud16 tag - fix test * feat: add support for notification_types in create_connection method * fix: shorter button copy * fix: do not include lud16 tag in published info event * Feat: add lud16 to get_info response (#1128) feat: add lud16 to get_info response * chore: minor alby go screen improvements * fix: incorrect unlock password error message to create app with superuser access * chore: minor ui improvements on alby go detail page * chore: avoid duplicate app names by adding a suffix * chore: move scopes check to apps service, add new tests, DRY controller test setup * fix: scopes component full access scopes and isolated scope group check * fix: use supported capabilities for Alby Go * fix: return correct app name * chore: address minor comments --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
2025-02-27 19:12:55 +07:00
// Use existing values as defaults
if len(existingPermissions) > 0 {
// Find pay_invoice permission for budget-related fields
for _, perm := range existingPermissions {
if perm.Scope == constants.PAY_INVOICE_SCOPE {
maxAmountSat = uint64(perm.MaxAmountSat)
budgetRenewal = perm.BudgetRenewal
expiresAt = perm.ExpiresAt
break
}
2024-05-30 00:06:06 +07:00
}
}
// Override with provided values
if resolvedMaxAmountSat != nil {
maxAmountSat = *resolvedMaxAmountSat
}
if updateAppRequest.BudgetRenewal != nil {
budgetRenewal = *updateAppRequest.BudgetRenewal
}
if updateAppRequest.ExpiresAt != nil {
parsedExpiresAt, err := api.parseExpiresAt(*updateAppRequest.ExpiresAt)
if err != nil {
return fmt.Errorf("invalid expiresAt: %v", err)
2024-05-30 00:06:06 +07:00
}
expiresAt = parsedExpiresAt
}
if updateAppRequest.ExpiresAt == nil && updateAppRequest.UpdateExpiresAt {
expiresAt = nil
2024-05-30 00:06:06 +07:00
}
// Update existing permissions with new budget and expiry
err := tx.Model(&db.AppPermission{}).Where("app_id", userApp.ID).Updates(map[string]interface{}{
"ExpiresAt": expiresAt,
"MaxAmountSat": maxAmountSat,
"BudgetRenewal": budgetRenewal,
}).Error
if err != nil {
2024-05-30 00:06:06 +07:00
return err
}
// Handle scope changes only if scopes were provided
if updateAppRequest.Scopes != nil {
if len(updateAppRequest.Scopes) == 0 {
return fmt.Errorf("won't update an app to have no request methods")
}
existingScopeMap := make(map[string]bool)
for _, perm := range existingPermissions {
existingScopeMap[perm.Scope] = true
}
if slices.Contains(updateAppRequest.Scopes, constants.SUPERUSER_SCOPE) && !existingScopeMap[constants.SUPERUSER_SCOPE] {
return fmt.Errorf("cannot update app to add superuser permission")
}
// Add new permissions
for _, scope := range updateAppRequest.Scopes {
if !existingScopeMap[scope] {
perm := db.AppPermission{
App: *userApp,
Scope: scope,
ExpiresAt: expiresAt,
MaxAmountSat: int(maxAmountSat),
BudgetRenewal: budgetRenewal,
}
if err := tx.Create(&perm).Error; err != nil {
return err
}
}
delete(existingScopeMap, scope)
}
// Remove old permissions
for scope := range existingScopeMap {
if err := tx.Where("app_id = ? AND scope = ?", userApp.ID, scope).Delete(&db.AppPermission{}).Error; err != nil {
return err
}
}
}
2024-05-30 00:06:06 +07:00
}
// Publish update event
api.svc.GetEventPublisher().Publish(&events.Event{
Event: "nwc_app_updated",
Properties: map[string]interface{}{
"name": name,
"id": userApp.ID,
},
})
2024-05-30 00:06:06 +07:00
// commit transaction
return nil
})
return err
}
func (api *api) DeleteApp(userApp *db.App) error {
// Delete lightning address if one exists
if api.appsSvc.HasLightningAddress(userApp) {
err := api.DeleteLightningAddress(context.Background(), userApp.ID)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": userApp.ID,
}).Error("Failed to delete lightning address during app deletion")
}
}
feat: app child key derived from wallet master key (#736) * feat(appwalletKey): add GetBIP32ChildKey * feat: fix interface * feat: adding subscription WiP * feat: handle nostr subscriptions for lifecycle of apps * Delete .idea/.gitignore * Delete .idea/hub.iml * Delete .idea/modules.xml * Delete .idea/vcs.xml * fix: remove unnecessary * fix: missing handling legacy app * fix: review fixes * fix: use app.ID for key calculation instead of passing in event * fix: add TODO * fix: remove unnecessary check * fix: improve err handling and remove check * chore: store master nostr key to avoid deriving each time * chore: rename app nostr_pubkey to app_pubkey, extract app consumers into separate files * chore: finish renaming * fix: update app wallet pubkey on app creation * fix: not NULL check * fix: fix HandleEvent * fix: error handling * fix: error handling * fix: move StartSubscription to start.go * fix: remove duplicated error check * fix: make tests use AppsService for creating apps * chore: remove unused code * chore: minor event handler improvements - fix error code response when failing to update request event - fix log content when failing to decrypt request event - move logging of app to correct place * fix: add event_handler tests for legacy app * chore: add comment about legacy apps in deleteAppConsumer * fix: remove unused app from tests * fix: error handling in startAppWalletSubscription * fix: only create event info and nostr subscription for master key if there are legacy apps * fix: add legacy tests * fix: move fetching of Nip47 event info to deleteAppConsumer * fix: fixed arguments * fix: use require instead of assert * fix: adapt GetAppWalletKey to use DeriveKey with path 1' * fix: for backends that don't use a mnemonic, create appKey from nostrSecretKey * fix: cleanup eventPublisher Subscribers when relay reconnects * fix: bip32.FirstHardenedChild + appID * fix: remove unused env vars * fix: generate new mnemonic if empty * fix: add tests.CreateTestServiceWithMnemonic to fix TestEncryptedBackup * fix: handle both relay and main ctx Done * chore: add keys tests * chore: add extra assertions to keys test * chore: log when legacy app subscription is created * chore: remove unnecessary break * chore: add log when relay is successfully connected * fix: only auto-start node if it has been started before --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2024-11-07 13:06:01 +01:00
return api.appsSvc.DeleteApp(userApp)
2024-05-30 00:06:06 +07:00
}
func (api *api) CreateLightningAddress(ctx context.Context, createLightningAddressRequest *CreateLightningAddressRequest) error {
app := api.appsSvc.GetAppById(createLightningAddressRequest.AppId)
if app == nil {
return errors.New("app not found")
}
var metadata map[string]interface{}
err := json.Unmarshal(app.Metadata, &metadata)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": app.ID,
}).Error("Failed to deserialize app metadata")
return err
}
createLightningAddressResponse, err := api.albyOAuthSvc.CreateLightningAddress(ctx, createLightningAddressRequest.Address, createLightningAddressRequest.AppId)
if err != nil {
logger.Logger.WithError(err).Error("Failed to create lightning address for app")
return err
}
metadata["lud16"] = createLightningAddressResponse.FullAddress
err = api.appsSvc.SetAppMetadata(app.ID, metadata)
if err != nil {
logger.Logger.WithError(err).Error("Failed to add lightning address to app metadata")
return err
}
return nil
}
func (api *api) DeleteLightningAddress(ctx context.Context, appId uint) error {
app := api.appsSvc.GetAppById(appId)
if app == nil {
return errors.New("app not found")
}
var metadata map[string]interface{}
err := json.Unmarshal(app.Metadata, &metadata)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": app.ID,
}).Error("Failed to deserialize app metadata")
return err
}
if metadata["lud16"] == nil {
return errors.New("no lightning address set")
}
lud16 := metadata["lud16"].(string)
if !strings.Contains(lud16, "@") {
return errors.New("invalid lightning address")
}
address := strings.Split(lud16, "@")[0]
// Call the Alby OAuth service to delete the lightning address
err = api.albyOAuthSvc.DeleteLightningAddress(ctx, address)
if err != nil {
logger.Logger.WithError(err).Error("Failed to delete lightning address for app")
return err
}
delete(metadata, "lud16")
err = api.appsSvc.SetAppMetadata(app.ID, metadata)
if err != nil {
logger.Logger.WithError(err).Error("Failed to remove lightning address from app metadata")
return err
}
return nil
}
func (api *api) GetApp(dbApp *db.App) (*App, error) {
2024-05-30 00:06:06 +07:00
paySpecificPermission := db.AppPermission{}
appPermissions := []db.AppPermission{}
var expiresAt *time.Time
if err := api.db.Where("app_id = ?", dbApp.ID).Find(&appPermissions).Error; err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": dbApp.ID,
}).Error("Failed to list app permissions")
return nil, err
}
2024-05-30 00:06:06 +07:00
requestMethods := []string{}
for _, appPerm := range appPermissions {
expiresAt = appPerm.ExpiresAt
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
if appPerm.Scope == constants.PAY_INVOICE_SCOPE {
// find the pay_invoice-specific permissions
2024-05-30 00:06:06 +07:00
paySpecificPermission = appPerm
}
requestMethods = append(requestMethods, appPerm.Scope)
2024-05-30 00:06:06 +07:00
}
// renewsIn := ""
maxAmountSat := uint64(paySpecificPermission.MaxAmountSat)
budgetUsageMsat, err := queries.GetBudgetUsageMsat(api.db, &paySpecificPermission)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": dbApp.ID,
}).Error("Failed to get budget usage for app")
return nil, err
}
2024-05-30 00:06:06 +07:00
feat: add uncle jim internal app (#557) * feat: add uncle jim internal app * fix: wrong number in instructions * chore: simplify alby jim internal app copy * Feat: app metadata (#570) * chore: wg.Add() before go (#559) * chore: code cleanup (#558) * Update README.md Add command to make the install script executable in the instructions. * feat: add migration card in wallet screen (#555) * feat: add migration card in wallet screen * chore: transfer funds if channel exists * chore: typo * chore: improve copy * chore: add transfer funds button * fix: remove duplicate icon --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: run extra workflows on PR (#563) * chore: run extra workflows on PR * fix: pull request workflows * build(deps): bump github.com/nbd-wtf/go-nostr from 0.34.5 to 0.34.10 (#551) Bumps [github.com/nbd-wtf/go-nostr](https://github.com/nbd-wtf/go-nostr) from 0.34.5 to 0.34.10. - [Commits](https://github.com/nbd-wtf/go-nostr/compare/v0.34.5...v0.34.10) --- updated-dependencies: - dependency-name: github.com/nbd-wtf/go-nostr 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> * build(deps): bump gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0 (#552) Bumps gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0. --- updated-dependencies: - dependency-name: gopkg.in/DataDog/dd-trace-go.v1 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> * fix: do not render 0 on withdraw onchain funds page when reserve balance is 0 (#549) * chore: update fly default kill timeout to ensure app gracefully shuts down (#547) * feat: app metadata * fix(wails): parse max length in log output endpoint (#568) * fix: alby account image and name on transaction list * fix: vertically center transaction item content * fix: use slashed zero on wallet balance * chore: align app image with app name in transaction list * fix: ensure auth with correct user if refresh token expires (#572) * fix: do not allow editing name of Alby Account connection * fix: change "Create Wallet" to "Create Subaccount" * fix: subaccount copy * chore: update friends and family app icon * fix: update app store images (#574) * fix: update app store images * chore: update paper scissors hodl and zapplanner icons * chore: update lume and habla news icons * chore: resize and compress zapplanner and rps logos --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * feat: add new auto channel flow that works with existing channels (#556) * feat: add new auto channel flow that works with existing channels * chore: remove "first" from auto channel copy * feat: new transaction list item design --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: copy * fix: less detailed icon for uncle jim app * fix: shorten app description --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: René Aaron <rene@twentyuno.net> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com>
2024-09-02 17:40:34 +07:00
var metadata Metadata
if dbApp.Metadata != nil {
jsonErr := json.Unmarshal(dbApp.Metadata, &metadata)
if jsonErr != nil {
logger.Logger.WithError(jsonErr).WithFields(logrus.Fields{
"app_id": dbApp.ID,
}).Error("Failed to deserialize app metadata")
}
}
walletPubkey := api.keys.GetNostrPublicKey()
uniqueWalletPubkey := false
if dbApp.WalletPubkey != nil {
walletPubkey = *dbApp.WalletPubkey
uniqueWalletPubkey = true
}
2024-05-30 00:06:06 +07:00
response := App{
ID: dbApp.ID,
Name: dbApp.Name,
Description: dbApp.Description,
CreatedAt: dbApp.CreatedAt,
UpdatedAt: dbApp.UpdatedAt,
AppPubkey: dbApp.AppPubkey,
ExpiresAt: expiresAt,
MaxAmount: maxAmountSat,
MaxAmountSat: maxAmountSat,
MaxAmountMsat: maxAmountSat * 1000,
Scopes: requestMethods,
BudgetUsage: budgetUsageMsat / 1000,
BudgetUsageSat: budgetUsageMsat / 1000,
BudgetUsageMsat: budgetUsageMsat,
BudgetRenewal: paySpecificPermission.BudgetRenewal,
Isolated: dbApp.Isolated,
Metadata: metadata,
WalletPubkey: walletPubkey,
UniqueWalletPubkey: uniqueWalletPubkey,
LastUsedAt: dbApp.LastUsedAt,
LastSettledTransactionAt: dbApp.LastSettledTransactionAt,
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
}
if dbApp.Isolated {
balanceMsat, err := queries.GetIsolatedBalanceMsat(api.db, dbApp.ID)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": dbApp.ID,
}).Error("Failed to get isolated app balance")
return nil, err
}
response.Balance = balanceMsat
response.BalanceSat = balanceMsat / 1000
response.BalanceMsat = balanceMsat
2024-05-30 00:06:06 +07:00
}
return &response, nil
2024-05-30 00:06:06 +07:00
}
2025-07-29 20:57:18 +07:00
func (api *api) ListApps(limit uint64, offset uint64, filters ListAppsFilters, orderBy string) (*ListAppsResponse, error) {
2024-05-30 00:06:06 +07:00
// TODO: join dbApps and permissions
dbApps := []db.App{}
2025-07-29 20:57:18 +07:00
query := api.db
if filters.Name != "" {
// searching for "Damus" will return "Damus" and "Damus (1)"
// Use case-insensitive search for both SQLite and PostgreSQL
if api.db.Dialector.Name() == "postgres" {
query = query.Where("name ILIKE ?", filters.Name+"%")
} else {
query = query.Where("name LIKE ?", filters.Name+"%")
}
2025-07-29 20:57:18 +07:00
}
if filters.AppStoreAppId != "" {
query = query.Where(datatypes.JSONQuery("metadata").Equals(filters.AppStoreAppId, constants.METADATA_APPSTORE_APP_ID_KEY))
2025-07-29 20:57:18 +07:00
}
if filters.Unused {
// find unused non-subwallet apps not used in the past 60 days
query = query.Where("last_used_at IS NULL OR last_used_at < ?", time.Now().Add(-60*24*time.Hour))
}
if filters.SubWallets != nil {
if *filters.SubWallets {
query = query.Where(datatypes.JSONQuery("metadata").Equals(constants.SUBWALLET_APPSTORE_APP_ID, constants.METADATA_APPSTORE_APP_ID_KEY))
2025-07-29 20:57:18 +07:00
} else {
// exclude subwallets :scream:
if api.db.Dialector.Name() == "sqlite" {
query = query.Where(fmt.Sprintf("metadata is NULL OR JSON_EXTRACT(metadata, '$.%s') IS NULL OR JSON_EXTRACT(metadata, '$.%s') != ?", constants.METADATA_APPSTORE_APP_ID_KEY, constants.METADATA_APPSTORE_APP_ID_KEY), constants.SUBWALLET_APPSTORE_APP_ID)
} else {
query = query.Where(fmt.Sprintf("metadata IS NULL OR metadata->>'%s' IS NULL OR metadata->>'%s' != ?", constants.METADATA_APPSTORE_APP_ID_KEY, constants.METADATA_APPSTORE_APP_ID_KEY), constants.SUBWALLET_APPSTORE_APP_ID)
}
2025-07-29 20:57:18 +07:00
}
}
query = query.Order(resolveAppOrderBy(orderBy))
2025-07-29 20:57:18 +07:00
if limit == 0 {
limit = 100
}
var totalCount int64
result := query.Model(&db.App{}).Count(&totalCount)
if result.Error != nil {
logger.Logger.WithError(result.Error).Error("Failed to count DB apps")
return nil, result.Error
}
var totalBalance *int64
var totalBalanceSat *int64
if filters.SubWallets != nil && *filters.SubWallets {
totalBalanceMsat, err := queries.GetTotalSubwalletBalanceMsat(api.db)
if err != nil {
logger.Logger.WithError(err).Error("Failed to calculate total subwallet balance")
return nil, err
}
totalBalance = &totalBalanceMsat
totalBalanceSatVal := totalBalanceMsat / 1000
totalBalanceSat = &totalBalanceSatVal
}
2025-07-29 20:57:18 +07:00
query = query.Offset(int(offset)).Limit(int(limit))
err := query.Find(&dbApps).Error
if err != nil {
logger.Logger.WithError(err).Error("Failed to list apps")
return nil, err
}
2024-05-30 00:06:06 +07:00
2025-07-29 20:57:18 +07:00
appIds := []uint64{}
for _, app := range dbApps {
appIds = append(appIds, uint64(app.ID))
}
appPermissions := []db.AppPermission{}
2025-07-29 20:57:18 +07:00
err = api.db.Where("app_id IN ?", appIds).Find(&appPermissions).Error
if err != nil {
logger.Logger.WithError(err).Error("Failed to list app permissions")
return nil, err
}
2024-05-30 00:06:06 +07:00
permissionsMap := make(map[uint][]db.AppPermission)
for _, perm := range appPermissions {
2024-05-30 00:06:06 +07:00
permissionsMap[perm.AppId] = append(permissionsMap[perm.AppId], perm)
}
apiApps := []App{}
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
for _, dbApp := range dbApps {
walletPubkey := api.keys.GetNostrPublicKey()
uniqueWalletPubkey := false
if dbApp.WalletPubkey != nil {
walletPubkey = *dbApp.WalletPubkey
uniqueWalletPubkey = true
}
2024-05-30 00:06:06 +07:00
apiApp := App{
ID: dbApp.ID,
Name: dbApp.Name,
Description: dbApp.Description,
CreatedAt: dbApp.CreatedAt,
UpdatedAt: dbApp.UpdatedAt,
AppPubkey: dbApp.AppPubkey,
Isolated: dbApp.Isolated,
WalletPubkey: walletPubkey,
UniqueWalletPubkey: uniqueWalletPubkey,
LastUsedAt: dbApp.LastUsedAt,
LastSettledTransactionAt: dbApp.LastSettledTransactionAt,
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
}
if dbApp.Isolated {
balanceMsat, err := queries.GetIsolatedBalanceMsat(api.db, dbApp.ID)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": dbApp.ID,
}).Error("Failed to get isolated app balance")
return nil, err
}
apiApp.Balance = balanceMsat
apiApp.BalanceSat = balanceMsat / 1000
apiApp.BalanceMsat = balanceMsat
2024-05-30 00:06:06 +07:00
}
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
for _, appPermission := range permissionsMap[dbApp.ID] {
apiApp.Scopes = append(apiApp.Scopes, appPermission.Scope)
apiApp.ExpiresAt = appPermission.ExpiresAt
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
if appPermission.Scope == constants.PAY_INVOICE_SCOPE {
apiApp.BudgetRenewal = appPermission.BudgetRenewal
apiApp.MaxAmount = uint64(appPermission.MaxAmountSat)
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
apiApp.MaxAmountSat = uint64(appPermission.MaxAmountSat)
apiApp.MaxAmountMsat = uint64(appPermission.MaxAmountSat) * 1000
budgetUsageMsat, err := queries.GetBudgetUsageMsat(api.db, &appPermission)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"app_id": dbApp.ID,
}).Error("Failed to get budget usage for app")
return nil, err
}
apiApp.BudgetUsage = budgetUsageMsat / 1000
apiApp.BudgetUsageSat = budgetUsageMsat / 1000
apiApp.BudgetUsageMsat = budgetUsageMsat
2024-05-30 00:06:06 +07:00
}
}
feat: add uncle jim internal app (#557) * feat: add uncle jim internal app * fix: wrong number in instructions * chore: simplify alby jim internal app copy * Feat: app metadata (#570) * chore: wg.Add() before go (#559) * chore: code cleanup (#558) * Update README.md Add command to make the install script executable in the instructions. * feat: add migration card in wallet screen (#555) * feat: add migration card in wallet screen * chore: transfer funds if channel exists * chore: typo * chore: improve copy * chore: add transfer funds button * fix: remove duplicate icon --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: run extra workflows on PR (#563) * chore: run extra workflows on PR * fix: pull request workflows * build(deps): bump github.com/nbd-wtf/go-nostr from 0.34.5 to 0.34.10 (#551) Bumps [github.com/nbd-wtf/go-nostr](https://github.com/nbd-wtf/go-nostr) from 0.34.5 to 0.34.10. - [Commits](https://github.com/nbd-wtf/go-nostr/compare/v0.34.5...v0.34.10) --- updated-dependencies: - dependency-name: github.com/nbd-wtf/go-nostr 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> * build(deps): bump gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0 (#552) Bumps gopkg.in/DataDog/dd-trace-go.v1 from 1.66.0 to 1.67.0. --- updated-dependencies: - dependency-name: gopkg.in/DataDog/dd-trace-go.v1 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> * fix: do not render 0 on withdraw onchain funds page when reserve balance is 0 (#549) * chore: update fly default kill timeout to ensure app gracefully shuts down (#547) * feat: app metadata * fix(wails): parse max length in log output endpoint (#568) * fix: alby account image and name on transaction list * fix: vertically center transaction item content * fix: use slashed zero on wallet balance * chore: align app image with app name in transaction list * fix: ensure auth with correct user if refresh token expires (#572) * fix: do not allow editing name of Alby Account connection * fix: change "Create Wallet" to "Create Subaccount" * fix: subaccount copy * chore: update friends and family app icon * fix: update app store images (#574) * fix: update app store images * chore: update paper scissors hodl and zapplanner icons * chore: update lume and habla news icons * chore: resize and compress zapplanner and rps logos --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * feat: add new auto channel flow that works with existing channels (#556) * feat: add new auto channel flow that works with existing channels * chore: remove "first" from auto channel copy * feat: new transaction list item design --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: copy * fix: less detailed icon for uncle jim app * fix: shorten app description --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matjaž Lipuš <matjazl@gmail.com> Co-authored-by: BtcPins <pardus79@gmail.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> Co-authored-by: Adithya Vardhan <imadithyavardhan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: René Aaron <rene@twentyuno.net> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com>
2024-09-02 17:40:34 +07:00
var metadata Metadata
if dbApp.Metadata != nil {
jsonErr := json.Unmarshal(dbApp.Metadata, &metadata)
if jsonErr != nil {
logger.Logger.WithError(jsonErr).WithFields(logrus.Fields{
"app_id": dbApp.ID,
}).Error("Failed to deserialize app metadata")
}
apiApp.Metadata = metadata
}
2024-05-30 00:06:06 +07:00
apiApps = append(apiApps, apiApp)
}
2025-07-29 20:57:18 +07:00
return &ListAppsResponse{
Apps: apiApps,
TotalCount: uint64(totalCount),
TotalBalance: totalBalance,
TotalBalanceSat: totalBalanceSat,
TotalBalanceMsat: totalBalance,
2025-07-29 20:57:18 +07:00
}, nil
2024-05-30 00:06:06 +07:00
}
func resolveAppOrderBy(orderBy string) string {
switch orderBy {
case "created_at":
return "created_at DESC"
case "last_settled_transaction":
return "last_settled_transaction_at IS NULL, last_settled_transaction_at DESC"
default:
return "last_used_at IS NULL, last_used_at DESC"
}
}
func (api *api) ListChannels(ctx context.Context) ([]Channel, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
channels, err := lnClient.ListChannels(ctx)
if err != nil {
return nil, err
}
apiChannels := []Channel{}
for _, channel := range channels {
status := "offline"
if channel.Active {
status = "online"
} else if channel.Confirmations != nil && channel.ConfirmationsRequired != nil && *channel.ConfirmationsRequired > *channel.Confirmations {
status = "opening"
}
apiChannels = append(apiChannels, Channel{
LocalBalance: channel.LocalBalanceMsat,
LocalBalanceSat: channel.LocalBalanceMsat / 1000,
LocalBalanceMsat: channel.LocalBalanceMsat,
LocalSpendableBalance: channel.LocalSpendableBalanceMsat,
LocalSpendableBalanceSat: channel.LocalSpendableBalanceMsat / 1000,
LocalSpendableBalanceMsat: channel.LocalSpendableBalanceMsat,
RemoteBalance: channel.RemoteBalanceMsat,
RemoteBalanceSat: channel.RemoteBalanceMsat / 1000,
RemoteBalanceMsat: channel.RemoteBalanceMsat,
Id: channel.Id,
RemotePubkey: channel.RemotePubkey,
FundingTxId: channel.FundingTxId,
FundingTxVout: channel.FundingTxVout,
Active: channel.Active,
Public: channel.Public,
InternalChannel: channel.InternalChannel,
Confirmations: channel.Confirmations,
ConfirmationsRequired: channel.ConfirmationsRequired,
ForwardingFeeBaseMsat: channel.ForwardingFeeBaseMsat,
ForwardingFeeProportionalMillionths: channel.ForwardingFeeProportionalMillionths,
UnspendablePunishmentReserve: channel.UnspendablePunishmentReserveSat,
UnspendablePunishmentReserveSat: channel.UnspendablePunishmentReserveSat,
CounterpartyUnspendablePunishmentReserve: channel.CounterpartyUnspendablePunishmentReserveSat,
CounterpartyUnspendablePunishmentReserveSat: channel.CounterpartyUnspendablePunishmentReserveSat,
Error: channel.Error,
IsOutbound: channel.IsOutbound,
Status: status,
})
}
slices.SortFunc(apiChannels, func(a, b Channel) int {
// sort by channel size first
aSize := a.LocalBalance + a.RemoteBalance
bSize := b.LocalBalance + b.RemoteBalance
if aSize != bSize {
return int(bSize - aSize)
}
// then by local balance in the channel
if a.LocalBalance != b.LocalBalance {
return int(b.LocalBalance - a.LocalBalance)
}
// finally sort by channel ID to prevent sort randomly changing
return strings.Compare(b.Id, a.Id)
})
return apiChannels, nil
2024-05-30 00:06:06 +07:00
}
func (api *api) GetChannelPeerSuggestions(ctx context.Context) ([]alby.ChannelPeerSuggestion, error) {
return api.albySvc.GetChannelPeerSuggestions(ctx)
feat: stories (#2172) * feat: integrate Stories widget with backend endpoint Add stories endpoint plumbing for HTTP and Wails, wire the Home Stories card to fetch from /api/alby/stories, and keep it first in the right column. Made-with: Cursor * feat(home): story modal CTAs and preview fallback - Add contextual actions in the story dialog (update hub with version, open Alby Go in-app, install extension) keyed by kind or title - Use preview stories when the stories API request fails - Pass hub version from useInfo into the update link Made-with: Cursor * feat(stories): polish modal, drop preview fallback - Widen modal and put video edge-to-edge with overlay close button - Drop verbose header and 'Watch on YouTube' button - Remove previewStories fallback so widget hides until upstream API ships - Tighten title line-height * feat(stories): render cta from API instead of mapping by kind Move CTA copy and URLs into the API response. Hub renders story.cta directly, so adding new story types no longer requires a hub release. * chore(csp): allow cdn.getalby-assets.com in img-src * feat(stories): bump avatar size and add ring gap Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): post-review cleanups - Use react-router Link for in-tab CTA instead of plain <a>. - Drop redundant www.youtube.com from frame-src (embeds always go through nocookie). - Tighten stories endpoint status check from >= 300 to >= 400. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): address CodeRabbit feedback - Switch StoriesWidget to useSWR + swrFetcher (project convention). - Guard story iframe with isYouTubeUrl so non-YouTube urls never embed. - Wrap GetStories errors with fmt.Errorf("...: %w", err). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): drop isYouTubeUrl guard Stories are curated and always YouTube; the runtime check was redundant. CSP frame-src still constrains the iframe source. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): drop getYouTubeEmbedUrl, embed videoUrl as-is The Alby API now sends canonical youtube-nocookie embed URLs with autoplay/rel query strings (getAlby/getalby.com#2568), so the runtime normalization is no longer needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): use w-16 instead of arbitrary w-[73px] Match the avatar's size token; no magic numbers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): take videoId from API and assemble embed url locally Pairs with getAlby/getalby.com#2568. The API now sends just the YouTube videoId; the hub composes the canonical embed URL so the domain/query-string format stays in one place. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): treat 3xx as non-success, matching file convention The other status checks in alby_oauth_service.go all use >= 300; align GetStories so redirects don't slip through. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): move viewed-storage key to constants, widen story button Address review feedback: - Centralize the localStorage key for viewed stories in localStorageKeys alongside the other keys. - Widen the story button from w-16 to w-20 so "Alby Extension" fits on one line and matches the other titles. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(stories): bump story button to w-24 so titles fit one line w-20 still wrapped "Alby Extension"; w-24 fits all current titles without truncation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Revert "chore(stories): bump story button to w-24 so titles fit one line" This reverts commit 0b47438f501aee4b2a91827bec4267ac06072747. * chore(stories): split title words onto separate lines Reserve two lines for every story title so avatars align regardless of title length. * chore(stories): align homeStoriesViewed key with sibling pattern * chore(stories): fit titles on one line * chore(stories): widen story button to w-21 for one-line titles --------- Co-authored-by: René Aaron <rene@twentyuno.net> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-02 10:50:15 +02:00
}
func (api *api) GetStories(ctx context.Context) ([]alby.Story, error) {
return api.albyOAuthSvc.GetStories(ctx)
}
func (api *api) GetLSPChannelOffer(ctx context.Context) (*alby.LSPChannelOffer, error) {
return api.albyOAuthSvc.GetLSPChannelOffer(ctx)
2024-05-30 00:06:06 +07:00
}
func (api *api) ResetRouter(key string) error {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
err := lnClient.ResetRouter(key)
2024-05-30 00:06:06 +07:00
if err != nil {
return err
}
// Because the above method has to stop the node to reset the router,
// We also need to stop the lnclient and ask the user to start it again
return api.Stop()
}
func (api *api) ChangeUnlockPassword(changeUnlockPasswordRequest *ChangeUnlockPasswordRequest) error {
if api.svc.GetLNClient() == nil {
return ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
autoUnlockPassword, err := api.cfg.Get("AutoUnlockPassword", "")
if err != nil {
return err
}
if autoUnlockPassword != "" {
return errors.New("please disable auto-unlock before using this feature")
}
err = api.cfg.ChangeUnlockPassword(changeUnlockPasswordRequest.CurrentUnlockPassword, changeUnlockPasswordRequest.NewUnlockPassword)
2024-05-30 00:06:06 +07:00
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).Error("failed to change unlock password")
2024-05-30 00:06:06 +07:00
return err
}
// Because all the encrypted fields have changed
// we also need to stop the lnclient and ask the user to start it again
return api.Stop()
}
func (api *api) SetAutoUnlockPassword(unlockPassword string) error {
if api.svc.GetLNClient() == nil {
return ErrLNClientNotStarted
}
err := api.cfg.SetAutoUnlockPassword(unlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("failed to set auto unlock password")
return err
}
return nil
}
2024-05-30 00:06:06 +07:00
func (api *api) Stop() error {
if !startMutex.TryLock() {
// do not allow to stop twice in case this is somehow called twice
return errors.New("app is busy")
}
defer startMutex.Unlock()
2024-06-17 19:42:09 +07:00
logger.Logger.Info("Running Stop command")
2024-05-30 00:06:06 +07:00
if api.svc.GetLNClient() == nil {
return ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
2024-06-17 19:42:09 +07:00
// stop the lnclient, nostr relay etc.
2024-05-30 00:06:06 +07:00
// The user will be forced to re-enter their unlock password to restart the node
api.svc.StopApp()
2024-06-17 19:42:09 +07:00
return nil
2024-05-30 00:06:06 +07:00
}
func (api *api) GetNodeConnectionInfo(ctx context.Context) (*NodeConnectionInfo, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
info, err := lnClient.GetNodeConnectionInfo(ctx)
if err != nil {
return nil, err
}
return &NodeConnectionInfo{
Pubkey: info.Pubkey,
Address: info.Address,
Port: info.Port,
}, nil
2024-05-30 00:06:06 +07:00
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
func (api *api) RefundSwap(refundSwapRequest *RefundSwapRequest) error {
if api.svc.GetSwapsService() == nil {
return errors.New("SwapsService not started")
}
return api.svc.GetSwapsService().RefundSwap(refundSwapRequest.SwapId, refundSwapRequest.Address, false)
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
}
func (api *api) GetAutoSwapConfig() (*GetAutoSwapConfigResponse, error) {
if api.svc.GetSwapsService() == nil {
return nil, errors.New("SwapsService not started")
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
swapOutBalanceThresholdStr, _ := api.cfg.Get(config.AutoSwapBalanceThresholdKey, "")
swapOutAmountStr, _ := api.cfg.Get(config.AutoSwapAmountKey, "")
swapOutDestination, _ := api.cfg.Get(config.AutoSwapDestinationKey, "")
2025-04-18 16:01:38 +05:30
if xpub := api.svc.GetSwapsService().GetDecryptedAutoSwapXpub(); xpub != "" {
swapOutDestination = xpub
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
swapOutEnabled := swapOutBalanceThresholdStr != "" && swapOutAmountStr != ""
var swapOutBalanceThresholdSat, swapOutAmountSat uint64
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
if swapOutEnabled {
2025-04-18 16:01:38 +05:30
var err error
if swapOutBalanceThresholdSat, err = strconv.ParseUint(swapOutBalanceThresholdStr, 10, 64); err != nil {
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
return nil, fmt.Errorf("invalid autoswap out balance threshold: %w", err)
2025-04-18 16:01:38 +05:30
}
if swapOutAmountSat, err = strconv.ParseUint(swapOutAmountStr, 10, 64); err != nil {
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
return nil, fmt.Errorf("invalid autoswap out amount: %w", err)
2025-04-18 16:01:38 +05:30
}
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
return &GetAutoSwapConfigResponse{
Type: constants.SWAP_TYPE_OUT,
Enabled: swapOutEnabled,
BalanceThreshold: swapOutBalanceThresholdSat,
BalanceThresholdSat: swapOutBalanceThresholdSat,
SwapAmount: swapOutAmountSat,
SwapAmountSat: swapOutAmountSat,
Destination: swapOutDestination,
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
}, nil
}
func (api *api) LookupSwap(swapId string) (*LookupSwapResponse, error) {
if api.svc.GetSwapsService() == nil {
return nil, errors.New("SwapsService not started")
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
dbSwap, err := api.svc.GetSwapsService().GetSwap(swapId)
if err != nil {
logger.Logger.WithError(err).Error("failed to fetch swap info")
return nil, err
}
return toApiSwap(dbSwap), nil
}
func (api *api) ListSwaps() (*ListSwapsResponse, error) {
if api.svc.GetSwapsService() == nil {
return nil, errors.New("SwapsService not started")
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
swaps, err := api.svc.GetSwapsService().ListSwaps()
if err != nil {
return nil, err
}
apiSwaps := []Swap{}
for _, swap := range swaps {
apiSwaps = append(apiSwaps, *toApiSwap(&swap))
}
return &ListSwapsResponse{
Swaps: apiSwaps,
}, nil
}
func toApiSwap(swap *swaps.Swap) *Swap {
return &Swap{
Id: swap.SwapId,
Type: swap.Type,
State: swap.State,
Invoice: swap.Invoice,
SendAmount: swap.SendAmountSat,
SendAmountSat: swap.SendAmountSat,
ReceiveAmount: swap.ReceiveAmountSat,
ReceiveAmountSat: swap.ReceiveAmountSat,
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
PaymentHash: swap.PaymentHash,
DestinationAddress: swap.DestinationAddress,
RefundAddress: swap.RefundAddress,
LockupAddress: swap.LockupAddress,
LockupTxId: swap.LockupTxId,
ClaimTxId: swap.ClaimTxId,
AutoSwap: swap.AutoSwap,
BoltzPubkey: swap.BoltzPubkey,
CreatedAt: swap.CreatedAt.Format(time.RFC3339),
UpdatedAt: swap.UpdatedAt.Format(time.RFC3339),
2025-08-29 16:47:31 +07:00
UsedXpub: swap.UsedXpub,
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
}
}
feat: add swap out and onchain withdraw to send flow (#1582) * chore: remove balance card and fix layout * chore: change send screen styling * feat: add onchain send * feat: send exact amount in swap outs * chore: address feedback * chore: change swap transaction title and add to address * chore: refactor zero amount screen and remove confirmation * chore: add x icon to recipient in lnurl pay * chore: split onchain send page into separate components * fix: set headers and remove send layout * chore: show warning if balance is low * chore: change name to PendingPaymentAlert * chore: add increase balance warning on exceeding amount * chore: minor changes * chore: remove you'll be notified message * chore: add on-chain transactions alert on wallet page * chore: align sending and payment pending alerts * chore: make sure amount doesn't reset * fix: small onchain amount alert copy * chore: rename isSending to useExactReceiveAmount * chore: add mempool and anchor reserves alert to onchain send screen * chore: use spending alert consistently and remove red text * chore: add option to edit fee rate * fix: styling after tailwind upgrade * feat: add swap in and onchain deposit to receive flow (#1585) * chore: remove receive layout * feat: add onchain address to receive flow * feat: add receive screen to swap in and deposit bitcoin * chore: rename import to MIN_SWAP_AMOUNT * chore: add onchain button when alby account is disconnected * fix: link * chore: add OnchainAddressDisplay and use useSearchParams hook * fix: use actual swap limits from boltz api (#1598) * fix: create another invoice button * chore: use fee rate instead of network fee * fix: styling after tailwind upgrade * chore: rename swap fees to swap info * chore: use lottie loading component * chore: add mempool alert * chore: make swaps the default option for send/receive onchain --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: consistently show fee rate in sat/vByte * chore: minor copy changes --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2025-08-15 16:58:00 +05:30
func (api *api) GetSwapInInfo() (*SwapInfoResponse, error) {
if api.svc.GetSwapsService() == nil {
return nil, errors.New("SwapsService not started")
}
feat: add swap out and onchain withdraw to send flow (#1582) * chore: remove balance card and fix layout * chore: change send screen styling * feat: add onchain send * feat: send exact amount in swap outs * chore: address feedback * chore: change swap transaction title and add to address * chore: refactor zero amount screen and remove confirmation * chore: add x icon to recipient in lnurl pay * chore: split onchain send page into separate components * fix: set headers and remove send layout * chore: show warning if balance is low * chore: change name to PendingPaymentAlert * chore: add increase balance warning on exceeding amount * chore: minor changes * chore: remove you'll be notified message * chore: add on-chain transactions alert on wallet page * chore: align sending and payment pending alerts * chore: make sure amount doesn't reset * fix: small onchain amount alert copy * chore: rename isSending to useExactReceiveAmount * chore: add mempool and anchor reserves alert to onchain send screen * chore: use spending alert consistently and remove red text * chore: add option to edit fee rate * fix: styling after tailwind upgrade * feat: add swap in and onchain deposit to receive flow (#1585) * chore: remove receive layout * feat: add onchain address to receive flow * feat: add receive screen to swap in and deposit bitcoin * chore: rename import to MIN_SWAP_AMOUNT * chore: add onchain button when alby account is disconnected * fix: link * chore: add OnchainAddressDisplay and use useSearchParams hook * fix: use actual swap limits from boltz api (#1598) * fix: create another invoice button * chore: use fee rate instead of network fee * fix: styling after tailwind upgrade * chore: rename swap fees to swap info * chore: use lottie loading component * chore: add mempool alert * chore: make swaps the default option for send/receive onchain --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: consistently show fee rate in sat/vByte * chore: minor copy changes --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2025-08-15 16:58:00 +05:30
swapInInfo, err := api.svc.GetSwapsService().GetSwapInInfo()
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
if err != nil {
logger.Logger.WithError(err).Error("failed to calculate fee info")
return nil, err
}
feat: add swap out and onchain withdraw to send flow (#1582) * chore: remove balance card and fix layout * chore: change send screen styling * feat: add onchain send * feat: send exact amount in swap outs * chore: address feedback * chore: change swap transaction title and add to address * chore: refactor zero amount screen and remove confirmation * chore: add x icon to recipient in lnurl pay * chore: split onchain send page into separate components * fix: set headers and remove send layout * chore: show warning if balance is low * chore: change name to PendingPaymentAlert * chore: add increase balance warning on exceeding amount * chore: minor changes * chore: remove you'll be notified message * chore: add on-chain transactions alert on wallet page * chore: align sending and payment pending alerts * chore: make sure amount doesn't reset * fix: small onchain amount alert copy * chore: rename isSending to useExactReceiveAmount * chore: add mempool and anchor reserves alert to onchain send screen * chore: use spending alert consistently and remove red text * chore: add option to edit fee rate * fix: styling after tailwind upgrade * feat: add swap in and onchain deposit to receive flow (#1585) * chore: remove receive layout * feat: add onchain address to receive flow * feat: add receive screen to swap in and deposit bitcoin * chore: rename import to MIN_SWAP_AMOUNT * chore: add onchain button when alby account is disconnected * fix: link * chore: add OnchainAddressDisplay and use useSearchParams hook * fix: use actual swap limits from boltz api (#1598) * fix: create another invoice button * chore: use fee rate instead of network fee * fix: styling after tailwind upgrade * chore: rename swap fees to swap info * chore: use lottie loading component * chore: add mempool alert * chore: make swaps the default option for send/receive onchain --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: consistently show fee rate in sat/vByte * chore: minor copy changes --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2025-08-15 16:58:00 +05:30
return &SwapInfoResponse{
AlbyServiceFee: swapInInfo.AlbyServiceFee,
BoltzServiceFee: swapInInfo.BoltzServiceFee,
BoltzNetworkFee: swapInInfo.BoltzNetworkFeeSat,
BoltzNetworkFeeSat: swapInInfo.BoltzNetworkFeeSat,
MinAmount: swapInInfo.MinAmountSat,
MinAmountSat: swapInInfo.MinAmountSat,
MaxAmount: swapInInfo.MaxAmountSat,
MaxAmountSat: swapInInfo.MaxAmountSat,
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
}, nil
}
feat: add swap out and onchain withdraw to send flow (#1582) * chore: remove balance card and fix layout * chore: change send screen styling * feat: add onchain send * feat: send exact amount in swap outs * chore: address feedback * chore: change swap transaction title and add to address * chore: refactor zero amount screen and remove confirmation * chore: add x icon to recipient in lnurl pay * chore: split onchain send page into separate components * fix: set headers and remove send layout * chore: show warning if balance is low * chore: change name to PendingPaymentAlert * chore: add increase balance warning on exceeding amount * chore: minor changes * chore: remove you'll be notified message * chore: add on-chain transactions alert on wallet page * chore: align sending and payment pending alerts * chore: make sure amount doesn't reset * fix: small onchain amount alert copy * chore: rename isSending to useExactReceiveAmount * chore: add mempool and anchor reserves alert to onchain send screen * chore: use spending alert consistently and remove red text * chore: add option to edit fee rate * fix: styling after tailwind upgrade * feat: add swap in and onchain deposit to receive flow (#1585) * chore: remove receive layout * feat: add onchain address to receive flow * feat: add receive screen to swap in and deposit bitcoin * chore: rename import to MIN_SWAP_AMOUNT * chore: add onchain button when alby account is disconnected * fix: link * chore: add OnchainAddressDisplay and use useSearchParams hook * fix: use actual swap limits from boltz api (#1598) * fix: create another invoice button * chore: use fee rate instead of network fee * fix: styling after tailwind upgrade * chore: rename swap fees to swap info * chore: use lottie loading component * chore: add mempool alert * chore: make swaps the default option for send/receive onchain --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: consistently show fee rate in sat/vByte * chore: minor copy changes --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2025-08-15 16:58:00 +05:30
func (api *api) GetSwapOutInfo() (*SwapInfoResponse, error) {
if api.svc.GetSwapsService() == nil {
return nil, errors.New("SwapsService not started")
}
feat: add swap out and onchain withdraw to send flow (#1582) * chore: remove balance card and fix layout * chore: change send screen styling * feat: add onchain send * feat: send exact amount in swap outs * chore: address feedback * chore: change swap transaction title and add to address * chore: refactor zero amount screen and remove confirmation * chore: add x icon to recipient in lnurl pay * chore: split onchain send page into separate components * fix: set headers and remove send layout * chore: show warning if balance is low * chore: change name to PendingPaymentAlert * chore: add increase balance warning on exceeding amount * chore: minor changes * chore: remove you'll be notified message * chore: add on-chain transactions alert on wallet page * chore: align sending and payment pending alerts * chore: make sure amount doesn't reset * fix: small onchain amount alert copy * chore: rename isSending to useExactReceiveAmount * chore: add mempool and anchor reserves alert to onchain send screen * chore: use spending alert consistently and remove red text * chore: add option to edit fee rate * fix: styling after tailwind upgrade * feat: add swap in and onchain deposit to receive flow (#1585) * chore: remove receive layout * feat: add onchain address to receive flow * feat: add receive screen to swap in and deposit bitcoin * chore: rename import to MIN_SWAP_AMOUNT * chore: add onchain button when alby account is disconnected * fix: link * chore: add OnchainAddressDisplay and use useSearchParams hook * fix: use actual swap limits from boltz api (#1598) * fix: create another invoice button * chore: use fee rate instead of network fee * fix: styling after tailwind upgrade * chore: rename swap fees to swap info * chore: use lottie loading component * chore: add mempool alert * chore: make swaps the default option for send/receive onchain --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: consistently show fee rate in sat/vByte * chore: minor copy changes --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2025-08-15 16:58:00 +05:30
swapOutInfo, err := api.svc.GetSwapsService().GetSwapOutInfo()
if err != nil {
logger.Logger.WithError(err).Error("failed to calculate fee info")
return nil, err
}
feat: add swap out and onchain withdraw to send flow (#1582) * chore: remove balance card and fix layout * chore: change send screen styling * feat: add onchain send * feat: send exact amount in swap outs * chore: address feedback * chore: change swap transaction title and add to address * chore: refactor zero amount screen and remove confirmation * chore: add x icon to recipient in lnurl pay * chore: split onchain send page into separate components * fix: set headers and remove send layout * chore: show warning if balance is low * chore: change name to PendingPaymentAlert * chore: add increase balance warning on exceeding amount * chore: minor changes * chore: remove you'll be notified message * chore: add on-chain transactions alert on wallet page * chore: align sending and payment pending alerts * chore: make sure amount doesn't reset * fix: small onchain amount alert copy * chore: rename isSending to useExactReceiveAmount * chore: add mempool and anchor reserves alert to onchain send screen * chore: use spending alert consistently and remove red text * chore: add option to edit fee rate * fix: styling after tailwind upgrade * feat: add swap in and onchain deposit to receive flow (#1585) * chore: remove receive layout * feat: add onchain address to receive flow * feat: add receive screen to swap in and deposit bitcoin * chore: rename import to MIN_SWAP_AMOUNT * chore: add onchain button when alby account is disconnected * fix: link * chore: add OnchainAddressDisplay and use useSearchParams hook * fix: use actual swap limits from boltz api (#1598) * fix: create another invoice button * chore: use fee rate instead of network fee * fix: styling after tailwind upgrade * chore: rename swap fees to swap info * chore: use lottie loading component * chore: add mempool alert * chore: make swaps the default option for send/receive onchain --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> * chore: consistently show fee rate in sat/vByte * chore: minor copy changes --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2025-08-15 16:58:00 +05:30
return &SwapInfoResponse{
AlbyServiceFee: swapOutInfo.AlbyServiceFee,
BoltzServiceFee: swapOutInfo.BoltzServiceFee,
BoltzNetworkFee: swapOutInfo.BoltzNetworkFeeSat,
BoltzNetworkFeeSat: swapOutInfo.BoltzNetworkFeeSat,
MinAmount: swapOutInfo.MinAmountSat,
MinAmountSat: swapOutInfo.MinAmountSat,
MaxAmount: swapOutInfo.MaxAmountSat,
MaxAmountSat: swapOutInfo.MaxAmountSat,
2025-04-18 16:01:38 +05:30
}, nil
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
func (api *api) InitiateSwapOut(ctx context.Context, initiateSwapOutRequest *InitiateSwapRequest) (*swaps.SwapResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
}
if api.svc.GetSwapsService() == nil {
return nil, errors.New("SwapsService not started")
}
amountSat := uint64(0)
resolvedAmountSat := ResolveToSat(initiateSwapOutRequest.SwapAmountSat, nil, initiateSwapOutRequest.SwapAmount, nil)
if resolvedAmountSat != nil {
amountSat = *resolvedAmountSat
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
destination := initiateSwapOutRequest.Destination
if amountSat == 0 {
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
return nil, errors.New("invalid swap amount")
}
swapOutResponse, err := api.svc.GetSwapsService().SwapOut(amountSat, destination, false, false)
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
if err != nil {
logger.Logger.WithFields(logrus.Fields{
"amount_sat": amountSat,
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
"destination": destination,
}).WithError(err).Error("Failed to initiate swap out")
return nil, err
}
return swapOutResponse, nil
}
func (api *api) InitiateSwapIn(ctx context.Context, initiateSwapInRequest *InitiateSwapRequest) (*swaps.SwapResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
}
if api.svc.GetSwapsService() == nil {
return nil, errors.New("SwapsService not started")
}
amountSat := uint64(0)
resolvedAmountSat := ResolveToSat(initiateSwapInRequest.SwapAmountSat, nil, initiateSwapInRequest.SwapAmount, nil)
if resolvedAmountSat != nil {
amountSat = *resolvedAmountSat
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
if amountSat == 0 {
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
return nil, errors.New("invalid swap amount")
}
swapInResponse, err := api.svc.GetSwapsService().SwapIn(amountSat, false)
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
if err != nil {
logger.Logger.WithFields(logrus.Fields{
"amount_sat": amountSat,
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
}).WithError(err).Error("Failed to initiate swap in")
return nil, err
}
return swapInResponse, nil
}
func (api *api) EnableAutoSwapOut(ctx context.Context, enableAutoSwapsRequest *EnableAutoSwapRequest) error {
if api.svc.GetSwapsService() == nil {
return errors.New("SwapsService not started")
}
encryptionKey := ""
if enableAutoSwapsRequest.Destination != "" {
switch enableAutoSwapsRequest.DestinationType {
case "address":
if err := api.svc.GetSwapsService().ValidateAddress(enableAutoSwapsRequest.Destination); err != nil {
return err
}
case "xpub":
if !api.cfg.CheckUnlockPassword(enableAutoSwapsRequest.UnlockPassword) {
return errors.New("invalid unlock password")
}
if err := api.svc.GetSwapsService().ValidateXpub(enableAutoSwapsRequest.Destination); err != nil {
return err
}
encryptionKey = enableAutoSwapsRequest.UnlockPassword
default:
return errors.New("destination type must be address or xpub")
}
}
balanceThresholdSat := uint64(0)
resolvedBalanceThresholdSat := ResolveToSat(enableAutoSwapsRequest.BalanceThresholdSat, nil, enableAutoSwapsRequest.BalanceThreshold, nil)
if resolvedBalanceThresholdSat != nil {
balanceThresholdSat = *resolvedBalanceThresholdSat
}
err := api.cfg.SetUpdate(config.AutoSwapBalanceThresholdKey, strconv.FormatUint(balanceThresholdSat, 10), "")
2025-04-16 20:58:32 +05:30
if err != nil {
logger.Logger.WithError(err).Error("Failed to save autoswap balance threshold to config")
2025-04-18 12:03:45 +05:30
return err
2025-04-16 20:58:32 +05:30
}
swapAmountSat := uint64(0)
resolvedSwapAmountSat := ResolveToSat(enableAutoSwapsRequest.SwapAmountSat, nil, enableAutoSwapsRequest.SwapAmount, nil)
if resolvedSwapAmountSat != nil {
swapAmountSat = *resolvedSwapAmountSat
}
err = api.cfg.SetUpdate(config.AutoSwapAmountKey, strconv.FormatUint(swapAmountSat, 10), "")
2025-04-18 14:41:11 +05:30
if err != nil {
2025-04-28 14:20:10 +05:30
logger.Logger.WithError(err).Error("Failed to save autoswap amount to config")
2025-04-18 14:41:11 +05:30
return err
}
err = api.cfg.SetUpdate(config.AutoSwapDestinationKey, enableAutoSwapsRequest.Destination, encryptionKey)
2025-04-16 20:58:32 +05:30
if err != nil {
logger.Logger.WithError(err).Error("Failed to save autoswap destination to config")
2025-04-18 12:03:45 +05:30
return err
2025-04-16 20:58:32 +05:30
}
return api.svc.GetSwapsService().EnableAutoSwapOut(enableAutoSwapsRequest.UnlockPassword)
2025-04-16 20:58:32 +05:30
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
func (api *api) DisableAutoSwap() error {
keys := []string{config.AutoSwapBalanceThresholdKey, config.AutoSwapAmountKey, config.AutoSwapDestinationKey}
2025-04-18 16:01:38 +05:30
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
for _, key := range keys {
if err := api.cfg.SetUpdate(key, "", ""); err != nil {
logger.Logger.WithError(err).Errorf("Failed to remove autoswap config for key: %s", key)
return err
}
}
2025-04-18 16:01:38 +05:30
if api.svc.GetSwapsService() != nil {
api.svc.GetSwapsService().StopAutoSwapOut()
}
2025-04-18 16:01:38 +05:30
return nil
}
Swaps improvements (shifting to standalone page + one-time swaps) (#1371) * 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&currency selector): added all currencies to the selector * feat(Zapplanner freq&currency 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>
2025-07-10 18:36:12 +05:30
func (api *api) GetSwapMnemonic() string {
return api.keys.GetSwapMnemonic()
}
func (api *api) GetNodeStatus(ctx context.Context) (*NodeStatus, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
nodeStatus, err := lnClient.GetNodeStatus(ctx)
if err != nil {
return nil, err
}
if nodeStatus == nil {
return nil, nil
}
return toApiNodeStatus(nodeStatus), nil
}
func toApiNodeStatus(nodeStatus *lnclient.NodeStatus) *NodeStatus {
return &NodeStatus{
IsReady: nodeStatus.IsReady,
InternalNodeStatus: nodeStatus.InternalNodeStatus,
}
2024-05-30 00:06:06 +07:00
}
func (api *api) ListPeers(ctx context.Context) ([]PeerDetails, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
peers, err := lnClient.ListPeers(ctx)
if err != nil {
return nil, err
}
apiPeers := make([]PeerDetails, 0, len(peers))
for _, peer := range peers {
apiPeers = append(apiPeers, PeerDetails{
NodeId: peer.NodeId,
Address: peer.Address,
IsPersisted: peer.IsPersisted,
IsConnected: peer.IsConnected,
})
}
return apiPeers, nil
2024-05-30 00:06:06 +07:00
}
func (api *api) ConnectPeer(ctx context.Context, connectPeerRequest *ConnectPeerRequest) error {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
return lnClient.ConnectPeer(ctx, &lnclient.ConnectPeerRequest{
Pubkey: connectPeerRequest.Pubkey,
Address: connectPeerRequest.Address,
Port: connectPeerRequest.Port,
})
2024-05-30 00:06:06 +07:00
}
func (api *api) OpenChannel(ctx context.Context, openChannelRequest *OpenChannelRequest) (*OpenChannelResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
resp, err := lnClient.OpenChannel(ctx, &lnclient.OpenChannelRequest{
Pubkey: openChannelRequest.Pubkey,
AmountSats: openChannelRequest.AmountSats,
Public: openChannelRequest.Public,
})
if err != nil {
return nil, err
}
return &OpenChannelResponse{
FundingTxId: resp.FundingTxId,
}, nil
2024-05-30 00:06:06 +07:00
}
func (api *api) DisconnectPeer(ctx context.Context, peerId string) error {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return ErrLNClientNotStarted
}
2024-06-17 19:42:09 +07:00
logger.Logger.WithFields(logrus.Fields{
"peer_id": peerId,
}).Info("Disconnecting peer")
return lnClient.DisconnectPeer(ctx, peerId)
}
2024-05-30 00:06:06 +07:00
func (api *api) CloseChannel(ctx context.Context, peerId, channelId string, force bool) (*CloseChannelResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
2024-06-17 19:42:09 +07:00
logger.Logger.WithFields(logrus.Fields{
2024-05-30 00:06:06 +07:00
"peer_id": peerId,
"channel_id": channelId,
"force": force,
}).Info("Closing channel")
err := lnClient.CloseChannel(ctx, &lnclient.CloseChannelRequest{
2024-05-30 00:06:06 +07:00
NodeId: peerId,
ChannelId: channelId,
Force: force,
})
if err != nil {
return nil, err
}
return &CloseChannelResponse{}, nil
2024-05-30 00:06:06 +07:00
}
func (api *api) UpdateChannel(ctx context.Context, updateChannelRequest *UpdateChannelRequest) error {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return ErrLNClientNotStarted
}
logger.Logger.WithFields(logrus.Fields{
"request": updateChannelRequest,
}).Info("updating channel")
return lnClient.UpdateChannel(ctx, &lnclient.UpdateChannelRequest{
ChannelId: updateChannelRequest.ChannelId,
NodeId: updateChannelRequest.NodeId,
ForwardingFeeBaseMsat: updateChannelRequest.ForwardingFeeBaseMsat,
ForwardingFeeProportionalMillionths: updateChannelRequest.ForwardingFeeProportionalMillionths,
MaxDustHtlcExposureFromFeeRateMultiplier: updateChannelRequest.MaxDustHtlcExposureFromFeeRateMultiplier,
})
}
func (api *api) MakeOffer(ctx context.Context, description string) (string, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return "", ErrLNClientNotStarted
}
offer, err := lnClient.MakeOffer(ctx, description)
if err != nil {
return "", err
}
return offer, nil
}
func (api *api) GetNewOnchainAddress(ctx context.Context) (string, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return "", ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
address, err := lnClient.GetNewOnchainAddress(ctx)
2024-05-30 00:06:06 +07:00
if err != nil {
return "", err
2024-05-30 00:06:06 +07:00
}
err = api.cfg.SetUpdate(config.OnchainAddressKey, address, "")
if err != nil {
logger.Logger.WithError(err).Error("Failed to save new onchain address to config")
}
return address, nil
}
func (api *api) GetUnusedOnchainAddress(ctx context.Context) (string, error) {
if api.svc.GetLNClient() == nil {
return "", ErrLNClientNotStarted
}
2024-06-17 19:42:09 +07:00
currentAddress, err := api.cfg.Get(config.OnchainAddressKey, "")
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).Error("Failed to get current address from config")
return "", err
}
if currentAddress != "" {
// check if address has any transactions
response, err := api.RequestEsploraApi(ctx, "/address/"+currentAddress+"/txs")
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).Error("Failed to get current address transactions")
return currentAddress, nil
}
transactions, ok := response.([]interface{})
if !ok {
2024-06-17 19:42:09 +07:00
logger.Logger.WithField("response", response).Error("Failed to cast esplora address txs response", response)
return currentAddress, nil
}
if len(transactions) == 0 {
// address has not been used yet
return currentAddress, nil
}
}
newAddress, err := api.GetNewOnchainAddress(ctx)
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).Error("Failed to retrieve new onchain address")
return "", err
}
return newAddress, nil
2024-05-30 00:06:06 +07:00
}
func (api *api) SignMessage(ctx context.Context, message string) (*SignMessageResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
signature, err := lnClient.SignMessage(ctx, message)
2024-05-30 00:06:06 +07:00
if err != nil {
return nil, err
}
return &SignMessageResponse{
Message: message,
Signature: signature,
}, nil
}
func (api *api) RedeemOnchainFunds(ctx context.Context, toAddress string, amountSat uint64, feeRate *uint64, sendAll bool) (*RedeemOnchainFundsResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
txId, err := lnClient.RedeemOnchainFunds(ctx, toAddress, amountSat, feeRate, sendAll)
2024-05-30 00:06:06 +07:00
if err != nil {
return nil, err
}
return &RedeemOnchainFundsResponse{
TxId: txId,
}, nil
}
func (api *api) GetBalances(ctx context.Context) (*BalancesResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
balances, err := lnClient.GetBalances(ctx, false)
2024-05-30 00:06:06 +07:00
if err != nil {
return nil, err
}
return toApiBalances(balances), nil
}
func toApiBalances(balances *lnclient.BalancesResponse) *BalancesResponse {
totalSpendableMsat := balances.Lightning.TotalSpendableMsat
totalReceivableMsat := balances.Lightning.TotalReceivableMsat
nextMaxSpendableMsat := balances.Lightning.NextMaxSpendableMsat
nextMaxReceivableMsat := balances.Lightning.NextMaxReceivableMsat
nextMaxSpendableMPPMsat := balances.Lightning.NextMaxSpendableMPPMsat
nextMaxReceivableMPPMsat := balances.Lightning.NextMaxReceivableMPPMsat
return &BalancesResponse{
Onchain: OnchainBalanceResponse{
Spendable: balances.Onchain.SpendableSat,
SpendableSat: balances.Onchain.SpendableSat,
Total: balances.Onchain.TotalSat,
TotalSat: balances.Onchain.TotalSat,
Reserved: balances.Onchain.ReservedSat,
ReservedSat: balances.Onchain.ReservedSat,
PendingBalancesFromChannelClosures: balances.Onchain.PendingBalancesFromChannelClosuresSat,
PendingBalancesFromChannelClosuresSat: balances.Onchain.PendingBalancesFromChannelClosuresSat,
PendingBalancesDetails: toApiPendingBalanceDetails(balances.Onchain.PendingBalancesDetails),
PendingSweepBalancesDetails: toApiPendingBalanceDetails(balances.Onchain.PendingSweepBalancesDetails),
InternalBalances: balances.Onchain.InternalBalances,
},
Lightning: LightningBalanceResponse{
TotalSpendable: totalSpendableMsat,
TotalSpendableSat: totalSpendableMsat / 1000,
TotalSpendableMsat: totalSpendableMsat,
TotalReceivable: totalReceivableMsat,
TotalReceivableSat: totalReceivableMsat / 1000,
TotalReceivableMsat: totalReceivableMsat,
NextMaxSpendable: nextMaxSpendableMsat,
NextMaxSpendableSat: nextMaxSpendableMsat / 1000,
NextMaxSpendableMsat: nextMaxSpendableMsat,
NextMaxReceivable: nextMaxReceivableMsat,
NextMaxReceivableSat: nextMaxReceivableMsat / 1000,
NextMaxReceivableMsat: nextMaxReceivableMsat,
NextMaxSpendableMPP: nextMaxSpendableMPPMsat,
NextMaxSpendableMPPSat: nextMaxSpendableMPPMsat / 1000,
NextMaxSpendableMPPMsat: nextMaxSpendableMPPMsat,
NextMaxReceivableMPP: nextMaxReceivableMPPMsat,
NextMaxReceivableMPPSat: nextMaxReceivableMPPMsat / 1000,
NextMaxReceivableMPPMsat: nextMaxReceivableMPPMsat,
},
}
}
func toApiPendingBalanceDetails(details []lnclient.PendingBalanceDetails) []PendingBalanceDetails {
if details == nil {
return nil
}
apiDetails := make([]PendingBalanceDetails, 0, len(details))
for _, d := range details {
apiDetails = append(apiDetails, PendingBalanceDetails{
ChannelId: d.ChannelId,
NodeId: d.NodeId,
Amount: d.AmountSat,
AmountSat: d.AmountSat,
FundingTxId: d.FundingTxId,
FundingTxVout: d.FundingTxVout,
})
}
return apiDetails
2024-05-30 00:06:06 +07:00
}
// TODO: remove dependency on this endpoint
func (api *api) RequestMempoolApi(ctx context.Context, endpoint string) (interface{}, error) {
2024-06-17 19:42:09 +07:00
url := api.cfg.GetEnv().MempoolApi + endpoint
2024-05-30 00:06:06 +07:00
client := http.Client{
Timeout: time.Second * 10,
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
2024-05-30 00:06:06 +07:00
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).WithFields(logrus.Fields{
2024-05-30 00:06:06 +07:00
"url": url,
}).Error("Failed to create http request")
return nil, err
}
res, err := client.Do(req)
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).WithFields(logrus.Fields{
2024-05-30 00:06:06 +07:00
"url": url,
}).Error("Failed to send request")
return nil, err
}
defer res.Body.Close()
body, readErr := io.ReadAll(res.Body)
if readErr != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).WithFields(logrus.Fields{
2024-05-30 00:06:06 +07:00
"url": url,
}).Error("Failed to read response body")
return nil, errors.New("failed to read response body")
}
if res.StatusCode != http.StatusOK {
logger.Logger.WithFields(logrus.Fields{
"endpoint": endpoint,
"status_code": res.StatusCode,
"body": string(body),
}).Error("Mempool endpoint returned non-success code")
return nil, fmt.Errorf("mempool endpoint returned non-success code: %s", string(body))
}
2024-05-30 00:06:06 +07:00
var jsonContent interface{}
jsonErr := json.Unmarshal(body, &jsonContent)
if jsonErr != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(jsonErr).WithFields(logrus.Fields{
2024-05-30 00:06:06 +07:00
"url": url,
}).Error("Failed to deserialize json")
return nil, fmt.Errorf("failed to deserialize json %s %s", url, string(body))
}
return jsonContent, nil
}
func (api *api) GetInfo(ctx context.Context) (*InfoResponse, error) {
info := InfoResponse{}
if api.nodeMigrationFileCreated.Load() {
// the hub is halted and the database is closed after a migration file
// is created, so return a minimal response without reading any config
// or node state; the frontend only needs the flag to keep showing the
// migration success page
info.NodeMigrationFileCreated = true
info.SetupCompleted = true
info.Version = version.Tag
info.Relays = []InfoResponseRelay{}
return &info, nil
}
2024-06-17 19:42:09 +07:00
backendType, _ := api.cfg.Get("LNBackendType", "")
ldkVssEnabled, _ := api.cfg.Get("LdkVssEnabled", "")
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
jitChannelsEnabled, _ := api.cfg.Get("JitChannelsEnabled", "")
autoUnlockPassword, _ := api.cfg.Get("AutoUnlockPassword", "")
setupCompleted, err := api.cfg.SetupCompleted()
if err != nil {
logger.Logger.WithError(err).Error("Failed to check if setup is completed")
return nil, err
}
info.SetupCompleted = setupCompleted
info.Currency = api.cfg.GetCurrency()
info.BitcoinDisplayFormat = api.cfg.GetBitcoinDisplayFormat()
info.StartupState = api.svc.GetStartupState()
if api.startupError != nil {
info.StartupError = api.startupError.Error()
info.StartupErrorTime = api.startupErrorTime
}
lnClient := api.svc.GetLNClient()
info.Running = lnClient != nil
info.NodeMigrationFileCreated = api.nodeMigrationFileCreated.Load()
2024-05-30 00:06:06 +07:00
info.BackendType = backendType
2024-06-17 19:42:09 +07:00
info.AlbyAuthUrl = api.albyOAuthSvc.GetAuthUrl()
info.OAuthRedirect = !api.cfg.GetEnv().IsDefaultClientId()
2024-06-22 12:22:01 +07:00
info.Version = version.Tag
info.EnableAdvancedSetup = api.cfg.GetEnv().EnableAdvancedSetup
info.HideUpdateBanner = api.cfg.GetEnv().HideUpdateBanner
info.LdkVssEnabled = ldkVssEnabled == "true"
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
info.JitChannelsEnabled = jitChannelsEnabled != "false"
info.VssSupported = backendType == config.LDKBackendType && api.cfg.GetEnv().LDKVssUrl != ""
info.LdkVssUrl = api.cfg.GetEnv().LDKVssUrl
info.DatabaseType = api.db.Dialector.Name()
info.SupportsBolt12 = backendType == config.LDKBackendType || backendType == config.CLNBackendType
info.AutoUnlockPasswordEnabled = autoUnlockPassword != ""
info.AutoUnlockPasswordSupported = api.cfg.GetEnv().IsDefaultClientId()
info.Relays = []InfoResponseRelay{}
for _, relayStatus := range api.svc.GetRelayStatuses() {
info.Relays = append(info.Relays, InfoResponseRelay{
Url: relayStatus.Url,
Online: relayStatus.Online,
})
}
info.MempoolUrl = api.cfg.GetMempoolUrl()
info.AlbyAccountConnected = api.albyOAuthSvc.IsConnected(ctx)
albyUserIdentifier, err := api.albyOAuthSvc.GetUserIdentifier()
2024-05-30 00:06:06 +07:00
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).Error("Failed to get alby user identifier")
2024-05-30 00:06:06 +07:00
return nil, err
}
info.AlbyUserIdentifier = albyUserIdentifier
if lnClient != nil {
nodeInfo, err := lnClient.GetInfo(ctx)
2024-05-30 00:06:06 +07:00
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).Error("Failed to get nodeInfo")
2024-05-30 00:06:06 +07:00
return nil, err
}
info.Network = nodeInfo.Network
if backendType == config.LDKBackendType {
// Only LDK supports this right now. Using a local interface here
// so we don't have to bloat the main LNClient interface for everyone else.
type chainSourceProvider interface {
GetChainDataSource() (string, string)
}
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
type lsps2SourceProvider interface {
GetLiquiditySourceLsps2() string
}
type lsps2MinPaymentSizeProvider interface {
GetLiquiditySourceLsps2MinPaymentSizeMsat() *uint64
}
type lsps2MaxPaymentSizeProvider interface {
GetLiquiditySourceLsps2MaxPaymentSizeMsat() *uint64
}
if ldkService, ok := api.svc.GetLNClient().(chainSourceProvider); ok {
info.ChainDataSourceType, info.ChainDataSourceAddress = ldkService.GetChainDataSource()
}
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
if ldkService, ok := api.svc.GetLNClient().(lsps2SourceProvider); ok {
info.JitChannelsLiquiditySource = ldkService.GetLiquiditySourceLsps2()
}
if ldkService, ok := api.svc.GetLNClient().(lsps2MinPaymentSizeProvider); ok {
info.JitChannelsMinPaymentSizeMsat = ldkService.GetLiquiditySourceLsps2MinPaymentSizeMsat()
}
if ldkService, ok := api.svc.GetLNClient().(lsps2MaxPaymentSizeProvider); ok {
info.JitChannelsMaxPaymentSizeMsat = ldkService.GetLiquiditySourceLsps2MaxPaymentSizeMsat()
}
}
2024-05-30 00:06:06 +07:00
}
2024-06-17 19:42:09 +07:00
info.NextBackupReminder, _ = api.cfg.Get("NextBackupReminder", "")
2024-05-30 00:06:06 +07:00
info.NodeAlias, _ = api.cfg.Get("NodeAlias", "")
2024-05-30 00:06:06 +07:00
return &info, nil
}
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
func (api *api) setCurrency(currency string) error {
if currency == "" {
return fmt.Errorf("currency value cannot be empty")
}
err := api.cfg.SetCurrency(currency)
if err != nil {
logger.Logger.WithError(err).Error("Failed to update currency")
return err
}
return nil
}
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
func (api *api) setBitcoinDisplayFormat(format string) error {
if format != constants.BITCOIN_DISPLAY_FORMAT_SATS && format != constants.BITCOIN_DISPLAY_FORMAT_BIP177 {
return fmt.Errorf("bitcoin display format must be '%s' or '%s'", constants.BITCOIN_DISPLAY_FORMAT_SATS, constants.BITCOIN_DISPLAY_FORMAT_BIP177)
}
err := api.cfg.SetBitcoinDisplayFormat(format)
if err != nil {
logger.Logger.WithError(err).Error("Failed to update bitcoin display format")
return err
}
return nil
}
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
func (api *api) setJitChannelsEnabled(enabled bool) error {
value := "true"
if !enabled {
value = "false"
}
err := api.cfg.SetUpdate("JitChannelsEnabled", value, "")
if err != nil {
logger.Logger.WithError(err).Error("Failed to update JIT channels setting")
return err
}
return nil
}
func (api *api) UpdateSettings(updateSettingsRequest *UpdateSettingsRequest) error {
if updateSettingsRequest.Currency != "" {
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
err := api.setCurrency(updateSettingsRequest.Currency)
if err != nil {
return fmt.Errorf("failed to set currency: %w", err)
}
}
if updateSettingsRequest.BitcoinDisplayFormat != "" {
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
err := api.setBitcoinDisplayFormat(updateSettingsRequest.BitcoinDisplayFormat)
if err != nil {
return fmt.Errorf("failed to set bitcoin display format: %w", err)
}
}
feat: just in time channels with lsps2 (#2275) * 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>
2026-06-10 09:47:07 +02:00
if updateSettingsRequest.JitChannelsEnabled != nil {
err := api.setJitChannelsEnabled(*updateSettingsRequest.JitChannelsEnabled)
if err != nil {
return fmt.Errorf("failed to set JIT channels setting: %w", err)
}
}
return nil
}
func (api *api) SetNodeAlias(nodeAlias string) error {
err := api.cfg.SetUpdate("NodeAlias", nodeAlias, "")
if err != nil {
logger.Logger.WithError(err).Error("Failed to save node alias to config")
return err
}
return nil
}
func (api *api) GetMnemonic(unlockPassword string) (*MnemonicResponse, error) {
if !api.cfg.CheckUnlockPassword(unlockPassword) {
return nil, fmt.Errorf("wrong password")
}
mnemonic, err := api.cfg.Get("Mnemonic", unlockPassword)
if err != nil {
return nil, fmt.Errorf("failed to fetch encryption key: %w", err)
}
resp := MnemonicResponse{
Mnemonic: mnemonic,
}
return &resp, nil
2024-05-30 00:06:06 +07:00
}
func (api *api) SetNextBackupReminder(backupReminderRequest *BackupReminderRequest) error {
err := api.cfg.SetUpdate("NextBackupReminder", backupReminderRequest.NextBackupReminder, "")
if err != nil {
logger.Logger.WithError(err).Error("Failed to save next backup reminder to config")
}
2024-05-30 00:06:06 +07:00
return nil
}
var startMutex sync.Mutex
func (api *api) Start(startRequest *StartRequest) {
api.startupError = nil
err := api.startInternal(startRequest)
if err != nil {
logger.Logger.WithError(err).Error("Failed to start node")
api.startupError = err
api.startupErrorTime = time.Now()
}
}
func (api *api) startInternal(startRequest *StartRequest) (err error) {
if !startMutex.TryLock() {
// do not allow to start twice in case this is somehow called twice
return errors.New("app is busy")
}
defer startMutex.Unlock()
2024-05-30 00:06:06 +07:00
return api.svc.StartApp(startRequest.UnlockPassword)
}
func (api *api) Setup(ctx context.Context, setupRequest *SetupRequest) error {
if !startMutex.TryLock() {
// do not allow to start twice in case this is somehow called twice
return errors.New("app is busy")
}
defer startMutex.Unlock()
2024-05-30 00:06:06 +07:00
info, err := api.GetInfo(ctx)
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithError(err).Error("Failed to get info")
2024-05-30 00:06:06 +07:00
return err
}
if info.SetupCompleted {
2024-06-17 19:42:09 +07:00
logger.Logger.Error("Cannot re-setup node")
2024-05-30 00:06:06 +07:00
return errors.New("setup already completed")
}
if setupRequest.UnlockPassword == "" {
return errors.New("no unlock password provided")
}
fix: bark onboarding, migration messaging and receive settlement for bark 0.6.0 (#2523) * fix: update bark onboarding and backup messaging for seed-based recovery Since bark 0.6.0, offchain funds are recoverable from the mnemonic alone via the seed-derived recovery mailbox. Remove the outdated warnings that the recovery phrase is not sufficient, show the standard recovery guidance for bark during onboarding, and expose the seed-recovery scan result as a 'recoveryreport' custom node command so users migrating to a new device can verify their funds were restored. Closes #2512 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: settle bark lightning receives in the new delivering state bark 0.6.0 added a 'delivering' receive state between preimage reveal and settlement. The receive claim handler only treated 'preimage-revealed' and 'settled' as paid, so claimed receives were published without a preimage and the transactions service rejected the settlement ('no preimage in payment'), leaving paid invoices pending forever. Recognize all states at or past preimage reveal via a receiveIsPaid helper (a positive allowlist, so an unknown future state degrades to pending rather than falsely settled), only mark the transaction settled when the preimage is present, and prefer bark's own settled_at timestamp when available. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: replace import channels checkbox with LDK-specific warning The 'I don't have another Alby Hub to migrate or open channels' checkbox on the import recovery phrase screen only applied to LDK but was required for every backend, and its claim that channel funds are always lost is wrong when dynamic channel backups (VSS) are enabled. Remove the checkbox and the channels bullet from the import screen and show the caveat on the Security & Recovery page instead, only when a mnemonic was imported and the LDK backend was chosen. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-08 16:39:02 +07:00
// Bark and Cashu both store wallet state on local disk, so they cannot
// run in environments without persistent volumes (e.g. Alby Cloud). Bark
// can recover spendable VTXOs from the mnemonic alone, but in-flight
// payment checkpoints and wallet metadata are local-only, so persistent
// storage is still required. The default OAuth client ID identifies a
// local / self-hosted deployment.
if !api.cfg.GetEnv().IsDefaultClientId() {
switch setupRequest.LNBackendType {
case config.BarkBackendType, config.CashuBackendType:
return fmt.Errorf("%s backend is not supported in this environment (no persistent storage)", setupRequest.LNBackendType)
}
}
err = api.cfg.SaveUnlockPasswordCheck(setupRequest.UnlockPassword)
if err != nil {
return err
}
2024-05-30 00:06:06 +07:00
// update next backup reminder
err = api.cfg.SetUpdate("NextBackupReminder", setupRequest.NextBackupReminder, "")
if err != nil {
logger.Logger.WithError(err).Error("Failed to save next backup reminder")
}
2024-05-30 00:06:06 +07:00
// only update non-empty values
if setupRequest.LNBackendType != "" {
err = api.cfg.SetUpdate("LNBackendType", setupRequest.LNBackendType, "")
if err != nil {
logger.Logger.WithError(err).Error("Failed to save backend type")
return err
}
2024-05-30 00:06:06 +07:00
}
if setupRequest.Mnemonic != "" {
err = api.cfg.SetUpdate("Mnemonic", setupRequest.Mnemonic, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save encrypted mnemonic")
return err
}
2024-05-30 00:06:06 +07:00
}
if setupRequest.LNDAddress != "" {
err = api.cfg.SetUpdate("LNDAddress", setupRequest.LNDAddress, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save lnd address")
return err
}
2024-05-30 00:06:06 +07:00
}
if setupRequest.LNDCertFile != "" {
// The file path is provided by the (unauthenticated) setup request, so
// only persist the content if it parses as a certificate. Storing the
// re-encoded certificate(s) guarantees nothing but the parsed structure
// reaches the database - e.g. a private key bundled in the same PEM file
// is dropped rather than persisted.
certHex, err := readAndCanonicalizeLNDCert(setupRequest.LNDCertFile)
if err != nil {
// Return a generic error and log the detail server-side so the
// response is not a file existence/readability oracle.
logger.Logger.WithError(err).Error("Failed to process lnd cert file")
return errors.New("invalid LND certificate file")
}
err = api.cfg.SetUpdate("LNDCertHex", certHex, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save lnd cert hex")
return err
}
2024-05-30 00:06:06 +07:00
}
if setupRequest.LNDMacaroonFile != "" {
// The file path is provided by the (unauthenticated) setup request, so
// only persist the content if it parses as a macaroon. Storing the
// re-marshalled macaroon guarantees only the parsed structure reaches
// the database.
macaroonHex, err := readAndCanonicalizeLNDMacaroon(setupRequest.LNDMacaroonFile)
if err != nil {
// Return a generic error and log the detail server-side so the
// response is not a file existence/readability oracle.
logger.Logger.WithError(err).Error("Failed to process lnd macaroon file")
return errors.New("invalid LND macaroon file")
}
err = api.cfg.SetUpdate("LNDMacaroonHex", macaroonHex, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save lnd macaroon hex")
return err
}
2024-05-30 00:06:06 +07:00
}
if setupRequest.PhoenixdAddress != "" {
err = api.cfg.SetUpdate("PhoenixdAddress", setupRequest.PhoenixdAddress, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save phoenix address")
return err
}
}
if setupRequest.PhoenixdAuthorization != "" {
err = api.cfg.SetUpdate("PhoenixdAuthorization", setupRequest.PhoenixdAuthorization, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save phoenix auth")
return err
}
}
2024-06-14 19:12:22 +03:00
if setupRequest.CashuMintUrl != "" {
err = api.cfg.SetUpdate("CashuMintUrl", setupRequest.CashuMintUrl, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save cashu mint url")
return err
}
2024-06-14 19:12:22 +03:00
}
feat: add CLN backend (#2026) * feat: add CLN as a lnclient backend * feat: add hold invoice support for CLN backend * fix: reduce CLN form to just addresses and lightning dir * feat: add README for CLN grpc go code generation * fix: cln backend does not support keysend with given preimages * fix: hold invoice notifications in CLN backend * fix: remove dead code in CLN backend from ListTransactions * fix: env example CLN_ADDRESS_HOLD with different port to show it's a different service * fix: cleanup of CLN ressources in all cases * fix: cln backend's GetNetworkGraph only fetches specified nodeId's * fix: cln backend: only advertise hold methods for nip47 if hold plugin enabled * fix: cln's Shutdown should not stop CLN itself * fix: relax the LND README line regarding env configuration * fix: more nil checks in clnInvoiceToTransaction * fix: prevent feerate overflow in CLN's RedeemOnchainFunds * fix: don't access nil errors for empty reponses of certain CLN methods * fix: nil instead of empty string in cln's GetNetworkGraph return types * fix: nil checks for created_at in cln's clnInvoiceToTransaction * fix: set minimum tls version to 1.2 for cln backend grpc connections * fix: cln's subscribeOpenHoldInvoices doesn't give up as fast * fix: deduplicate graph edges in cln's GetNetworkGraph * fix: print the error string, not pointer address, in cln's ListChannels * fix: remove cln's ListTransactions completely * fix: use ListPeers instead of ListPeerChannels in cln's ListPeers * feat: cln's MakeHoldInvoice supports minCltvExpiryDelta * fix: use named return err in NewCLNService * fix: cln listpeers log message * fix: incorrect import * fix: compile errors after rename --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2026-05-03 21:36:13 +02:00
if setupRequest.CLNAddress != "" {
err = api.cfg.SetUpdate("CLNAddress", setupRequest.CLNAddress, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save CLN address")
return err
}
}
if setupRequest.CLNLightningDir != "" {
// The directory path is provided by the (unauthenticated) setup request.
// Validate that it holds the expected CLN TLS credentials before saving,
// so the path cannot be used as an existence/readability oracle for
// arbitrary directories (the failure otherwise surfaces via startupError
// on the anonymous /api/info response).
if err := validateCLNLightningDir(setupRequest.CLNLightningDir, setupRequest.CLNAddressHold != ""); err != nil {
logger.Logger.WithError(err).Error("Failed to validate CLN lightning directory")
return errors.New("invalid CLN lightning directory")
}
feat: add CLN backend (#2026) * feat: add CLN as a lnclient backend * feat: add hold invoice support for CLN backend * fix: reduce CLN form to just addresses and lightning dir * feat: add README for CLN grpc go code generation * fix: cln backend does not support keysend with given preimages * fix: hold invoice notifications in CLN backend * fix: remove dead code in CLN backend from ListTransactions * fix: env example CLN_ADDRESS_HOLD with different port to show it's a different service * fix: cleanup of CLN ressources in all cases * fix: cln backend's GetNetworkGraph only fetches specified nodeId's * fix: cln backend: only advertise hold methods for nip47 if hold plugin enabled * fix: cln's Shutdown should not stop CLN itself * fix: relax the LND README line regarding env configuration * fix: more nil checks in clnInvoiceToTransaction * fix: prevent feerate overflow in CLN's RedeemOnchainFunds * fix: don't access nil errors for empty reponses of certain CLN methods * fix: nil instead of empty string in cln's GetNetworkGraph return types * fix: nil checks for created_at in cln's clnInvoiceToTransaction * fix: set minimum tls version to 1.2 for cln backend grpc connections * fix: cln's subscribeOpenHoldInvoices doesn't give up as fast * fix: deduplicate graph edges in cln's GetNetworkGraph * fix: print the error string, not pointer address, in cln's ListChannels * fix: remove cln's ListTransactions completely * fix: use ListPeers instead of ListPeerChannels in cln's ListPeers * feat: cln's MakeHoldInvoice supports minCltvExpiryDelta * fix: use named return err in NewCLNService * fix: cln listpeers log message * fix: incorrect import * fix: compile errors after rename --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
2026-05-03 21:36:13 +02:00
err = api.cfg.SetUpdate("CLNLightningDir", setupRequest.CLNLightningDir, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save CLN Lightning directory path")
return err
}
}
if setupRequest.CLNAddressHold != "" {
err = api.cfg.SetUpdate("CLNAddressHold", setupRequest.CLNAddressHold, setupRequest.UnlockPassword)
if err != nil {
logger.Logger.WithError(err).Error("Failed to save cln hold plugin address")
return err
}
}
2024-05-30 00:06:06 +07:00
return nil
}
// readAndCanonicalizeLNDCert reads the LND TLS certificate at the given path,
// validates that it contains at least one parseable certificate, and returns
// the hex-encoded re-encoding of only the parsed certificate(s). Any non
// CERTIFICATE PEM blocks (e.g. a bundled private key) are discarded so they are
// never persisted. Callers must not reflect the returned error to the client.
func readAndCanonicalizeLNDCert(path string) (string, error) {
raw, err := os.ReadFile(path)
if err != nil {
return "", fmt.Errorf("failed to read LND cert file: %w", err)
}
var canonical []byte
rest := raw
for {
var block *pem.Block
block, rest = pem.Decode(rest)
if block == nil {
break
}
if block.Type != "CERTIFICATE" {
continue
}
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return "", fmt.Errorf("failed to parse LND certificate: %w", err)
}
canonical = append(canonical, pem.EncodeToMemory(&pem.Block{
Type: "CERTIFICATE",
Bytes: cert.Raw,
})...)
}
if len(canonical) == 0 {
return "", errors.New("no valid certificate found in LND cert file")
}
return hex.EncodeToString(canonical), nil
}
// readAndCanonicalizeLNDMacaroon reads the LND macaroon at the given path,
// validates that it is a well-formed macaroon, and returns the hex-encoded
// re-marshalling so that only the parsed structure is persisted. Callers must
// not reflect the returned error to the client.
func readAndCanonicalizeLNDMacaroon(path string) (string, error) {
raw, err := os.ReadFile(path)
if err != nil {
return "", fmt.Errorf("failed to read LND macaroon file: %w", err)
}
mac := &macaroon.Macaroon{}
if err := mac.UnmarshalBinary(raw); err != nil {
return "", fmt.Errorf("failed to parse LND macaroon: %w", err)
}
canonical, err := mac.MarshalBinary()
if err != nil {
return "", fmt.Errorf("failed to marshal LND macaroon: %w", err)
}
return hex.EncodeToString(canonical), nil
}
// validateCLNLightningDir checks that the given directory holds the CLN TLS
// credentials that will later be loaded at connect time (ca.pem, client.pem,
// client-key.pem), for each gRPC server name the config will use. This mirrors
// the parses performed by the CLN client's loadTLSCredentials so a directory
// that passes here is one CLN can actually use. Callers must not reflect the
// returned error to the client.
func validateCLNLightningDir(lightningDir string, hold bool) error {
// "cln" reads the directory directly; other server names are joined as a
// subdirectory, matching loadTLSCredentials in lnclient/cln.
serverNames := []string{"cln"}
if hold {
serverNames = append(serverNames, "hold")
}
for _, serverName := range serverNames {
dir := lightningDir
if serverName != "cln" {
dir = filepath.Join(dir, serverName)
}
caPEM, err := os.ReadFile(filepath.Join(dir, "ca.pem"))
if err != nil {
return fmt.Errorf("failed to read CLN CA cert (%s): %w", serverName, err)
}
if !x509.NewCertPool().AppendCertsFromPEM(caPEM) {
return fmt.Errorf("failed to parse CLN CA cert (%s)", serverName)
}
if _, err := tls.LoadX509KeyPair(filepath.Join(dir, "client.pem"), filepath.Join(dir, "client-key.pem")); err != nil {
return fmt.Errorf("failed to load CLN client cert/key (%s): %w", serverName, err)
}
}
return nil
}
func (api *api) GetWalletCapabilities(ctx context.Context) (*WalletCapabilitiesResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
}
methods := lnClient.GetSupportedNIP47Methods()
notificationTypes := lnClient.GetSupportedNIP47NotificationTypes()
scopes, err := permissions.RequestMethodsToScopes(methods)
if err != nil {
return nil, err
}
if len(notificationTypes) > 0 {
Feat: dynamic budgets (#226) * feat: add transactions table * feat: add transactions service with makeinvoice method * feat: use internal transactions WIP * feat: check unsettled transactions * feat: use transactions service in nip47 package WIP * feat: use transactions service in NIP-47 handlers * fix: transaction list colors * fix: tests * chore: remove old payments table * fix: return budget usage as sats * feat: use internal transactions table for keysend payments * feat: consume nwc_payment_received event in transaction service (WIP) * feat: update existing transaction from nwc_payment_received event in transactions service * feat: update existing transaction from nwc_payment_sent event in transactions service * feat: handle async payment failed events in transactions service * fix: tests * feat: correctly implement NIP-47 NOT_FOUND error code * feat: intercept self payments * feat: isolated balance and visibility * feat: validate keysend payment does not exceed app internal balance * feat: budget check in transactions service, correctly pass payment errors to NIP-47 response also reduce query duplication * fix: order transactions when looking up transaction * feat: add fee reserves to unsettled outgoing transactions * chore: rename app permissions max amount field * chore: rename transaction amount values to be clearly millisats * chore: merge balance type and visibility into isolated property on apps table * chore: move duplicated permission check from nip-47 controllers to handler * fix: app name in transaction list * Feat: permissions revamp v2 (#273) * feat: revamp permissions component * chore: changes * chore: changes * chore: add view mode for show app screen * chore: further changes * feat: new illustration for linking account (#254) * feat: new illustration for linking account * fix: update paths * fix: icon props (#256) * fix: use date from frontend * chore: add expiryselect component * chore: further changes * chore: further changes * chore: add date-fns for date picker * chore: further changes * chore: further changes * fix: add central LDK gossip node to help gossip new public channels (#262) * fix: make dialog responsive (#258) * chore: further changes * typo * chore: spacing issues * chore: use scopes from capabilities * chore: change scope type descriptions * chore: styling fixes * chore: fix typings * chore: budget renewal component * fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing * chore: remove unnecessary dark classes (#255) * fix: links to open first channel in sidebar and onboarding checklist (#268) * feat: improve migrate node UI (#269) * fix: migrate node copy (#270) * fix: stop nostr when app is shutdown and use context to stop lnclient (#271) * fix: permissions revamp WIP * feat: basic isolated apps UI * fix: new app connection, edit app connection, deep linking --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com> * fix: make transactions table ID autoincrement * fix: do not send unrelated notifications to isolated apps * fix: nip-47 notifications not receiving updated transaction state * fix: migrate existing tables to have autoincrementing primary keys (#274) * fix: migrate existing tables to have autoincrementing primary keys * fix: recreate request and response event tables after apps * fix: remove null from request_events app_id * fix: do not crash when reloading app created page * chore: update pragma commands, add busy_timeout * fix: remove unnecessary migration of user_configs table * chore: update comment on autoincrement migration * feat: sqlite database config improvements * fix: autoincrement migration to delete unlinked app permissions * chore: update tests for dynamic budgets (WIP) * fix: get balance tests * chore: add extra event handler tests * chore: add extra event handler test * chore: add extra multi_pay_invoice tests * chore: transactions service tests (WIP) * chore: add transactions service payment tests * chore: add tests for self payments * fix: notifications tests * chore: add notifications tests for transactions service * chore: add fee reserve tests for transactions service * chore: add list transactions tests * chore: add keysend tests for transactions service * feat: subscribe for payments and invoices (#281) * fix: db transaction should be passed as pointer * feat(lnd): subscribe for payments and invoices * chore: rearrange check for settled * chore: remove TODO * chore: retry on error and add select * chore: publish payment failed event * chore: use json logging * feat: add lnd notification types * chore: remove sleep * fix: incorrect key on transaction list items * fix: test * fix: disable isolated app type on non-supported backends --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com> Co-authored-by: René Aaron <100827540+reneaaron@users.noreply.github.com> Co-authored-by: Michael Bumann <hello@michaelbumann.com>
2024-07-19 23:30:22 +07:00
scopes = append(scopes, constants.NOTIFICATIONS_SCOPE)
}
return &WalletCapabilitiesResponse{
Methods: methods,
NotificationTypes: notificationTypes,
Scopes: scopes,
}, nil
}
func (api *api) MigrateNodeStorage(ctx context.Context, to string) error {
if api.svc.GetLNClient() == nil {
return ErrLNClientNotStarted
}
if to != "VSS" {
return fmt.Errorf("migration type not supported: %s", to)
}
ldkVssEnabled, err := api.cfg.Get("LdkVssEnabled", "")
if err != nil {
return err
}
if ldkVssEnabled == "true" {
return errors.New("VSS already enabled")
}
if api.cfg.GetEnv().LDKVssUrl == "" {
return errors.New("no VSS URL set")
}
api.cfg.SetUpdate("LdkVssEnabled", "true", "")
api.cfg.SetUpdate("LdkMigrateStorage", "VSS", "")
return api.Stop()
}
func (api *api) GetNetworkGraph(ctx context.Context, nodeIds []string) (NetworkGraphResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
return lnClient.GetNetworkGraph(ctx, nodeIds)
2024-05-30 00:06:06 +07:00
}
func (api *api) SyncWallet() error {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
lnClient.UpdateLastWalletSyncRequest()
2024-05-30 00:06:06 +07:00
return nil
}
func (api *api) ListOnchainTransactions(ctx context.Context) ([]OnchainTransaction, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
}
transactions, err := lnClient.ListOnchainTransactions(ctx)
if err != nil {
return nil, err
}
apiTransactions := make([]OnchainTransaction, 0, len(transactions))
for _, t := range transactions {
apiTransactions = append(apiTransactions, OnchainTransaction{
AmountSat: t.AmountSat,
CreatedAt: t.CreatedAt,
State: t.State,
Type: t.Type,
NumConfirmations: t.NumConfirmations,
TxId: t.TxId,
})
}
return apiTransactions, nil
}
2024-05-30 00:06:06 +07:00
func (api *api) GetLogOutput(ctx context.Context, logType string, getLogRequest *GetLogOutputRequest) (*GetLogOutputResponse, error) {
var err error
var logData []byte
if logType == LogTypeNode {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
2024-05-30 00:06:06 +07:00
}
logData, err = lnClient.GetLogOutput(ctx, getLogRequest.MaxLen)
2024-05-30 00:06:06 +07:00
if err != nil {
return nil, err
}
} else if logType == LogTypeApp {
2024-06-17 19:42:09 +07:00
logFileName := logger.GetLogFilePath()
if logFileName == "" {
logData = []byte("file log is disabled")
} else {
logData, err = utils.ReadFileTail(logFileName, getLogRequest.MaxLen)
if err != nil {
return nil, err
}
2024-05-30 00:06:06 +07:00
}
} else {
return nil, fmt.Errorf("invalid log type: '%s'", logType)
}
return &GetLogOutputResponse{Log: string(logData)}, nil
}
func (api *api) Health(ctx context.Context) (*HealthResponse, error) {
var alarms []HealthAlarm
albyInfo, err := api.albySvc.GetInfo(ctx)
if err != nil {
return nil, err
}
if !albyInfo.Healthy {
alarms = append(alarms, NewHealthAlarm(HealthAlarmKindAlbyService, albyInfo.Incidents))
}
relayStatuses := api.svc.GetRelayStatuses()
if len(relayStatuses) > 0 {
isAnyNostrRelayOffline := false
offlineRelayUrls := []string{}
for _, relayStatus := range relayStatuses {
if !relayStatus.Online {
isAnyNostrRelayOffline = true
offlineRelayUrls = append(offlineRelayUrls, relayStatus.Url)
}
}
if isAnyNostrRelayOffline {
alarms = append(alarms, NewHealthAlarm(HealthAlarmKindNostrRelayOffline, offlineRelayUrls))
}
}
ldkVssEnabled, _ := api.cfg.Get("LdkVssEnabled", "")
if ldkVssEnabled == "true" {
albyMe, err := api.albyOAuthSvc.GetMe(ctx)
if err != nil {
return nil, err
}
if albyMe.Subscription.PlanCode == "" {
alarms = append(alarms, NewHealthAlarm(HealthAlarmKindVssNoSubscription, nil))
}
}
lnClient := api.svc.GetLNClient()
if lnClient != nil {
nodeStatus, _ := lnClient.GetNodeStatus(ctx)
if nodeStatus == nil || !nodeStatus.IsReady {
var apiNodeStatus *NodeStatus
if nodeStatus != nil {
apiNodeStatus = toApiNodeStatus(nodeStatus)
}
alarms = append(alarms, NewHealthAlarm(HealthAlarmKindNodeNotReady, apiNodeStatus))
}
channels, err := lnClient.ListChannels(ctx)
if err != nil {
return nil, err
}
offlineChannels := slices.DeleteFunc(channels, func(channel lnclient.Channel) bool {
if channel.Active {
return true
}
if channel.Confirmations == nil || channel.ConfirmationsRequired == nil {
return false
}
return *channel.Confirmations < *channel.ConfirmationsRequired
})
if len(offlineChannels) > 0 {
alarms = append(alarms, NewHealthAlarm(HealthAlarmKindChannelsOffline, nil))
}
}
return &HealthResponse{Alarms: alarms}, nil
}
func (api *api) GetCustomNodeCommands() (*CustomNodeCommandsResponse, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
}
allCommandDefs := lnClient.GetCustomNodeCommandDefinitions()
commandDefs := make([]CustomNodeCommandDef, 0, len(allCommandDefs))
for _, commandDef := range allCommandDefs {
argDefs := make([]CustomNodeCommandArgDef, 0, len(commandDef.Args))
for _, argDef := range commandDef.Args {
argDefs = append(argDefs, CustomNodeCommandArgDef{
Name: argDef.Name,
Description: argDef.Description,
})
}
commandDefs = append(commandDefs, CustomNodeCommandDef{
Name: commandDef.Name,
Description: commandDef.Description,
Args: argDefs,
})
}
return &CustomNodeCommandsResponse{Commands: commandDefs}, nil
}
func (api *api) ExecuteCustomNodeCommand(ctx context.Context, command string) (interface{}, error) {
lnClient := api.svc.GetLNClient()
if lnClient == nil {
return nil, ErrLNClientNotStarted
}
// Split command line into arguments. Command name must be the first argument.
parsedArgs, err := utils.ParseCommandLine(command)
if err != nil {
return nil, fmt.Errorf("failed to parse node command: %w", err)
} else if len(parsedArgs) == 0 {
return nil, errors.New("no command provided")
}
// Look up the requested command definition.
allCommandDefs := lnClient.GetCustomNodeCommandDefinitions()
commandDefIdx := slices.IndexFunc(allCommandDefs, func(def lnclient.CustomNodeCommandDef) bool {
return def.Name == parsedArgs[0]
})
if commandDefIdx < 0 {
return nil, fmt.Errorf("unknown command: %q", parsedArgs[0])
}
// Build flag set.
commandDef := allCommandDefs[commandDefIdx]
flagSet := flag.NewFlagSet(commandDef.Name, flag.ContinueOnError)
for _, argDef := range commandDef.Args {
flagSet.String(argDef.Name, "", argDef.Description)
}
if err = flagSet.Parse(parsedArgs[1:]); err != nil {
return nil, fmt.Errorf("failed to parse command arguments: %w", err)
}
// Collect flags that have been set.
argValues := make(map[string]string)
flagSet.Visit(func(f *flag.Flag) {
argValues[f.Name] = f.Value.String()
})
reqArgs := make([]lnclient.CustomNodeCommandArg, 0, len(argValues))
for _, argDef := range commandDef.Args {
if argValue, ok := argValues[argDef.Name]; ok {
reqArgs = append(reqArgs, lnclient.CustomNodeCommandArg{
Name: argDef.Name,
Value: argValue,
})
}
}
nodeResp, err := lnClient.ExecuteCustomNodeCommand(ctx, &lnclient.CustomNodeCommandRequest{
Name: commandDef.Name,
Args: reqArgs,
})
if err != nil {
return nil, fmt.Errorf("node failed to execute custom command: %w", err)
}
return nodeResp.Response, nil
}
func (api *api) SendEvent(event string, properties interface{}) {
api.svc.GetEventPublisher().Publish(&events.Event{
Event: event,
Properties: properties,
})
}
2024-05-30 00:06:06 +07:00
func (api *api) parseExpiresAt(expiresAtString string) (*time.Time, error) {
var expiresAt *time.Time
if expiresAtString != "" {
var err error
expiresAtValue, err := time.Parse(time.RFC3339, expiresAtString)
if err != nil {
2024-06-17 19:42:09 +07:00
logger.Logger.WithField("expiresAt", expiresAtString).Error("Invalid expiresAt")
2024-05-30 00:06:06 +07:00
return nil, fmt.Errorf("invalid expiresAt: %v", err)
}
expiresAt = &expiresAtValue
}
return expiresAt, nil
}
func (api *api) GetForwards() (*GetForwardsResponse, error) {
var forwards []db.Forward
err := api.db.Find(&forwards).Error
if err != nil {
return nil, err
}
var totalOutboundAmountMsat uint64
var totalFeeEarnedMsat uint64
for _, forward := range forwards {
totalOutboundAmountMsat += forward.OutboundAmountForwardedMsat
totalFeeEarnedMsat += forward.TotalFeeEarnedMsat
}
numForwards := len(forwards)
return &GetForwardsResponse{
OutboundAmountForwardedSat: totalOutboundAmountMsat / 1000,
OutboundAmountForwardedMsat: totalOutboundAmountMsat,
TotalFeeEarnedSat: totalFeeEarnedMsat / 1000,
TotalFeeEarnedMsat: totalFeeEarnedMsat,
NumForwards: uint64(numForwards),
}, nil
}