staticaddr/withdraw: harden replacement monitoring - #1215
Draft
hieblmi wants to merge 16 commits into
Draft
Conversation
This was referenced Aug 27, 2026
hieblmi
force-pushed
the
multi-address-withdrawal-hardening
branch
from
August 27, 2026 10:28
0a947a5 to
9dd7f66
Compare
hieblmi
force-pushed
the
multi-address-address-hardening
branch
from
August 27, 2026 10:28
56dcc74 to
7c226da
Compare
hieblmi
force-pushed
the
multi-address-withdrawal-hardening
branch
from
August 27, 2026 10:40
9dd7f66 to
93bbffa
Compare
hieblmi
force-pushed
the
multi-address-address-hardening
branch
from
August 27, 2026 10:40
7c226da to
e85c0d3
Compare
hieblmi
force-pushed
the
multi-address-withdrawal-hardening
branch
from
August 27, 2026 11:46
93bbffa to
942e440
Compare
hieblmi
force-pushed
the
multi-address-address-hardening
branch
from
August 27, 2026 11:47
e85c0d3 to
6f82255
Compare
hieblmi
force-pushed
the
multi-address-withdrawal-hardening
branch
from
August 27, 2026 12:41
942e440 to
6245c73
Compare
hieblmi
force-pushed
the
multi-address-address-hardening
branch
2 times, most recently
from
August 28, 2026 10:34
c458192 to
f709e0c
Compare
hieblmi
force-pushed
the
multi-address-withdrawal-hardening
branch
from
August 28, 2026 10:34
6245c73 to
82b5b00
Compare
1 task
Create a fresh static address for partial-withdrawal change and persist that output from the confirmed transaction. Keep all withdrawal outputs in the PSBT without separate signing metadata while preserving full-withdrawal behavior.
Let loop static deposit create and fund a fresh receive address through lnd SendCoins. Validate funding arguments before address creation and require explicit confirmation unless --force is set, including for non-interactive and first-use deposits. Resolve requested existing addresses through the active script index rather than reconstructing every persisted address. Expose the nested request through the client RPC, require swap:execute permission, and cover the CLI and daemon funding paths. Regenerate RPC and CLI documentation.
Include the owning static address in every deposit RPC response and CLI listing. Users can distinguish deposits created by different receive and change addresses without reconstructing scripts externally. Calculate blocks until expiry from each deposit owner instead of the legacy root address, and reject deposits whose owning parameters are missing. Centralize deposit response conversion and update generated RPC artifacts, regression coverage, and command replay fixtures.
The CLI previously recognized an uninitialized static-address seed by searching arbitrary gRPC error text. Any wrapping or wording change could suppress the L402 backup warning before a user funded a newly derived address. Map ErrNoStaticAddress to codes.NotFound at the RPC boundary and classify that status in the CLI. Retain compatibility with older daemons only for an exact Unknown-status message, avoiding the broad substring match, and cover both sides with regression tests.
A static-address account can now receive deposits across multiple derived addresses, so the singular summary field can no longer describe the current receive address. Removing or repurposing field 1 would break existing clients. Keep the wire value as the legacy/root derivation address, formally deprecate it, document the expiry as the shared CSV delay, and direct CLI users to derive a fresh receive address. Rename the server locals to make the compatibility behavior explicit and regenerate protobuf and Swagger artifacts.
Cover per-deposit address ownership and operation-specific change outputs across the shared SQL persistence boundary. Reconstruct the deposit, loop-in, and withdrawal stores to verify ownership and change metadata survive restart.
Document fresh receive-address derivation, lazy seed initialization, funding-address lookup hardening, and the swap:execute permission required by address creation. Regenerate the CLI, gRPC, Swagger, and man-page documentation and add feature, breaking-change, and recovery release notes.
Follow the transaction that actually spends the watched deposit, require its confirmed form to spend every selected withdrawal input, persist that transaction, and stop republishing both the original and replacement.
Identify withdrawal change through its active change-family script instead of a fixed output index. Record amounts correctly when confirmed replacements reorder or add outputs.
Stop republishing an obsolete withdrawal when its confirmed spender consumes only part of the deposit group. Finalize spent deposits, release untouched deposits, and clear stale transaction references.
handleWithdrawal starts a long-lived spend and confirmation monitor, but the manager did not own its lifecycle. Manager.Run could return while a monitor was still transitioning deposits, updating withdrawal rows, or reading package-level logging state. Track every monitor with a WaitGroup and give the run loop a child context that is canceled on every exit path. Close request delivery, cancel the monitors, and join them before returning. Configure the test logger once and make monitor tests cancel and wait so consecutive race tests cannot overlap through the global logger.
Withdrawal spend monitoring followed an RBF replacement's txid while retaining the original destination script. Confirmation requests match both values, so a replacement paying a newly derived destination could remain invisible and leave deposits stuck in Withdrawing. Build the confirmation request from the actual spending transaction, use a positive spending height as its historical hint with the startup height as the mempool fallback, and identify change from the confirmed transaction's own destination. Persist the confirmation's block height and remove both original and replacement republish entries after resolution. Widen the manager store dependency to an interface so the complete transition and persistence path can be covered without a database, and add replacement, map-cleanup, and mempool-height regression tests.
hieblmi
force-pushed
the
multi-address-withdrawal-hardening
branch
from
August 28, 2026 13:35
82b5b00 to
042bc9b
Compare
hieblmi
force-pushed
the
multi-address-address-hardening
branch
from
August 28, 2026 13:35
f709e0c to
1179815
Compare
hieblmi
changed the base branch from
multi-address-address-hardening
to
multi-address-core
August 28, 2026 13:35
hieblmi
force-pushed
the
multi-address-core
branch
2 times, most recently
from
August 28, 2026 15:09
eb2cb02 to
7aa2e74
Compare
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
This is PR 3 of 3 in the static-address multi-address stack. It depends on
#1214 and is based on
multi-address-address-hardeningso this PR only showswithdrawal replacement and monitor hardening.
This follow-up:
selected deposits;
output index;
withdrawn;
withdrawal; and
replacement coverage.
Stack
Testing
go test -race ./staticaddr/...go vet ./...git diff --checkPull Request Checklist
docs/release-notes/release-notes-next.md.