lianad: warn createrecovery to an address of the same wallet. - #2226
Draft
qlrd wants to merge 1 commit into
Draft
Conversation
This commit adds a new error (code 1001, just after the existing 1000) bound to `createrecovery` -- as a error/warning response -- when a user wants to re-lock funds from/to addresses derived from the wallet descriptor. As stated by jp1ac4 the starting point is to check this on the backend since the backend has easier access to known wallet addresses (needs a check on how to deal with derivation indices beyond what the DB knows). The proposed flow is first return an error from `createrecovery`, controlled by a new `Option<bool>` parameter `allow_own_address` (defaults to `false`). With this, a user can try again with `allow_own_address=true` (see `tests/test_rpc.py`). In that case is proposed to a new `warnings` field was added to the response together with the `psbt` field, to warn the user as a mean to double-check the entire procedure. refs wizardsardine#1654.
pythcoiner
reviewed
Aug 7, 2026
Comment on lines
+1332
to
+1342
| if sweep_addr_info.is_some() { | ||
| if !allow_own_address.unwrap_or(false) { | ||
| return Err(CommandError::RecoveryToOwnAddress(sweep_addr.addr)); | ||
| } | ||
| warnings.push(format!( | ||
| "Address {} belongs to the same wallet. Recovered funds would \ | ||
| be locked under the same descriptor again.", | ||
| sweep_addr.addr | ||
| )); | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
better for maintenance
Suggested change
| if sweep_addr_info.is_some() { | |
| if !allow_own_address.unwrap_or(false) { | |
| return Err(CommandError::RecoveryToOwnAddress(sweep_addr.addr)); | |
| } | |
| warnings.push(format!( | |
| "Address {} belongs to the same wallet. Recovered funds would \ | |
| be locked under the same descriptor again.", | |
| sweep_addr.addr | |
| )); | |
| } | |
| if sweep_addr_info.is_some() { | |
| let err = CommandError::RecoveryToOwnAddress(sweep_addr.addr.clone()); | |
| if !allow_own_address.unwrap_or(false) { | |
| return Err(err.clone()); | |
| } | |
| warnings.push(err.to_string()); | |
| } | |
pythcoiner
reviewed
Aug 7, 2026
| coins_outpoints: &[bitcoin::OutPoint], | ||
| feerate_vb: u64, | ||
| timelock: Option<u16>, | ||
| allow_own_address: Option<bool>, |
Collaborator
There was a problem hiding this comment.
I can overlook something, but I dont think this flag is really useful, it seems to me we can just return warnings
Author
There was a problem hiding this comment.
I will get my annotations made before "that" and lyn :)
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.
This commit adds a new error (code 1001, just after the existing 1000) bound to
createrecovery-- as a error/warning response -- when a user wants to re-lock funds from/to addresses derived from the wallet descriptor.As stated by jp1ac4 the starting point is to check this on the backend since the backend has easier access to known wallet addresses (needs a check on how to deal with derivation indices beyond what the DB knows).
The proposed flow is first return an error from
createrecovery, controlled by a newOption<bool>parameterallow_own_address(defaults tofalse). With this, a user can try again withallow_own_address=true(seetests/test_rpc.py).In that case is proposed to a new
warningsfield was added to the response together with thepsbtfield, to warn the user as a mean to double-check the entire procedure.refs #1654.
Details
A following commit to this PR is beign draft while waiting for discussion.