From 90076aadbc5e7c3f1e4db1643b86ce0b2c205c54 Mon Sep 17 00:00:00 2001 From: timlucmiptev Date: Thu, 29 Oct 2020 20:07:43 +0200 Subject: [PATCH] wallet basics compile --- app/btc-wallet-store.hoon | 45 ++++++++++++++++++++++++++++++++++++--- sur/btc-wallet-store.hoon | 19 +++++++++++------ 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/app/btc-wallet-store.hoon b/app/btc-wallet-store.hoon index 423aa600e2..387314101e 100644 --- a/app/btc-wallet-store.hoon +++ b/app/btc-wallet-store.hoon @@ -50,7 +50,12 @@ == [cards this] :: -++ on-watch on-watch:def +++ on-watch + |= pax=path + ^- (quip card _this) + ?> (team:title our.bowl src.bowl) + ?> ?=([%wallets *] pax) + `this ++ on-leave on-leave:def ++ on-peek on-peek:def ++ on-agent on-agent:def @@ -65,7 +70,40 @@ ?- -.act %add-wallet (add-wallet xpub.act) + :: + %update-address + (update-address +.act) == +++ update-address + |= [a=address us=(set utxo)] + ^- (quip card _state) + =/ xpubs=(list tape) + %~ tap in + ~(key by wallets.state) + |- ?~ xpubs `state + =/ w=walt (~(got by wallets.state) i.xpubs) + ?: (~(has by wach.w) a) + %: send-address-update + i.xpubs + (update-wallet w a us) + a + us + == + $(xpubs t.xpubs) +:: +++ update-wallet + |= [w=walt a=address us=(set utxo)] + ^- walt + =/ curr-addi=addi + (~(got by wach.w) a) + w(wach (~(put by wach.w) a curr-addi(used %.y, utxos us))) +:: +++ send-address-update + |= [xpub=tape =walt a=address us=(set utxo)] + ^- (quip card _state) + :_ state(wallets (~(put by wallets.state) xpub walt)) + ~[[%give %fact ~[/wallets] %btc-wallet-store-update !>([%address a us])]] +:: ++ add-wallet |= xpub=tape ^- (quip card _state) @@ -75,8 +113,9 @@ =/ wallet=walt :* (from-extended:bip32 xpub) (xpub-type:btc xpub) - [%.n 0 *wach] - [%.n 0 *wach] + *wach + %.n + [0 0] == `state(wallets (~(put by wallets.state) xpub wallet)) -- diff --git a/sur/btc-wallet-store.hoon b/sur/btc-wallet-store.hoon index addd0ca95c..2f19e22e8d 100644 --- a/sur/btc-wallet-store.hoon +++ b/sur/btc-wallet-store.hoon @@ -11,21 +11,26 @@ :: wilt: stores xpub; copulates with thousands of indices to form addresses :: walt: wallet metadata :: -+$ addi [idx=@ used=? utxos=(set utxo)] ++$ chyg $?(%0 %1) ++$ addi [=chyg idx=@ used=? utxos=(set utxo)] +$ wach (map address addi) -+$ chyg [scanned=? next=@ =wach] +$ wilt _bip32 +$ walt $: :: bipt: BIP44/49/84 - :: ching: non-change addresses - :: chang: change addresses + :: ching: next index in non-change addresses + :: chang: next index in change addresses :: =wilt =bipt - ching=chyg - chang=chyg - == + =wach + scanned=? + [ching=@ chang=@] + == +$ action $% [%add-wallet xpub=tape] + [%update-address =address utxos=(set utxo)] + == ++$ update + $% [%address =address utxos=(set utxo)] == --