mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 05:22:27 +03:00
Merge pull request #5051 from urbit/la/btc-wallet-clean
btc-wallet: refactor and improve performance
This commit is contained in:
commit
116707070e
@ -74,27 +74,25 @@
|
||||
^- (quip card _state)
|
||||
?- -.comm
|
||||
%set-credentials
|
||||
:- :~ do-ping:hc
|
||||
(start-ping-timer:hc ~s30)
|
||||
==
|
||||
%_ state
|
||||
host-info
|
||||
[api-url.comm connected=%.n network.comm block=0 clients=*(set ship)]
|
||||
:_ state(host-info [api-url.comm %.n network.comm 0 *(set ship)])
|
||||
:~ do-ping:hc
|
||||
(start-ping-timer:hc ~s30)
|
||||
==
|
||||
::
|
||||
%add-whitelist
|
||||
:- ~
|
||||
?- -.wt.comm
|
||||
%public
|
||||
`state(public.whitelist %.y)
|
||||
state(public.whitelist %.y)
|
||||
::
|
||||
%kids
|
||||
`state(kids.whitelist %.y)
|
||||
state(kids.whitelist %.y)
|
||||
::
|
||||
%users
|
||||
`state(users.whitelist (~(uni in users.whitelist) users.wt.comm))
|
||||
state(users.whitelist (~(uni in users.whitelist) users.wt.comm))
|
||||
::
|
||||
%groups
|
||||
`state(groups.whitelist (~(uni in groups.whitelist) groups.wt.comm))
|
||||
state(groups.whitelist (~(uni in groups.whitelist) groups.wt.comm))
|
||||
==
|
||||
::
|
||||
%remove-whitelist
|
||||
@ -134,10 +132,10 @@
|
||||
++ handle-action
|
||||
|= act=action
|
||||
^- (quip card _state)
|
||||
:_ state
|
||||
?. ?|(connected.host-info ?=(%ping -.act))
|
||||
~& >>> "Not connected to RPC"
|
||||
[~[(send-update:hc [%| %not-connected 500])] state]
|
||||
:_ state
|
||||
~[(send-update:hc [%| %not-connected 500])]
|
||||
:_ ~
|
||||
%+ req-card act
|
||||
^- action:rpc-types
|
||||
@ -326,8 +324,10 @@
|
||||
(~(has in users.whitelist) user)
|
||||
in-group
|
||||
==
|
||||
::
|
||||
++ is-kid
|
||||
=(our.bowl (sein:title our.bowl now.bowl user))
|
||||
::
|
||||
++ in-group
|
||||
=/ gs ~(tap in groups.whitelist)
|
||||
|-
|
||||
@ -335,7 +335,6 @@
|
||||
?: (~(is-member groupl bowl) user i.gs)
|
||||
%.y
|
||||
$(gs t.gs)
|
||||
:: .^((unit group:g) %gx ;:(weld /=group-store=/groups p /noun))
|
||||
--
|
||||
::
|
||||
++ is-client
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
/- bc=bitcoin
|
||||
/+ bcu=bitcoin-utils
|
||||
~% %bip-158-top ..part ~
|
||||
|%
|
||||
++ params
|
||||
|%
|
||||
@ -8,6 +9,7 @@
|
||||
--
|
||||
::
|
||||
++ siphash
|
||||
~/ %siphash
|
||||
|= [k=byts m=byts]
|
||||
^- byts
|
||||
|^
|
||||
@ -86,25 +88,28 @@
|
||||
:: write appends to the back
|
||||
::
|
||||
++ str
|
||||
~% %str ..params ~
|
||||
|%
|
||||
++ read-bit
|
||||
~/ %read-bit
|
||||
|= s=bits:bc
|
||||
^- [bit=@ub rest=bits:bc]
|
||||
?> (gth wid.s 0)
|
||||
:* ?:((gth wid.s (met 0 dat.s)) 0b0 0b1)
|
||||
[(dec wid.s) (end [0 (dec wid.s)] dat.s)]
|
||||
==
|
||||
:+ ?:((gth wid.s (met 0 dat.s)) 0b0 0b1)
|
||||
(dec wid.s)
|
||||
(end [0 (dec wid.s)] dat.s)
|
||||
::
|
||||
::
|
||||
++ read-bits
|
||||
~/ %read-bits
|
||||
|= [n=@ s=bits:bc]
|
||||
^- [bits:bc rest=bits:bc]
|
||||
=| bs=bits:bc
|
||||
|-
|
||||
?: =(n 0) [bs s]
|
||||
=^ b s (read-bit s)
|
||||
$(n (dec n), bs (write-bits bs [1 b]))
|
||||
=/ r=@ (sub wid.s n)
|
||||
:- n^(cut 0 [r n] dat.s)
|
||||
r^(cut 0 [0 r] dat.s)
|
||||
::
|
||||
++ write-bits
|
||||
~/ %write-bits
|
||||
|= [s1=bits:bc s2=bits:bc]
|
||||
^- bits:bc
|
||||
[(add wid.s1 wid.s2) (can 0 ~[s2 s1])]
|
||||
@ -112,6 +117,7 @@
|
||||
:: +gol: Golomb-Rice encoding/decoding
|
||||
::
|
||||
++ gol
|
||||
~% %gol ..params ~
|
||||
|%
|
||||
:: +en: encode x and append to end of s
|
||||
:: - s: bits stream
|
||||
@ -119,6 +125,7 @@
|
||||
:: - p: golomb-rice p param
|
||||
::
|
||||
++ en
|
||||
~/ %en
|
||||
|= [s=bits:bc x=@ p=@]
|
||||
^- bits:bc
|
||||
=+ q=(rsh [0 p] x)
|
||||
@ -128,6 +135,7 @@
|
||||
(write-bits:str unary r)
|
||||
::
|
||||
++ de
|
||||
~/ %de
|
||||
|= [s=bits:bc p=@]
|
||||
^- [delta=@ rest=bits:bc]
|
||||
|^ ?> (gth wid.s 0)
|
||||
@ -148,6 +156,7 @@
|
||||
:: +hsh
|
||||
::
|
||||
++ hsh
|
||||
~% %hsh ..params ~
|
||||
|%
|
||||
:: +to-range
|
||||
:: - item: scriptpubkey to hash
|
||||
@ -155,6 +164,7 @@
|
||||
:: - k: key for siphash (end of blockhash, reversed)
|
||||
::
|
||||
++ to-range
|
||||
~/ %to-range
|
||||
|= [item=byts f=@ k=byts]
|
||||
^- @
|
||||
(rsh [0 64] (mul f (swp 3 dat:(siphash k item))))
|
||||
@ -171,6 +181,7 @@
|
||||
--
|
||||
::
|
||||
++ parse-filter
|
||||
~/ %parse-filter
|
||||
|= filter=hexb:bc
|
||||
^- [n=@ux gcs-set=bits:bc]
|
||||
=/ n n:(de:csiz:bcu filter)
|
||||
@ -180,6 +191,7 @@
|
||||
:: +to-key: blockhash (little endian) to key for siphash
|
||||
::
|
||||
++ to-key
|
||||
~/ %to-key
|
||||
|= blockhash=tape
|
||||
^- byts
|
||||
%+ take:byt:bcu 16
|
||||
@ -191,6 +203,7 @@
|
||||
:: - targets: scriptpubkeys to match
|
||||
::
|
||||
++ match
|
||||
~/ %match
|
||||
|= [filter=hexb:bc k=byts targets=(list byts)]
|
||||
^- ?
|
||||
=/ [p=@ m=@] [p:params m:params]
|
||||
@ -214,6 +227,7 @@
|
||||
:: - targets: scriptpubkeys to match
|
||||
::
|
||||
++ all-match
|
||||
~/ %all-match
|
||||
|= [filter=hexb:bc blockhash=hexb:bc targets=(list [address:bc byts])]
|
||||
^- (set [address:bc hexb:bc])
|
||||
=/ k (to-key (trip (to-cord:hxb:bcu blockhash)))
|
||||
|
@ -10,8 +10,6 @@ import './css/custom.css';
|
||||
|
||||
// rebuild x3
|
||||
|
||||
window.NETWORK = 'testnet'; // 'bitcoin'
|
||||
|
||||
const channel = new window.channel();
|
||||
api.setChannel(window.ship, channel);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user