Waymark — Recovering useful wallet state without starting from zero

Hi everyone,

I’ve been testing a recovery problem around CKB light-client wallets.

When you restore a wallet with your seed phrase, you get control of your wallet again.

But the wallet may still have to rebuild a lot of the local information it had already gathered before — account discovery, transaction history, live Cells, sync progress, light-client state, and other data it needs to become fully useful again.

I wanted to see if that part could also be recovered safely.

That became Waymark.

GitHub:

The idea

Waymark separates two things that normally get treated as one recovery problem:

1. Recovering ownership of the wallet

This still happens normally with the seed phrase.

The new installation creates its own keys, PIN protection, device security and signing environment.

2. Recovering useful local state

Before the old installation is lost, selected non-secret wallet and light-client state can be saved.

After the wallet is recovered normally on the new installation, that saved state can be restored too.

The wallet then continues syncing from there and checks everything against the chain.

So the flow looks like this:

Restore wallet normally
        ↓
keys and signing access are recovered
        ↓
restore saved non-secret wallet/light-client state
        ↓
continue syncing from that point
        ↓
catch up with anything that changed
        ↓
current chain state remains the final authority

The saved state is not treated as truth forever.

It can be old.

Cells that were live when it was saved may already have been spent. New transactions may have happened. Balances may have changed.

The wallet still has to reconnect to the chain and catch up correctly.

The point is simply that it does not always need to throw away all the useful work it had already done and start rebuilding everything from zero.

What is saved

The tested package contains selected non-secret information needed to continue the wallet’s previous work.

That includes things around:

  • public account relationships;
  • account and Script mapping;
  • sync progress;
  • discovery state;
  • light-client history and indexes;
  • chain checkpoints needed to continue syncing.

It does not contain the wallet’s signing secrets.

Waymark does not transfer:

  • seed phrase;
  • private keys;
  • wallet PIN;
  • Android device credential;
  • Android Keystore keys;
  • source-device signing material;
  • raw wallet backups containing secrets.

The wallet still has to be recovered normally first.

That was an important part of the test.

Why I tested it on Pocket Node

Pocket Node was a good place to test this because it runs a CKB light client directly on the device and keeps useful local state around the wallet.

I tested against Pocket Node 1.8.5.

Pocket itself was not modified into a finished Waymark feature.

The recovery/export/import work was done around the existing Pocket implementation so I could test whether the recovery model actually works.

How I tested it

I did not only test restoring a clean snapshot and checking whether the app opened.

The saved state was intentionally allowed to become stale.

After the checkpoint was created, more activity happened on the wallet.

That meant the restored wallet had to prove that it could continue from the older state and still discover what changed afterwards.

The later tests included:

  • two populated accounts;
  • different CKB Scripts;
  • transaction history on both accounts;
  • an active Nervos DAO deposit;
  • transactions that happened after the saved checkpoint;
  • account mapping checks;
  • balance and live Cell checks;
  • signing;
  • restart;
  • and comparison against the expected chain state.

After the emulator tests passed, I ran the full recovery flow on a real Android phone.

The final comparison

I tested two separate recovery paths.

Baseline recovery

For the baseline, Pocket started from fresh application state.

The wallet was recovered normally from the seed.

No saved Waymark state was used.

Pocket had to rebuild the required wallet/light-client state normally.

After recovery it reached the expected chain state, signed a real CKB testnet transaction, broadcast it successfully and passed a cold restart.

State-assisted recovery

Then Pocket was reset again.

The same wallet was recovered normally from the seed first.

This created fresh destination-side security again.

Only after normal recovery was complete did I restore the older saved non-secret state.

That saved checkpoint was stale by this point.

There had already been later activity on both accounts, including the transaction created during the baseline recovery.

So the restored wallet still had work to do.

It had to:

  • catch up from the saved checkpoint;
  • discover the later transactions;
  • remove Cells that were no longer live;
  • find the new live Cells;
  • recover the correct balances;
  • keep both accounts mapped correctly;
  • recover the DAO position correctly;
  • and reach the same current wallet state as the baseline recovery.

It passed.

After catching up, the state-assisted recovery also signed and confirmed another real testnet transaction.

It then passed a cold restart as well.

Result

At the common comparison point, baseline recovery and state-assisted recovery matched.

They agreed on:

  • both accounts;
  • account-to-Script mapping;
  • live Cells;
  • balances;
  • covered transaction history;
  • later activity that happened after the saved checkpoint;
  • DAO ownership and deposit state;
  • and sync progress.

There was no recovery-specific DAO difference.

There was no account mix-up.

There was no dependency on the old device’s Keystore.

The destination created its own fresh security state and signing still worked after the saved state was restored.

So for the Pocket setup I tested, the result was:

PASS

The baseline test transaction was:

0x2067edf16ab143e7bff9ef91803e36ce6a32347c632c75a37d382443ae379738

The state-assisted test transaction was:

0xe4cbdffa9002b0283c2c71cc19ec646b85cb58274b8f45d72496e78ae96b4cbd

Both were confirmed on CKB testnet.

More detailed evidence is in the repository:

What about recovery time?

On the real-phone run, the full baseline path took about 60 minutes.

The state-assisted path took about 30 minutes.

But I do not want to present that as “Waymark is 2x faster.”

These were not controlled performance benchmarks.

The runs included things like:

  • manual authentication;
  • automation delays;
  • peer/network conditions;
  • discovery work;
  • observation and verification;
  • restart checks.

The useful result is simpler:

the restored state avoided rebuilding some work, and the wallet still reached the same correct chain state.

A proper performance benchmark would need a different test setup.

Why I think this matters

Wallet recovery is usually discussed mostly as:

Can I recover my keys?

That is obviously the most important part.

But with a light-client wallet, there is another question:

Can I also recover the useful work my wallet had already done?

Those are different things.

The seed answers:

“Which wallet do I own?”

The saved state can help answer:

“What had this wallet already discovered and processed?”

Waymark keeps those responsibilities separate.

The seed and keys remain responsible for ownership and signing.

The saved state only helps the recovered wallet continue from previous work.

And the chain remains responsible for telling the wallet what is currently true.

One useful thing I found while testing

While checking the DAO state during this work, I also found a separate issue in Pocket’s DAO reward estimate.

The DAO reader was using 61 CKB as the occupied capacity when calculating compensation, while a DAO deposit Cell actually occupies 102 CKB.

That caused the displayed compensation estimate to be slightly too high.

It did not affect wallet ownership, principal or the actual unlock transaction path.

I reported it here:

The fix was added, tested and merged into Pocket:

That issue was separate from the Waymark recovery result, but it came out of the testing.

Current scope

Waymark is not a finished production wallet feature.

It is also not something I am claiming already works across every CKB wallet.

The current end-to-end proof is on Pocket Node.

I have not yet validated the same recovery flow on:

  • Neuron;
  • iBytes;
  • or other CKB wallets/light-client applications.

The current proof is also limited to the environment I tested:

  • one pinned Pocket version;
  • CKB testnet;
  • two accounts;
  • one active DAO deposit;
  • one real Android device;
  • and the specific saved-state format used in the experiment.

Things like cross-version migration, different wallet architectures, much larger histories, hostile/corrupt source backups and production backup UX still need separate work if this goes further.

What happens next?

For now I wanted to put the result in front of the CKB community rather than keep testing more wallets privately.

The main question I have is:

Is this recovery model useful enough to explore beyond Pocket?

For example:

  • Should something like this simply become a Pocket feature?
  • Would it be useful to test the same recovery model on another CKB wallet or light-client application?
  • If the same need appears in multiple wallets, is there a useful reusable part?
  • Or is wallet state recovery something each wallet should own independently?

I think the Pocket proof is enough to have that discussion now.

If there is interest, the next step can be decided from there instead of trying to build support for every wallet first.

Waymark:

Feedback from wallet developers, light-client developers and anyone who has dealt with wallet recovery/state reconstruction would be very useful.

4 Likes

Hi @Ticoworld this is a very helpful research and work you’ve done, i had this idea in mind for a while even @Xcodes-chain created an issue about it on github.
I haven’t looked at the code, I’ll do that soon so we can catch any underlying issue or bugs. Then officially incorporate it into PN and other applications thats uses LC state

2 Likes

Thanks bro, really appreciate this.

Good to know this was already something you had in mind too. I’d like to hear what you find after you’ve gone through the code.

Waymark Lite is now in Pocket Node’s main branch on both Android and iOS.

When I first tested Waymark on Pocket, the idea was simple: after restoring from a seed phrase, can the wallet avoid rebuilding everything from zero?

@Jnr6 took the Lite path from that work and built it into Pocket as a restore-hint flow. The Android side landed in #561, the iOS side followed in #566, and #559 is now complete.

Really nice seeing the experiment turn into something concrete in the wallet this quickly.

The Full recovery direction is still open in #560, so there’s still more to understand around what is worth carrying forward beyond Lite.

4 Likes