shrub/app/btc-wallet-store.hoon

87 lines
1.7 KiB
Plaintext
Raw Normal View History

2020-10-24 19:13:36 +03:00
:: btc-wallet-store.hoon
2020-10-19 12:04:51 +03:00
:: Manages wallet pubkeys
::
2020-10-28 16:20:24 +03:00
:: Subscriptions: none
:: To Subscribers:
:: watched address updates
::
2020-10-29 15:10:54 +03:00
/- *btc-wallet-store
2020-10-30 14:45:38 +03:00
/+ dbug, default-agent, *btc-wallet-store, btc, bip32
2020-10-19 12:04:51 +03:00
|%
+$ versioned-state
$% state-0
==
2020-10-31 18:03:00 +03:00
:: walts: all wallets, keyed by their xpubs
:: scanning: sets of idxs currently being scanned, keyed by xpub+chyg
:: has-used: whether xpub+chyg being scanned has previously used addresses, keyed by xpub+chyg
2020-10-19 12:04:51 +03:00
::
2020-10-30 12:06:42 +03:00
+$ state-0
$: %0
2020-10-31 20:26:58 +03:00
walts=(map xpub:btc _walt)
=scans
2020-10-30 12:06:42 +03:00
==
2020-10-19 12:04:51 +03:00
::
2020-10-24 19:13:36 +03:00
+$ card card:agent:gall
2020-10-19 12:04:51 +03:00
::
--
=| state-0
=* state -
%- agent:dbug
^- agent:gall
2020-10-29 15:10:54 +03:00
=<
2020-10-19 12:04:51 +03:00
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
2020-10-29 15:10:54 +03:00
hc ~(. +> bowl)
2020-10-19 12:04:51 +03:00
::
++ on-init
^- (quip card _this)
2020-10-24 19:13:36 +03:00
~& > '%btc-wallet-store initialized'
2020-10-31 20:26:58 +03:00
`this(state [%0 *(map xpub:btc _walt) *^scans])
2020-10-19 12:04:51 +03:00
++ on-save
^- vase
!>(state)
++ on-load
|= old-state=vase
^- (quip card _this)
2020-10-24 19:13:36 +03:00
~& > '%btc-wallet-store recompiled'
2020-10-19 12:04:51 +03:00
`this(state !<(versioned-state old-state))
++ on-poke
|= [=mark =vase]
^- (quip card _this)
2020-10-29 15:10:54 +03:00
?> (team:title our.bowl src.bowl)
=^ cards state
?+ mark (on-poke:def mark vase)
%btc-wallet-store-action
(handle-action:hc !<(action vase))
==
[cards this]
2020-10-19 12:04:51 +03:00
::
2020-10-29 21:07:43 +03:00
++ on-watch
|= pax=path
^- (quip card _this)
?> (team:title our.bowl src.bowl)
?> ?=([%wallets *] pax)
`this
2020-10-19 12:04:51 +03:00
++ on-leave on-leave:def
++ on-peek on-peek:def
++ on-agent on-agent:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
--
2020-10-29 15:10:54 +03:00
::
|_ =bowl:gall
++ handle-action
|= act=action
^- (quip card _state)
?- -.act
%add-wallet
2020-10-30 14:45:38 +03:00
`state
:: (add-wallet +.act)
2020-10-29 21:07:43 +03:00
::
%update-address
2020-10-29 15:10:54 +03:00
`state
2020-10-30 14:45:38 +03:00
:: (update-address +.act)
==
2020-10-29 15:10:54 +03:00
--