change provider types; refactor gen-adress

This commit is contained in:
timlucmiptev 2020-11-02 12:51:07 +02:00 committed by ixv
parent ca310028f5
commit 926c508961
6 changed files with 21 additions and 26 deletions

View File

@ -51,20 +51,21 @@ nixt.st.q.res
## Algos ## Algos
### Scan addresses ### Scan addresses
* types
- req-id=@ux: hash160 of (cat xpub chyg)
* maps: * maps:
- scans ([xpub chyg] -> waltscan) - scans ([xpub chyg] -> waltscan)
- pend/fail: (req-id -> [=idx key=[xpub chyg]])
- timeouts: (req-id -> @da) -- store Behns for each req
* start scan * start scan
- get `nixt` from wallet - get `nixt` from wallet
- generate - choose the next N indices
- store their indexes in scan - store their indexes in scan
- send address+ idx [xpub chyg] to provider - send address+ idx [xpub chyg] to provider
#### in wallet-hook #### 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-watch req
- send address to provider with req-id - send address to provider with req-id
- set a Behn for 30s, put in timeouts - set a Behn for 30s, put in timeouts

View File

@ -85,7 +85,7 @@
|^ ^- (quip card _state) |^ ^- (quip card _state)
=/ ract=action:rpc =/ ract=action:rpc
?- -.act ?- -.act
%get-address-info %watch-address
[%erpc %get-address-utxos address.act] [%erpc %get-address-utxos address.act]
== ==
[~[(req-card act ract)] state] [~[(req-card act ract)] state]

View File

@ -12,13 +12,14 @@
$% state-0 $% state-0
== ==
:: walts: all wallets, keyed by their xpubs :: walts: all wallets, keyed by their xpubs
:: scanning: sets of idxs currently being scanned, keyed by xpub+chyg :: scans: batch info for wallets being scanned
:: has-used: whether xpub+chyg being scanned has previously used addresses, keyed by xpub+chyg :: batch-size: how many addresses to send out at once for checking
:: ::
+$ state-0 +$ state-0
$: %0 $: %0
walts=(map xpub:btc _walt) walts=(map xpub:btc _walt)
=scans =scans
=batch-size
== ==
:: ::
+$ card card:agent:gall +$ card card:agent:gall

View File

@ -32,20 +32,6 @@
scan-to.st (fall scan-to *scon) scan-to.st (fall scan-to *scon)
max-gap.st (fall max-gap default-max-gap) 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 ++ mk-address
|= =idx |= =idx
@ -55,10 +41,17 @@
pub:(derive-public:(derive-public:wilt.st (@ chyg)) idx) pub:(derive-public:(derive-public:wilt.st (@ chyg)) idx)
?: ?=(%bip84 bipt.st) ?: ?=(%bip84 bipt.st)
(need (encode-pubkey:bech32:btc %main pubkey)) (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 a new address; update "nixt" free address if this one was it
:: ::
++ insert-address ++ watch-address
|= [a=address:btc =addi] |= [a=address:btc =addi]
^- _this ^- _this
?> =(chyg chyg.addi) ?> =(chyg chyg.addi)

View File

@ -8,7 +8,7 @@
$% [%get-address-info =address] $% [%get-address-info =address]
== ==
+$ result +$ result
$% [%get-address-info a=address utxos=(set utxo) used=?] $% [%watch-address a=address utxos=(set utxo) used=?]
== ==
+$ error +$ error
$% [%not-connected ~] $% [%not-connected ~]