Add swap-in wallet and splice-in via Electrum backend#226
Open
matthiasdebernardini wants to merge 1 commit intoACINQ:masterfrom
Open
Add swap-in wallet and splice-in via Electrum backend#226matthiasdebernardini wants to merge 1 commit intoACINQ:masterfrom
matthiasdebernardini wants to merge 1 commit intoACINQ:masterfrom
Conversation
…kend Port swap-in functionality from PR ACINQ#69 to current master by switching the blockchain backend from MempoolSpaceClient to ElectrumClient. This enables peer.swapInWallet (which requires IElectrumClient) and adds three new API endpoints: getswapinaddress, swapinwalletbalance, and splicein. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MempoolSpaceClienttoElectrumClient/ElectrumWatcher, enablingpeer.swapInWalletandpeer.finalWallet(which requireIElectrumClient)GET /getswapinaddress,GET /swapinwalletbalance,POST /spliceinphoenix-cli getswapinaddress,swapinwalletbalance,spliceinpeer.startWatchSwapInWallet()after both Electrum and peer connections are established, enabling automatic swap-in to channel--electrum-serverCLI option with per-chain defaults, deprecates--mempool-space-urland--mempool-space-polling-interval-minutesThis is based on the approach from #69 but ported to the current codebase and API surface.
Motivation
Phoenixd currently uses
MempoolSpaceClientwhich only implementsIClient, notIElectrumClient. This meanspeer.swapInWalletandpeer.finalWalletare alwaysnull— users cannot receive on-chain funds and splice them into channels. The Phoenix mobile app usesElectrumClientand has full swap-in support; this PR brings phoenixd to parity.Changes
Phoenixd.kt--electrum-serveroption, Electrum connection loop,startWatchSwapInWallet()call, deprecate mempool optionsApi.ktgetswapinaddress,swapinwalletbalance(read-only),splicein(full-access) endpointsJsonSerializers.ktSwapInAddressandSwapInWalletBalanceresponse typesPhoenixCli.ktGetSwapInAddress,GetSwapInWalletBalance,SpliceInCLI commandsMainnet E2E Test Results
Tested on mainnet with real sats (22,333 sat across 3 deposits):
electrum.acinq.co:50002sendtoaddresssplice-out worked (19,000 sat sent on-chain, tx15539c9a61114c3bb2940dce83badaa58c540ba8064f553cf416ee1761c41969)Known Issue: Feerate Estimation
The Electrum server's
blockchain.estimatefeereturned very low values (1 sat/vB), causingfundingFeerate=253 sat/kw. The ACINQ LSP aborted channel creation during interactive-tx withchannel funding error. The channel was ultimately opened via Phoenix mobile (same seed), after which phoenixd synced the state and successfully performed splice-out.Possible fixes:
electrum.acinq.coreturns low fee estimatesOther Notes
testnet.acinq.co:51002doesn't resolve — needs a working defaultbuild.gradle.ktschanges needed —ElectrumClient/ElectrumWatcherare part oflightning-kmp-core(already a dependency)Test plan
GET /getswapinaddressreturns valid taproot address with derivation indexGET /swapinwalletbalancecorrectly reports total and unconfirmed balancesPOST /sendtoaddresssplice-out works from an open channelPOST /spliceinmanual splice-in (not tested — auto flow triggered first)🤖 Generated with Claude Code