mirror of
https://github.com/urbit/shrub.git
synced 2024-12-22 10:21:31 +03:00
change provider types; refactor gen-adress
This commit is contained in:
parent
ca310028f5
commit
926c508961
@ -51,20 +51,21 @@ nixt.st.q.res
|
||||
## Algos
|
||||
|
||||
### Scan addresses
|
||||
* types
|
||||
- req-id=@ux: hash160 of (cat xpub chyg)
|
||||
* maps:
|
||||
- scans ([xpub chyg] -> waltscan)
|
||||
- pend/fail: (req-id -> [=idx key=[xpub chyg]])
|
||||
- timeouts: (req-id -> @da) -- store Behns for each req
|
||||
|
||||
* start scan
|
||||
- get `nixt` from wallet
|
||||
- generate
|
||||
- choose the next N indices
|
||||
- store their indexes in scan
|
||||
- send address+ idx [xpub chyg] to provider
|
||||
|
||||
#### in wallet-hook
|
||||
* types
|
||||
- req-id=@ux: hash160 of (cat xpub chyg)
|
||||
- pend/fail: (req-id -> [=idx key=[xpub chyg]])
|
||||
- timeouts: (req-id -> @da) -- store Behns for each req
|
||||
|
||||
* send address-watch req
|
||||
- send address to provider with req-id
|
||||
- set a Behn for 30s, put in timeouts
|
||||
|
@ -85,7 +85,7 @@
|
||||
|^ ^- (quip card _state)
|
||||
=/ ract=action:rpc
|
||||
?- -.act
|
||||
%get-address-info
|
||||
%watch-address
|
||||
[%erpc %get-address-utxos address.act]
|
||||
==
|
||||
[~[(req-card act ract)] state]
|
||||
|
@ -12,13 +12,14 @@
|
||||
$% state-0
|
||||
==
|
||||
:: 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
|
||||
:: scans: batch info for wallets being scanned
|
||||
:: batch-size: how many addresses to send out at once for checking
|
||||
::
|
||||
+$ state-0
|
||||
$: %0
|
||||
walts=(map xpub:btc _walt)
|
||||
=scans
|
||||
=batch-size
|
||||
==
|
||||
::
|
||||
+$ card card:agent:gall
|
||||
|
@ -32,20 +32,6 @@
|
||||
scan-to.st (fall scan-to *scon)
|
||||
max-gap.st (fall max-gap default-max-gap)
|
||||
==
|
||||
:: generates the next available address
|
||||
:: adds it to wach (i.e. treat it as used and out in the wild)
|
||||
::
|
||||
++ gen-address
|
||||
^- (pair address:btc _this)
|
||||
=^ curr-idx nixt.st
|
||||
bump-nixt
|
||||
=/ addr (mk-address curr-idx)
|
||||
:- addr
|
||||
%= this
|
||||
wach.st %+ ~(put by wach.st)
|
||||
addr
|
||||
[chyg curr-idx *(set utxo:btc)]
|
||||
==
|
||||
::
|
||||
++ mk-address
|
||||
|= =idx
|
||||
@ -55,10 +41,17 @@
|
||||
pub:(derive-public:(derive-public:wilt.st (@ chyg)) idx)
|
||||
?: ?=(%bip84 bipt.st)
|
||||
(need (encode-pubkey:bech32:btc %main pubkey))
|
||||
~|("legacy addresses not supported yet" !!)
|
||||
~|("legacy addresses not supported yet " !!)
|
||||
:: generates and watches the next available address
|
||||
::
|
||||
++ gen-address
|
||||
^- (pair address:btc _this)
|
||||
=/ addr (mk-address nixt-idx)
|
||||
:- addr
|
||||
(watch-address addr [chyg nixt-idx *(set utxo:btc)])
|
||||
:: insert a new address; update "nixt" free address if this one was it
|
||||
::
|
||||
++ insert-address
|
||||
++ watch-address
|
||||
|= [a=address:btc =addi]
|
||||
^- _this
|
||||
?> =(chyg chyg.addi)
|
||||
|
@ -8,7 +8,7 @@
|
||||
$% [%get-address-info =address]
|
||||
==
|
||||
+$ result
|
||||
$% [%get-address-info a=address utxos=(set utxo) used=?]
|
||||
$% [%watch-address a=address utxos=(set utxo) used=?]
|
||||
==
|
||||
+$ error
|
||||
$% [%not-connected ~]
|
||||
|
@ -30,7 +30,7 @@
|
||||
:: start: index this batch started scanning from
|
||||
::
|
||||
+$ batch [todo=(set idx) has-used=? start=idx]
|
||||
+$ scans (map [xpub chyg] batch)
|
||||
+$ scans (map [xpub chyg] batch)
|
||||
::
|
||||
+$ action
|
||||
$% [%add-wallet =xpub scan-to=(unit scon) max-gap=(unit @)]
|
||||
|
Loading…
Reference in New Issue
Block a user