Skip to content

Improve wallet repair with previews, validation, error handling, and multi-coin support#295

Open
QuickMythril wants to merge 9 commits intoQortal:masterfrom
QuickMythril:bugfix/wallet-repair
Open

Improve wallet repair with previews, validation, error handling, and multi-coin support#295
QuickMythril wants to merge 9 commits intoQortal:masterfrom
QuickMythril:bugfix/wallet-repair

Conversation

@QuickMythril
Copy link

@QuickMythril QuickMythril commented Jan 9, 2026

Summary

  • Enforce deterministic private keys for repair, rejecting xpub/tpub on sweep endpoints.
  • Surface proper API errors on repair failures instead of returning non-txid strings.
  • Add repair preview summaries and gate repair behind recommendations with a force override.
  • Extend repair/preview behavior to BTC, DOGE, DGB, and RVN.
  • Strengthen unit and API tests to validate txid format and new preview/force behavior.

Issue

Refs: #294

Commit breakdown

Require private key for litecoin repair

  • src/main/java/org/qortal/api/resource/CrossChainLitecoinResource.java: validate deterministic private keys for repair so xpub/tpub are rejected.
  • src/main/java/org/qortal/crosschain/Bitcoiny.java: add a private-key validator helper used by repair endpoints.

Return API errors for wallet repair failures

  • src/main/java/org/qortal/api/resource/CrossChainLitecoinResource.java: map repair failures to API errors so clients get clear error responses.
  • src/main/java/org/qortal/crosschain/Bitcoiny.java: throw structured exceptions instead of returning class-name strings.
  • src/test/java/org/qortal/test/crosschain/BitcoinyTests.java: align tests with the new error handling.

Assert repair returns valid txid

  • src/test/java/org/qortal/test/crosschain/BitcoinyTests.java: verify txid format rather than just non-null responses.

Add litecoin repair preview endpoint

  • src/main/java/org/qortal/crosschain/RepairWalletPreview.java: new response model for preview summaries.
  • src/main/java/org/qortal/crosschain/Bitcoiny.java: implement old-vs-current scan comparison, missing balance, fee/dust estimate, and recommendation logic.
  • src/main/java/org/qortal/api/resource/CrossChainLitecoinResource.java: add /repair/preview endpoint to expose the summary.
  • src/test/java/org/qortal/test/crosschain/BitcoinyTests.java: add preview test coverage.

Gate litecoin repair behind recommendation

  • src/main/java/org/qortal/api/resource/CrossChainLitecoinResource.java: refuse repair when preview is not recommended unless force=true.

Add repair preview and gated repair for BTC/DOGE/DGB/RVN

  • src/main/java/org/qortal/api/resource/CrossChainBitcoinResource.java: add preview endpoint and force-gated repair.
  • src/main/java/org/qortal/api/resource/CrossChainDogecoinResource.java: add preview endpoint and force-gated repair.
  • src/main/java/org/qortal/api/resource/CrossChainDigibyteResource.java: add preview endpoint and force-gated repair.
  • src/main/java/org/qortal/api/resource/CrossChainRavencoinResource.java: add preview endpoint and force-gated repair.

Document force query param in repair endpoints

  • src/main/java/org/qortal/api/resource/CrossChainBitcoinResource.java: OpenAPI @Parameter docs for force.
  • src/main/java/org/qortal/api/resource/CrossChainLitecoinResource.java: OpenAPI @Parameter docs for force.
  • src/main/java/org/qortal/api/resource/CrossChainDogecoinResource.java: OpenAPI @Parameter docs for force.
  • src/main/java/org/qortal/api/resource/CrossChainDigibyteResource.java: OpenAPI @Parameter docs for force.
  • src/main/java/org/qortal/api/resource/CrossChainRavencoinResource.java: OpenAPI @Parameter docs for force.

Add API tests for repair preview and force

  • src/test/java/org/qortal/test/api/CrossChainRepairApiTests.java: new API-level tests for preview summaries and force-gated repair behavior using a dummy provider to avoid network calls.

Fix repair test compilation and exception ctor

  • src/main/java/org/qortal/crosschain/ForeignBlockchainException.java: add a (String, Throwable) constructor so repair paths can preserve causes without build errors.
  • src/test/java/org/qortal/test/api/CrossChainRepairApiTests.java: rely on the static ApiCommon.assertApiError helper to avoid an invalid instance override and keep tests compiling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant