mirror of
https://github.com/urbit/shrub.git
synced 2024-12-24 03:14:30 +03:00
send for scanning if not done
This commit is contained in:
parent
10f060e368
commit
978f434879
@ -27,7 +27,6 @@
|
||||
$: %0
|
||||
walts=(map xpub:btc walt)
|
||||
=scans
|
||||
=gena
|
||||
batch-size=@ud
|
||||
last-block=@ud
|
||||
==
|
||||
@ -48,7 +47,7 @@
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
~& > '%btc-wallet-store initialized'
|
||||
`this(state [%0 *(map xpub:btc walt) *^scans *^gena max-gap:defaults 0])
|
||||
`this(state [%0 *(map xpub:btc walt) *^scans max-gap:defaults 0])
|
||||
++ on-save
|
||||
^- vase
|
||||
!>(state)
|
||||
@ -115,13 +114,7 @@
|
||||
(update-address +.act)
|
||||
::
|
||||
%generate-address
|
||||
=+ uw=(~(get by walts) xpub.act)
|
||||
?~ uw
|
||||
~|("btc-wallet-store: non-existent xpub" !!)
|
||||
=/ [a=address:btc w=walt]
|
||||
~(gen-address wad u.uw chyg.act)
|
||||
:_ state(walts (~(put by walts) xpub.act w))
|
||||
~[(send-update [%generate-address a meta.act])]
|
||||
(generate-address +.act)
|
||||
::
|
||||
%generate-txbu
|
||||
=+ w=(~(get by walts) xpub.act)
|
||||
@ -223,13 +216,15 @@
|
||||
(bump-batch xpub %1)
|
||||
:- (weld cards0 cards1)
|
||||
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
|
||||
:: +update-address: watch the address passed; update wallet if it's used
|
||||
:: - if address is unused, send %address-info request to monitor it
|
||||
:: - if address doesn't have enough confs, send %address-info request to monitor it
|
||||
:: - 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
|
||||
::
|
||||
++ update-address
|
||||
|= [=xpub:btc =chyg =idx utxos=(set utxo) used=? last-block=@ud]
|
||||
^- (quip card _state)
|
||||
|^ ^- (quip card _state)
|
||||
=? state (gth last-block last-block.state)
|
||||
state(last-block last-block)
|
||||
=/ w=(unit walt) (~(get by walts) xpub)
|
||||
@ -246,9 +241,48 @@
|
||||
?~ b `state
|
||||
=. scans
|
||||
(iter-scan u.b(has-used ?|(used has-used.u.b)) xpub chyg idx)
|
||||
:: if address is not used or utxos aren't conf'd, send more-info request
|
||||
::
|
||||
?: empty:(scan-status xpub chyg)
|
||||
(run-scan xpub)
|
||||
`state
|
||||
=^ cards state (run-scan xpub)
|
||||
[(weld (more-info u.w) cards) state]
|
||||
[(more-info u.w) state]
|
||||
::
|
||||
++ more-info
|
||||
|= w=walt
|
||||
^- (list card)
|
||||
?: (is-done w) ~
|
||||
:~
|
||||
%- send-request
|
||||
:* %address-info last-block
|
||||
(~(mk-address wad w chyg) idx)
|
||||
xpub chyg idx
|
||||
==
|
||||
==
|
||||
::
|
||||
++ is-done
|
||||
|= w=walt
|
||||
?& used
|
||||
%+ levy (turn ~(tap in utxos) num-confs)
|
||||
|=(nc=@ud (gte nc confs:w))
|
||||
==
|
||||
::
|
||||
++ num-confs
|
||||
|= =utxo:btc
|
||||
?: =(0 height.utxo) 0
|
||||
(add 1 (sub last-block height.utxo))
|
||||
--
|
||||
:: +generate-address: generate and return address
|
||||
::
|
||||
++ generate-address
|
||||
|= [=xpub =chyg meta=(unit [payer=ship value=sats])]
|
||||
=+ uw=(~(get by walts) xpub)
|
||||
?~ uw
|
||||
~|("btc-wallet-store: non-existent xpub" !!)
|
||||
=/ [addr=address:btc w=walt]
|
||||
~(gen-address wad u.uw chyg)
|
||||
:- ~[(send-update [%generate-address addr meta])]
|
||||
state(walts (~(put by walts) xpub w))
|
||||
::
|
||||
++ scanned-wallets
|
||||
^- (list xpub)
|
||||
@ -271,6 +305,12 @@
|
||||
add
|
||||
(roll values add)
|
||||
::
|
||||
++ send-request
|
||||
|= req=request ^- card
|
||||
:* %give %fact ~[/requests]
|
||||
%btc-wallet-store-request !>(req)
|
||||
==
|
||||
::
|
||||
++ send-update
|
||||
|= upd=update ^- card
|
||||
[%give %fact ~[/updates] %btc-wallet-store-update !>(upd)]
|
||||
|
@ -42,6 +42,7 @@
|
||||
::
|
||||
+$ response
|
||||
$% [%get-address-info utxos=(set utxo) used=? block=@ud]
|
||||
[%create-psbt psbt=cord]
|
||||
[%get-raw-tx =txid =rawtx]
|
||||
[%get-block-count block=@ud]
|
||||
[%get-block-and-fee block=@ud fee=sats]
|
||||
|
@ -9,7 +9,9 @@
|
||||
:: chyg: whether account is (non-)change. 0 or 1
|
||||
:: idx: an address_index
|
||||
:: nixt: next indices to generate addresses from (non-change/change)
|
||||
:: addi: address with metadata inside a change path
|
||||
:: addi: HD path along with UTXOs
|
||||
:: - poll: whether wallet should keep checking this address
|
||||
:: used for newly generated addresses to watch them
|
||||
:: wach: map for watched addresses.
|
||||
:: Membership implies the address is known by outside parties or had prior activity
|
||||
:: scon: indices to initially scan to in (non-)change accounts
|
||||
@ -54,11 +56,9 @@
|
||||
:: scanning addresses and monitoring generated addresses
|
||||
:: batch: indexes to scan for a given chyg
|
||||
:: scans: all scans underway (batches)
|
||||
:: gena: any generated address that hasn't had activity yet
|
||||
::
|
||||
+$ batch [todo=(set idx) endpoint=idx has-used=?]
|
||||
+$ scans (map [xpub chyg] batch)
|
||||
+$ gena (set address)
|
||||
::
|
||||
:: %add-wallet: add wallet to state and initiate a scan
|
||||
:: %address-info: give new data about an address.
|
||||
|
Loading…
Reference in New Issue
Block a user