mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-27 00:44:27 +03:00
Merge branch 'ixv/btc-filter'
This commit is contained in:
commit
fd663e0d2b
@ -85,8 +85,7 @@
|
|||||||
::
|
::
|
||||||
?> ?=([%clients *] pax)
|
?> ?=([%clients *] pax)
|
||||||
?. (is-whitelisted:hc src.bowl)
|
?. (is-whitelisted:hc src.bowl)
|
||||||
~& >>> "btc-provider: blocked client {<src.bowl>}"
|
~|("btc-provider: blocked client {<src.bowl>}" !!)
|
||||||
[~[[%give %kick ~ ~]] this]
|
|
||||||
~& > "btc-provider: accepted client {<src.bowl>}"
|
~& > "btc-provider: accepted client {<src.bowl>}"
|
||||||
:- [do-ping:hc]~
|
:- [do-ping:hc]~
|
||||||
this(clients.host-info (~(put in clients.host-info) src.bowl))
|
this(clients.host-info (~(put in clients.host-info) src.bowl))
|
||||||
@ -195,6 +194,9 @@
|
|||||||
::
|
::
|
||||||
%ping
|
%ping
|
||||||
[%get-block-info ~]
|
[%get-block-info ~]
|
||||||
|
::
|
||||||
|
%block-info
|
||||||
|
[%get-block-info block.act]
|
||||||
==
|
==
|
||||||
[~[(req-card act ract)] state]
|
[~[(req-card act ract)] state]
|
||||||
::
|
::
|
||||||
@ -284,6 +286,11 @@
|
|||||||
?: =(block.host-info block.r)
|
?: =(block.host-info block.r)
|
||||||
~[(send-status [%connected network.host-info block.r fee.r])]
|
~[(send-status [%connected network.host-info block.r fee.r])]
|
||||||
~[(send-status [%new-block network.host-info block.r fee.r blockhash.r blockfilter.r])]
|
~[(send-status [%new-block network.host-info block.r fee.r blockhash.r blockfilter.r])]
|
||||||
|
::
|
||||||
|
%block-info
|
||||||
|
?> ?=([%get-block-info *] r)
|
||||||
|
:_ state
|
||||||
|
~[(send-update [%.y %block-info network.host-info +.r])]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ send-status
|
++ send-status
|
||||||
|
@ -167,13 +167,20 @@
|
|||||||
|= [=wire =sign:agent:gall]
|
|= [=wire =sign:agent:gall]
|
||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
?+ -.sign (on-agent:def wire sign)
|
?+ -.sign (on-agent:def wire sign)
|
||||||
|
%watch-ack
|
||||||
|
?~ p.sign `this
|
||||||
|
%- (slog leaf+"connection rejected by provider ({<src.bowl>})" u.p.sign)
|
||||||
|
`this
|
||||||
|
::
|
||||||
%kick
|
%kick
|
||||||
~& >>> "kicked from prov {<src.bowl>}"
|
|
||||||
?~ prov `this
|
?~ prov `this
|
||||||
?: ?& ?=(%set-provider -.wire)
|
?: ?& ?=(%set-provider -.wire)
|
||||||
=(host.u.prov src.bowl)
|
=(host.u.prov src.bowl)
|
||||||
==
|
==
|
||||||
`this(prov ~)
|
:_ this(prov [~ src.bowl %.n])
|
||||||
|
:~ (watch-provider src.bowl)
|
||||||
|
(give-update %change-provider `[src.bowl %.n])
|
||||||
|
==
|
||||||
`this
|
`this
|
||||||
::
|
::
|
||||||
%fact
|
%fact
|
||||||
@ -238,7 +245,6 @@
|
|||||||
?> (team:title our.bowl src.bowl)
|
?> (team:title our.bowl src.bowl)
|
||||||
?- -.comm
|
?- -.comm
|
||||||
%set-provider
|
%set-provider
|
||||||
|^
|
|
||||||
?~ provider.comm
|
?~ provider.comm
|
||||||
?~ prov `state
|
?~ prov `state
|
||||||
:_ state(prov ~)
|
:_ state(prov ~)
|
||||||
@ -252,20 +258,6 @@
|
|||||||
(watch-provider u.provider.comm)
|
(watch-provider u.provider.comm)
|
||||||
(give-update %change-provider `[u.provider.comm %.n])
|
(give-update %change-provider `[u.provider.comm %.n])
|
||||||
==
|
==
|
||||||
::
|
|
||||||
++ watch-provider
|
|
||||||
|= who=@p
|
|
||||||
^- card
|
|
||||||
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
|
|
||||||
%watch /clients
|
|
||||||
==
|
|
||||||
++ leave-provider
|
|
||||||
|= who=@p
|
|
||||||
^- card
|
|
||||||
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
|
|
||||||
%leave ~
|
|
||||||
==
|
|
||||||
--
|
|
||||||
::
|
::
|
||||||
%check-provider
|
%check-provider
|
||||||
=/ pax /permitted/(scot %p provider.comm)
|
=/ pax /permitted/(scot %p provider.comm)
|
||||||
@ -685,7 +677,6 @@
|
|||||||
++ handle-provider-status
|
++ handle-provider-status
|
||||||
|= s=status:bp
|
|= s=status:bp
|
||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
|^
|
|
||||||
=^ cards state
|
=^ cards state
|
||||||
?~ prov `state
|
?~ prov `state
|
||||||
?. =(host.u.prov src.bowl) `state
|
?. =(host.u.prov src.bowl) `state
|
||||||
@ -704,102 +695,146 @@
|
|||||||
(give-update %change-provider prov)
|
(give-update %change-provider prov)
|
||||||
cards
|
cards
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ on-connected
|
++ on-connected
|
||||||
|= $: p=provider
|
|= $: p=provider
|
||||||
=network
|
=network
|
||||||
block=@ud
|
block=@ud
|
||||||
fee=(unit sats)
|
fee=(unit sats)
|
||||||
blockhash=(unit hexb)
|
blockhash=(unit hexb)
|
||||||
blockfilter=(unit hexb)
|
blockfilter=(unit hexb)
|
||||||
==
|
|
||||||
^- (quip card _state)
|
|
||||||
:_ %_ state
|
|
||||||
prov `p(connected %.y)
|
|
||||||
btc-state [block fee now.bowl]
|
|
||||||
==
|
|
||||||
?: ?|(?!(connected.p) (lth block.btc-state block))
|
|
||||||
;: weld
|
|
||||||
(retry-pend-piym network)
|
|
||||||
(retry-poym network)
|
|
||||||
(retry-addrs network)
|
|
||||||
(retry-txs network)
|
|
||||||
(retry-scans network)
|
|
||||||
retry-ahistorical-txs
|
|
||||||
==
|
==
|
||||||
|
^- (quip card _state)
|
||||||
|
:: request block-info for missing blocks
|
||||||
|
:: if blockhash or blockfilter are ~ request block-info for current block
|
||||||
|
::
|
||||||
|
=| blocks=(list @ud)
|
||||||
|
=/ gap (sub block block.btc-state)
|
||||||
|
=? blocks (gth gap 1)
|
||||||
|
(gulf +(block.btc-state) (dec block))
|
||||||
|
=? blocks ?|(?=(~ blockhash) ?=(~ blockfilter))
|
||||||
|
(snoc blocks block)
|
||||||
|
=? blocks (gth gap 50) ~
|
||||||
|
::
|
||||||
|
=/ cards=(list card)
|
||||||
;: weld
|
;: weld
|
||||||
:: (retry-addrs network)
|
|
||||||
retry-ahistorical-txs
|
retry-ahistorical-txs
|
||||||
(retry-pend-piym network)
|
(retry-pend-piym network)
|
||||||
|
(retry-block-info blocks)
|
||||||
==
|
==
|
||||||
::
|
=? cards ?|(!connected.p (gth gap 0))
|
||||||
++ retry-ahistorical-txs
|
;: weld cards
|
||||||
^- (list card)
|
(retry-poym network)
|
||||||
%+ turn ~(tap in ahistorical-txs)
|
(retry-txs network)
|
||||||
|= =txid
|
(retry-scans network)
|
||||||
(poke-provider [%tx-info txid])
|
==
|
||||||
|
=? cards ?&(?=(^ blockhash) ?=(^ blockfilter) (gth gap 0))
|
||||||
::
|
(weld cards (retry-filtered-addrs network u.blockhash u.blockfilter))
|
||||||
++ retry-scans
|
=? cards (gth gap 50)
|
||||||
|= =network
|
(weld cards (retry-addrs network))
|
||||||
^- (list card)
|
:- cards
|
||||||
%- zing
|
%_ state
|
||||||
%+ murn ~(tap by scans)
|
prov `p(connected %.y)
|
||||||
|= [[=xpub:bc =chyg] =batch]
|
btc-state [block fee now.bowl]
|
||||||
?. =(network network:(~(got by walts) xpub)) ~
|
==
|
||||||
`-:(req-scan batch xpub chyg)
|
::
|
||||||
:: +retry-addrs: get info on addresses with unconfirmed UTXOs
|
++ retry-block-info
|
||||||
::
|
|= blocks=(list @ud)
|
||||||
++ retry-addrs
|
%+ turn blocks
|
||||||
|= =network
|
|= block=@ud
|
||||||
^- (list card)
|
(poke-provider %block-info `block)
|
||||||
%- zing
|
::
|
||||||
%+ murn ~(val by walts)
|
++ retry-ahistorical-txs
|
||||||
|= w=walt
|
^- (list card)
|
||||||
?. =(network network.w) ~
|
%+ turn ~(tap in ahistorical-txs)
|
||||||
^- (unit (list card))
|
|= =txid
|
||||||
:- ~
|
(poke-provider [%tx-info txid])
|
||||||
%+ turn ~(tap by wach.w)
|
::
|
||||||
|= [a=address *]
|
++ retry-scans
|
||||||
(poke-provider [%address-info a])
|
|= =network
|
||||||
:: +retry-txs: get info on txs without enough confirmations
|
^- (list card)
|
||||||
::
|
%- zing
|
||||||
++ retry-txs
|
%+ murn ~(tap by scans)
|
||||||
|= =network
|
|= [[=xpub:bc =chyg] =batch]
|
||||||
^- (list card)
|
=/ w (~(get by walts) xpub)
|
||||||
%+ murn ~(tap by history)
|
?~ w ~
|
||||||
|= [=txid =hest]
|
?. =(network network.u.w) ~
|
||||||
=/ w (~(get by walts) xpub.hest)
|
`-:(req-scan batch xpub chyg)
|
||||||
?~ w ~
|
:: +retry-addrs: get info on addresses with unconfirmed UTXOs
|
||||||
?. =(network network.u.w) ~
|
::
|
||||||
?: (gte confs.hest confs.u.w) ~
|
++ retry-addrs
|
||||||
`(poke-provider [%tx-info txid])
|
|= =network
|
||||||
::
|
^- (list card)
|
||||||
++ retry-poym
|
%- zing
|
||||||
|= =network
|
%+ murn ~(val by walts)
|
||||||
^- (list card)
|
|= w=walt
|
||||||
?~ txbu.poym ~
|
?. =(network network.w) ~
|
||||||
=/ w (~(get by walts) xpub.u.txbu.poym)
|
^- (unit (list card))
|
||||||
?~ w ~
|
:- ~
|
||||||
?. =(network network.u.w) ~
|
%+ turn ~(tap by wach.w)
|
||||||
%+ weld
|
|= [a=address *]
|
||||||
?~ signed-tx.u.txbu.poym ~
|
(poke-provider [%address-info a])
|
||||||
~[(poke-provider [%broadcast-tx u.signed-tx.u.txbu.poym])]
|
::
|
||||||
%+ turn txis.u.txbu.poym
|
::
|
||||||
|= =txi
|
++ retry-filtered-addrs
|
||||||
(poke-provider [%raw-tx ~(get-txid txb:bl u.txbu.poym)])
|
|= [=network blockhash=hexb blockfilter=hexb]
|
||||||
:: +retry-pend-piym: check whether txids in pend-piym are in mempool
|
^- (list card)
|
||||||
::
|
%- zing
|
||||||
++ retry-pend-piym
|
%+ murn ~(val by walts)
|
||||||
|= =network
|
|= w=walt
|
||||||
^- (list card)
|
^- (unit (list card))
|
||||||
%+ murn ~(tap by pend.piym)
|
?. =(network network.w) ~
|
||||||
|= [=txid p=payment]
|
:- ~
|
||||||
=/ w (~(get by walts) xpub.p)
|
%+ murn
|
||||||
?~ w ~
|
%~ tap in
|
||||||
?. =(network network.u.w) ~
|
%: all-match:bip-b158:bc
|
||||||
`(poke-provider [%tx-info txid])
|
blockfilter
|
||||||
--
|
blockhash
|
||||||
|
::
|
||||||
|
%+ turn ~(tap by wach.w)
|
||||||
|
|= [a=address *]
|
||||||
|
[a (to-script-pubkey:adr:bc a)]
|
||||||
|
==
|
||||||
|
|= [a=address spk=hexb]
|
||||||
|
^- (unit card)
|
||||||
|
`(poke-provider [%address-info a])
|
||||||
|
:: +retry-txs: get info on txs without enough confirmations
|
||||||
|
::
|
||||||
|
++ retry-txs
|
||||||
|
|= =network
|
||||||
|
^- (list card)
|
||||||
|
%+ murn ~(tap by history)
|
||||||
|
|= [=txid =hest]
|
||||||
|
=/ w (~(get by walts) xpub.hest)
|
||||||
|
?~ w ~
|
||||||
|
?. =(network network.u.w) ~
|
||||||
|
?: (gte confs.hest confs.u.w) ~
|
||||||
|
`(poke-provider [%tx-info txid])
|
||||||
|
::
|
||||||
|
++ retry-poym
|
||||||
|
|= =network
|
||||||
|
^- (list card)
|
||||||
|
?~ txbu.poym ~
|
||||||
|
=/ w (~(get by walts) xpub.u.txbu.poym)
|
||||||
|
?~ w ~
|
||||||
|
?. =(network network.u.w) ~
|
||||||
|
%+ weld
|
||||||
|
?~ signed-tx.u.txbu.poym ~
|
||||||
|
~[(poke-provider [%broadcast-tx u.signed-tx.u.txbu.poym])]
|
||||||
|
%+ turn txis.u.txbu.poym
|
||||||
|
|= =txi
|
||||||
|
(poke-provider [%raw-tx ~(get-txid txb:bl u.txbu.poym)])
|
||||||
|
:: +retry-pend-piym: check whether txids in pend-piym are in mempool
|
||||||
|
::
|
||||||
|
++ retry-pend-piym
|
||||||
|
|= =network
|
||||||
|
^- (list card)
|
||||||
|
%+ murn ~(tap by pend.piym)
|
||||||
|
|= [=txid p=payment]
|
||||||
|
=/ w (~(get by walts) xpub.p)
|
||||||
|
?~ w ~
|
||||||
|
?. =(network network.u.w) ~
|
||||||
|
`(poke-provider [%tx-info txid])
|
||||||
::
|
::
|
||||||
++ handle-provider-update
|
++ handle-provider-update
|
||||||
|= upd=update:bp
|
|= upd=update:bp
|
||||||
@ -833,6 +868,10 @@
|
|||||||
:~ (poke-internal [%fail-broadcast-tx txid.p.upd])
|
:~ (poke-internal [%fail-broadcast-tx txid.p.upd])
|
||||||
(give-update %cancel-tx txid.p.upd)
|
(give-update %cancel-tx txid.p.upd)
|
||||||
==
|
==
|
||||||
|
::
|
||||||
|
%block-info
|
||||||
|
:_ state
|
||||||
|
(retry-filtered-addrs network.p.upd blockhash.p.upd blockfilter.p.upd)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ handle-tx-info
|
++ handle-tx-info
|
||||||
@ -1082,6 +1121,19 @@
|
|||||||
^- card
|
^- card
|
||||||
[%give %fact ~[/all] %btc-wallet-update !>(upd)]
|
[%give %fact ~[/all] %btc-wallet-update !>(upd)]
|
||||||
::
|
::
|
||||||
|
++ watch-provider
|
||||||
|
|= who=@p
|
||||||
|
^- card
|
||||||
|
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
|
||||||
|
%watch /clients
|
||||||
|
==
|
||||||
|
++ leave-provider
|
||||||
|
|= who=@p
|
||||||
|
^- card
|
||||||
|
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
|
||||||
|
%leave ~
|
||||||
|
==
|
||||||
|
::
|
||||||
++ give-initial
|
++ give-initial
|
||||||
^- card
|
^- card
|
||||||
=^ a=(unit address) state
|
=^ a=(unit address) state
|
||||||
|
@ -211,19 +211,20 @@
|
|||||||
$(last-val (add delta last-val))
|
$(last-val (add delta last-val))
|
||||||
:: +all-match: returns all target byts that match
|
:: +all-match: returns all target byts that match
|
||||||
:: - filter: full block filter, with leading N
|
:: - filter: full block filter, with leading N
|
||||||
:: - k: key for siphash (end of blockhash, reversed)
|
|
||||||
:: - targets: scriptpubkeys to match
|
:: - targets: scriptpubkeys to match
|
||||||
::
|
::
|
||||||
++ all-match
|
++ all-match
|
||||||
|= [filter=hexb:bc k=byts targets=(list byts)]
|
|= [filter=hexb:bc blockhash=hexb:bc targets=(list [address:bc byts])]
|
||||||
^- (set hexb:bc)
|
^- (set [address:bc hexb:bc])
|
||||||
%- ~(gas in *(set hexb:bc))
|
=/ k (to-key (trip (to-cord:hxb:bcu blockhash)))
|
||||||
|
%- ~(gas in *(set [address:bc hexb:bc]))
|
||||||
=/ [p=@ m=@] [p:params m:params]
|
=/ [p=@ m=@] [p:params m:params]
|
||||||
=/ [n=@ux gcs-set=bits:bc] (parse-filter filter)
|
=/ [n=@ux gcs-set=bits:bc] (parse-filter filter)
|
||||||
=/ target-map=(map @ hexb:bc)
|
=/ target-map=(map @ [address:bc hexb:bc])
|
||||||
%- ~(gas by *(map @ hexb:bc))
|
%- ~(gas by *(map @ [address:bc hexb:bc]))
|
||||||
%+ turn targets
|
%+ turn targets
|
||||||
|=(t=hexb:bc [(to-range:hsh t (mul n m) k) t])
|
|= [a=address:bc t=hexb:bc]
|
||||||
|
[(to-range:hsh t (mul n m) k) a t]
|
||||||
=+ target-hs=(sort ~(tap in ~(key by target-map)) lth)
|
=+ target-hs=(sort ~(tap in ~(key by target-map)) lth)
|
||||||
=+ last-val=0
|
=+ last-val=0
|
||||||
=| matches=(list @)
|
=| matches=(list @)
|
||||||
@ -244,4 +245,5 @@
|
|||||||
=^ delta gcs-set
|
=^ delta gcs-set
|
||||||
(de:gol gcs-set p)
|
(de:gol gcs-set p)
|
||||||
$(last-val (add delta last-val))
|
$(last-val (add delta last-val))
|
||||||
|
::
|
||||||
--
|
--
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
:: expose BIP libraries
|
:: expose BIP libraries
|
||||||
::
|
::
|
||||||
/- sur=bitcoin
|
/- sur=bitcoin
|
||||||
/+ bech32=bip-b173, pbt=bip-b174, bcu=bitcoin-utils
|
/+ bech32=bip-b173, pbt=bip-b174, bcu=bitcoin-utils, bip-b158
|
||||||
=, sur
|
=, sur
|
||||||
=, bcu
|
=, bcu
|
||||||
|%
|
|%
|
||||||
|
@ -505,8 +505,10 @@
|
|||||||
(mk-url '/getblockcount' '')
|
(mk-url '/getblockcount' '')
|
||||||
::
|
::
|
||||||
%get-block-info
|
%get-block-info
|
||||||
|
=/ param=@t
|
||||||
|
?~(block.ract '' (rsh [3 2] (scot %ui u.block.ract)))
|
||||||
%- get-request
|
%- get-request
|
||||||
(mk-url '/getblockinfo' '')
|
(mk-url '/getblockinfo/' param)
|
||||||
==
|
==
|
||||||
++ mk-url
|
++ mk-url
|
||||||
|= [base=@t params=@t]
|
|= [base=@t params=@t]
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
[%raw-tx txid=hexb]
|
[%raw-tx txid=hexb]
|
||||||
[%broadcast-tx rawtx=hexb]
|
[%broadcast-tx rawtx=hexb]
|
||||||
[%ping ~]
|
[%ping ~]
|
||||||
|
[%block-info block=(unit @ud)]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
+$ result
|
+$ result
|
||||||
@ -38,6 +39,7 @@
|
|||||||
[%tx-info =info:tx]
|
[%tx-info =info:tx]
|
||||||
[%raw-tx txid=hexb rawtx=hexb]
|
[%raw-tx txid=hexb rawtx=hexb]
|
||||||
[%broadcast-tx txid=hexb broadcast=? included=?]
|
[%broadcast-tx txid=hexb broadcast=? included=?]
|
||||||
|
[%block-info =network block=@ud fee=(unit sats) blockhash=hexb blockfilter=hexb]
|
||||||
==
|
==
|
||||||
+$ error
|
+$ error
|
||||||
$% [%not-connected status=@ud]
|
$% [%not-connected status=@ud]
|
||||||
@ -60,7 +62,7 @@
|
|||||||
[%get-raw-tx txid=hexb]
|
[%get-raw-tx txid=hexb]
|
||||||
[%broadcast-tx rawtx=hexb]
|
[%broadcast-tx rawtx=hexb]
|
||||||
[%get-block-count ~]
|
[%get-block-count ~]
|
||||||
[%get-block-info ~]
|
[%get-block-info block=(unit @ud)]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
+$ result
|
+$ result
|
||||||
|
@ -151,9 +151,11 @@
|
|||||||
::
|
::
|
||||||
++ check-all-match
|
++ check-all-match
|
||||||
|= v=match-vector
|
|= v=match-vector
|
||||||
=+ k=(to-key blockhash.v)
|
=/ b=hexb (from-cord:hxb (crip blockhash.v))
|
||||||
|
=/ inc=(list [address hexb]) (turn inc-spks.v |=(h=hexb [*address h]))
|
||||||
|
=/ exc=(list [address hexb]) (turn exc-spks.v |=(h=hexb [*address h]))
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!>(`(set hexb)`(sy inc-spks.v))
|
!>(`(set [address hexb])`(sy inc))
|
||||||
!>(`(set hexb)`(all-match filter.v k (weld inc-spks.v exc-spks.v)))
|
!>(`(set [address hexb])`(all-match filter.v b (weld inc exc)))
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user