diff --git a/WALLET.scratch.md b/WALLET.scratch.md index b09e6989d..99dd8c26f 100644 --- a/WALLET.scratch.md +++ b/WALLET.scratch.md @@ -35,18 +35,17 @@ nixt:walt1 ``` ## Algos -Insert an address -1. send wallet an address that we KNOW is in the wallet -2. include the address's index Scan addresses. (map xpub (pair list list)) -outgoing wire is /scan/xpub/change/index -- keep list of whether we've heard back on an address `(list (unit used))` +outgoing wire is /scan/xpub/change/idx +- keep (jug cord idx) of xpub+chyg -> idx - every time we get a response - - insert the address into the wallet if it's used - - check whether (lent (murn l)) == max-gap - - if it does, run lien--if any used, continue - - if none used, the wallet is scanned. + - check whether idx in `scanning`--ignore if not (old response) + - insert the address into the wallet **if it's used** + - if used, update `has-used` for this xpub to be true + - delete idx from `scanning` jug + - check whether `scanning` is now empty + ## scratch code, refactor diff --git a/sur/btc-wallet-store.hoon b/sur/btc-wallet-store.hoon index 731e16ae7..8455a1f2e 100644 --- a/sur/btc-wallet-store.hoon +++ b/sur/btc-wallet-store.hoon @@ -25,6 +25,13 @@ +$ wach (map address addi) +$ scon $~([max-index max-index] (pair idx idx)) +$ wilt _bip32 +:: scanning: maps xpub+chyg to set of indices. +:: once it's full, we can check whether address in it were blank or not +:: seen: holds addresses whose scan results we've seen already +:: ++$ scanning (jug cord idx) ++$ has-used (map cord ?) +:: +$ action $% [%add-wallet =xpub scan-to=(unit scon) max-gap=(unit @)] [%update-address a=address utxos=(set utxo)]