Skip to content

feat: enable Safe recovery for ICP (offline mode) - #10055

Merged
pranishnepal merged 1 commit into
masterfrom
WCN-2886
Oct 26, 2026
Merged

pranishnepal merged 1 commit into
masterfrom
WCN-2886

Conversation

@pranishnepal

Copy link
Copy Markdown
Contributor

What

Enables Safe (offline) recovery for ICP. Icp.recover() gains a broadcast?: boolean
option (default true); when false it returns the signed transaction payload instead
of submitting it to the network. The Safe key-derivation pipeline
(deriveSafeWalletKeys → buildSafeRecoverKeyParams → coin.recover()) now works for
ICP's slot-3 ecdsaMpc keys.

Why

Safe recovery (WCN-2732) requires "nothing auto-broadcasts" — recover() is the probe
during account scanning, and ICP was the one coin whose recover() always submitted the
sweep to the live network. This change makes the offline guarantee hold at the SDK layer.

Changes

  • sdk-coin-icp: broadcast?: boolean on RecoveryOptions; offline returns the
    signed payload ({ id, tx, txHex, coin }) with zero network writes; userKey/
    backupKey/walletPassphrase optional so typed unsigned sweeps compile; fail-closed
    RecoveryKeyMismatchError on bitgoKey/rootAddress mismatch; getBuilderFactory()
    uses _staticsCoin (fixes ticp building mainnet canister IDs).
  • sdk-core: buildSafeRecoverKeyParams gains the ecdsaMpc arm (signed re-encrypts
    child reduced shares under a fresh v1 passphrase; unsigned returns the child common
    keychain). Both modes set broadcast: false — Safe recovery is offline by construction,
    matching every other coin's recover().

Testing

  • Unit tests in modules/sdk-coin-icp (transactionRecover.ts) and modules/sdk-core
    (safe/recovery.ts)
  • New E2E icpSafeRecovery.ts: real DKG roots → derive → map → recover() with real
    DKLS 2-of-2 signing; signature verified cryptographically; broadcast never called

@linear-code

linear-code Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

WCN-2886

Add an offline mode to Icp.recover()

- Icp.recover() gains broadcast?: boolean (default true); when false it
  returns the signed transaction payload ({ id, tx, txHex, coin })
  without submitting it to the network
- buildSafeRecoverKeyParams() gains the ecdsaMpc (slot 3) arm:
  signed mode re-encrypts the derived child reduced shares under a
  fresh v1 passphrase, unsigned mode returns the child common keychain;
  both set broadcast: false so the coin-agnostic Safe engine stays
  offline
- RecoveryOptions.userKey/backupKey/walletPassphrase are now optional so
  typed unsigned sweeps compile
- Icp.recover() fails closed with RecoveryKeyMismatchError when bitgoKey
  or rootAddress does not match the recovery keys
- getBuilderFactory() uses _staticsCoin so ticp builds testnet
  transactions

Ticket: WCN-2886
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Unit tests are failing on Node 26.x (Current release line, non-blocking). This is not an LTS version yet, so it does not block merge, but it signals an incompatibility to fix before Node 26.x becomes LTS.

View run

@pranishnepal
pranishnepal marked this pull request as ready for review October 23, 2026 21:32
@pranishnepal
pranishnepal requested review from a team as code owners October 23, 2026 21:32

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@kisslove-dewangan kisslove-dewangan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls check ci test failing

@bhavidhingra

Copy link
Copy Markdown
Contributor

@claude review

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread modules/sdk-coin-icp/src/icp.ts Resolved
Comment thread modules/sdk-coin-icp/src/icp.ts Resolved
@pranishnepal
pranishnepal merged commit 6ffb597 into master Oct 26, 2026
42 of 44 checks passed
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.

5 participants