last-block, update/watch rolled into address-info

This commit is contained in:
timlucmiptev 2020-11-13 16:05:25 +02:00 committed by ixv
parent 437a88eb20
commit f6afc46bd5
4 changed files with 23 additions and 30 deletions

View File

@ -138,8 +138,8 @@
?~ ureq `state
:_ state(pend (~(del by pend) req-id.p.update))
:~ %- poke-store
:* %watch-address xpub.u.ureq chyg.u.ureq idx.u.ureq
utxos.body.p.update used.body.p.update
:* %address-info xpub.u.ureq chyg.u.ureq idx.u.ureq
utxos.body.p.update used.body.p.update blockcount.body.p.update
==
==
==

View File

@ -102,11 +102,8 @@
=. walts (~(put by walts) xpub.act w)
(init-batches xpub.act (dec max-gap.w))
::
%watch-address
(watch-address +.act)
::
%update-address
`state
%address-info
(update-address +.act)
::
%generate-address
=/ uw=(unit walt) (~(get by walts) xpub.act)
@ -208,21 +205,27 @@
state(scans (insert-batches xpub batch0 batch1))
:: watch the address passed, update wallet if it's used
:: if this idx was the last in todo.scans, do run-scan to see whether scan is done
:: updates wallet-store state to have last-block
::
++ watch-address
|= [=xpub:btc =chyg =idx utxos=(set utxo) used=?]
++ update-address
|= [=xpub:btc =chyg =idx utxos=(set utxo) used=? last-block=@ud]
^- (quip card _state)
?. (~(has by scans) [xpub chyg]) `state
=/ w=walt (~(got by walts) xpub)
=/ b=batch (~(got by scans) [xpub chyg])
=? state (gth last-block last-block.state)
state(last-block last-block)
=/ w=(unit walt) (~(get by walts) xpub)
?~ w `state
=? walts used
%+ ~(put by walts)
xpub
%+ ~(watch-address wad w chyg)
(~(mk-address wad w chyg) idx)
%+ ~(put by walts) xpub
%+ ~(update-address wad u.w chyg)
(~(mk-address wad u.w chyg) idx)
[chyg idx utxos]
:: if the wallet is being scanned, update the scan batch
::
?. (~(has by scans) [xpub chyg]) `state
=/ b=(unit batch) (~(get by scans) [xpub chyg])
?~ b `state
=. scans
(iter-scan b(has-used ?|(used has-used.b)) xpub chyg idx)
(iter-scan u.b(has-used ?|(used has-used.u.b)) xpub chyg idx)
?: empty:(scan-status xpub chyg)
(run-scan xpub)
`state

View File

@ -51,10 +51,10 @@
^- (pair address:btc walt)
=/ addr (mk-address nixt-idx)
:- addr
(watch-address addr [chyg nixt-idx *(set utxo:btc)])
(update-address addr [chyg nixt-idx *(set utxo:btc)])
:: insert a new address; update "nixt" free address if this one was it
::
++ watch-address
++ update-address
|= [a=address:btc =addi]
^- walt
?> =(chyg chyg.addi)
@ -62,15 +62,6 @@
=? nixt.w (is-nixt addi)
new:bump-nixt
w(wach (~(put by wach.w) a addi))
:: update an address if it's in wach map
::
++ update-address
|= [a=address:btc utxos=(set utxo:btc)]
^- walt
=/ adi=(unit addi)
(~(get by wach.w) a)
?~ adi w
w(wach (~(put by wach.w) a u.adi(utxos utxos)))
::
++ is-nixt
|= =addi ^- ?

View File

@ -55,8 +55,7 @@
::
+$ action
$% [%add-wallet =xpub scan-to=(unit scon) max-gap=(unit @ud) confs=(unit @ud)]
[%watch-address =xpub =chyg =idx utxos=(set utxo) used=?]
[%update-address a=address utxos=(set utxo)]
[%address-info =xpub =chyg =idx utxos=(set utxo) used=? blockcount=@ud]
[%generate-address =xpub =chyg]
==
::