Repository navigation
#137 lightning_refund fails: WalletManager._get_client() missing 'url' argument - #138
Merged
Merged
Conversation
get_block_height, get_transaction_hex and broadcast_raw_tx (added in #134) still called _get_client(network), whose signature #131 changed to (network, url), so every refund raised TypeError. Route them through the backend fallback, reuse the idempotent _broadcast, and read tx hex over HTTP for Esplora backends: lwk's EsploraClient has no get_tx, and every default Liquid backend is Esplora. Closes #137
andycreed0x
marked this pull request as ready for review
September 30, 2026 21:14
Electrum: lwk's ElectrumClient.get_tx never returns None; a missing tx
raises LwkError ("missing transaction", probed live on Blockstream's
Liquid Electrum). The old None check was dead, so a miss escaped as a
raw LwkError instead of the "Transaction ... not found" ValueError.
Recognize the miss and treat it like an Esplora 404. The test now raises
what lwk really raises instead of returning None.
Esplora: a 200 whose body is not tx hex (a proxy HTML page, a JSON
error, an empty or non-UTF-8 body) was returned as the lockup hex and
failed later inside wally.tx_from_hex, without trying the next backend.
Validate the body, record the backend as failed and fall back.
Collaborator
|
Tested PR #138 on the fix branch — both issues resolved. MCP and CLI lightning_refund working correctly (cooperative refunds confirmed for swap IDs 1NLdmc6R and 1N4CK50F). Lightning send to Wallet of Satoshi also routing successfully via Indra now. One refund (1Nqv0DCV) kept locked on develop for post-merge verification. Ready to merge. |
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.
Walkthrough
Type:
fixlightning_refundfailed on every attempt because the chain helpers added in #134 (get_block_height,get_transaction_hex,broadcast_raw_tx) still called_get_client(network), whose signature #131 (Airavata) changed to(network, url). The helpers now go through the backend fallback, andbroadcast_raw_txreuses the idempotent_broadcast. A live mainnet check then exposed a second bug hidden behind the first: lwk'sEsploraClienthas noget_tx, and every default Liquid backend is Esplora, soget_transaction_hexnow readsGET {base}/tx/{txid}/hexover HTTP (Electrum overrides keepget_tx), with the same rules astools._esplora_request: fall back on 5xx/429/network errors, and report "not found" only when every backend returns 404.Closes #137
Changes
src/aqua/wallet.pyget_block_height→_with_client_fallback;broadcast_raw_tx→_broadcast(backend fallback + "already broadcast" = success);get_transaction_hex+ new_fetch_tx_hex: HTTP for Esplora,get_txfor Electrum, with per-backend fallback.tests/test_wallet.pyTestChainAccess(10 tests). It stubs_get_client(network, url)andurlopeninstead of patching the helpers, so it catches both the signature mismatch and the missingget_tx. The existing refund tests intest_lightning.pymock the helpers and missed both.Flow
sequenceDiagram participant CLI as lightning_refund participant LM as LightningManager participant WM as WalletManager participant BE as Liquid backends (Esplora) CLI->>LM: refund(swap_id) LM->>WM: get_transaction_hex(lockup_txid) WM->>BE: GET /tx/{txid}/hex (fallback on 5xx/429/404) BE-->>WM: raw hex LM->>WM: get_block_height() WM->>BE: tip() via _with_client_fallback LM->>WM: broadcast_raw_tx(refund_hex) WM->>BE: _broadcast (fallback, idempotent) BE-->>CLI: refund txidVerification
tuna-test):get_block_heightandget_transaction_hexreturn correct data through Airavata.broadcast_raw_txreaches the backend and surfaces the node's real rejection.tuna-testhas no refundable swap. Its old Boltz lockups were already claimed by the provider, and the Indra ones were already refunded.🤖 Generated with Claude Code