get blockfilter

This commit is contained in:
timlucmiptev 2021-01-26 13:27:32 +02:00 committed by ixv
parent 5a4342d092
commit dc3536e6d4
7 changed files with 65 additions and 37 deletions

View File

@ -63,13 +63,13 @@ Install files:
:btc-wallet-hook|action [%set-provider moon1]
=xpub2 'zpub6r8dKyWJ31XF6n69KKeEwLjVC5ruqAbiJ4QCqLsrV36Mvx9WEjUaiPNPGFLHNCCqgCdy6iZC8ZgHsm6a1AUTVBMVbKGemNcWFcwBGSjJKbD'
=fprint [%4 0xbeef.dead]
:btc-wallet-store|action [%add-wallet xpub2 fprint ~ [~ 8] [~ 6]]
:btc-wallet-store|action [%add-wallet xpub2 fprint ~ [~ 8] [~ 1]]
```
### Request Address
Moon2:
```
:btc-wallet-hook|action [%req-pay-address payee=moon1 value=2.000 [~ 30]]
:btc-wallet-hook|action [%req-pay-address payee=~sarsev-dapwel-timluc-miptev value=10.000 [~ 37]]
:btc-wallet-hook +dbug [%state 'poym']
```

View File

@ -31,7 +31,7 @@
++ on-init
^- (quip card _this)
~& > '%btc-provider initialized successfully'
`this(host-info ['' connected=%.n clients=*(set ship)], whitelist *(set ship))
`this(host-info ['' connected=%.n block=0 clients=*(set ship)], whitelist *(set ship))
++ on-save
^- vase
!>(state)
@ -77,7 +77,7 @@
=^ cards state
?+ +<.sign-arvo (on-arvo:def wire sign-arvo)
%http-response
(handle-rpc-response:hc wire client-response.sign-arvo)
(handle-rpc-response:hc wire client-response.sign-arvo)
==
[cards this]
::
@ -91,7 +91,7 @@
?- -.comm
%set-credentials
:- do-ping
state(host-info [api-url.comm connected=%.n clients=*(set ship)])
state(host-info [api-url.comm connected=%.n block=0 clients=*(set ship)])
::
%whitelist-clients
`state(whitelist (~(uni in whitelist) clients.comm))
@ -119,7 +119,7 @@
[%broadcast-tx rawtx.act]
::
%ping
[%get-block-and-fee ~]
[%get-block-info ~]
==
[~[(req-card act ract)] state]
::
@ -197,9 +197,11 @@
~[(send-update [%.y %broadcast-tx +.r])]
::
%ping
?> ?=([%get-block-and-fee *] r)
:- ~[(send-status [%connected block.r fee.r])]
state(connected.host-info %.y)
?> ?=([%get-block-info *] r)
:_ state(connected.host-info %.y, block.host-info block.r)
?: =(block.host-info block.r)
~[(send-status [%connected block.r fee.r])]
~[(send-status [%new-block block.r fee.r blockhash.r blockfilter.r])]
==
::
++ send-status

View File

@ -31,7 +31,7 @@
::
+$ state-0
$: %0
prov=(unit [host=ship connected=?])
prov=(unit provider)
=reqs
=btc-state
def-wallet=(unit xpub)
@ -310,27 +310,44 @@
++ handle-provider-status
|= s=status:bp
^- (quip card _state)
|^
?~ prov `state
?. =(host.u.prov src.bowl) `state
?- -.s
%new-block
~& >> "%new-block"
(connected u.prov block.s fee.s `blockhash.s `blockfilter.s)
::
%connected
:_ %= state
prov `[host.u.prov %.y]
btc-state [block.s fee.s now.bowl]
==
?: ?!(connected.u.prov)
%- zing
:~ (retry-reqs block.s)
retry-poym
retry-pend-piym
==
?. (lth block.btc-state block.s)
retry-pend-piym
(weld retry-pend-piym (retry-reqs block.s))
~& >> "%connected"
(connected u.prov block.s fee.s ~ ~)
::
%disconnected
`state(prov `[host.u.prov %.n])
==
::
++ connected
|= $: p=provider
block=@ud
fee=sats
blockhash=(unit bytc)
blockfilter=(unit bytc)
==
^- (quip card _state)
:_ %_ state
prov `[host.p %.y]
btc-state [block fee now.bowl]
==
?: ?!(connected.p)
%- zing
:~ (retry-reqs block)
retry-poym
retry-pend-piym
==
?. (lth block.btc-state block)
retry-pend-piym
(weld retry-pend-piym (retry-reqs block))
--
::
++ handle-provider-update
|= upd=update:bp

View File

@ -108,8 +108,8 @@
%get-block-count
[id.res (ni:dejs:format res.res)]
::
%get-block-and-fee
[id.res (block-and-fee res.res)]
%get-block-info
[id.res (block-info res.res)]
==
++ address-info
%- ot:dejs:format
@ -126,7 +126,7 @@
[%value ni:dejs:format]
[%recvd (cu:dejs:format from-epoch ni:dejs:format)]
==
++ tx-vals
++ tx-vals
%- ot:dejs:format
:~ [%included bo:dejs:format]
[%txid (cu:dejs:format to-hash256 so:dejs:format)]
@ -153,10 +153,12 @@
[%broadcast bo:dejs:format]
[%included bo:dejs:format]
==
++ block-and-fee
++ block-info
%- ot:dejs:format
:~ [%block ni:dejs:format]
[%fee ni:dejs:format]
[%blockhash (cu:dejs:format to-bytc so:dejs:format)]
[%blockfilter (cu:dejs:format to-bytc so:dejs:format)]
==
--
--
@ -189,9 +191,9 @@
%- get-request
(mk-url '/getblockcount' '')
::
%get-block-and-fee
%get-block-info
%- get-request
(mk-url '/getblockandfee' '')
(mk-url '/getblockinfo' '')
==
++ mk-url
|= [base=@t params=@t]

View File

@ -75,8 +75,8 @@
==
++ txo-data
|= =txo
:* (script-pubkey:btc address.txo)
value.txo
:- (script-pubkey:btc address.txo)
value.txo
--
::
++ fee
@ -134,8 +134,8 @@
|= =idx:btc
^- address:btc
?: ?=(%84 bipt.w)
(need (encode-pubkey:bech32:btc %main dat:(pubkey idx)))
~|("legacy addresses not supported yet " !!)
(need (encode-pubkey:bech32:btc %main (pubkey idx)))
~|("base58 addresses not supported yet " !!)
:: +nixt-address: used to get change addresses
:: - gets the current next available address
:: - doesn't bump nixt-address if it's unused

View File

@ -1,6 +1,11 @@
/- *btc
|%
+$ host-info [api-url=@t connected=? clients=(set ship)]
+$ host-info
$: api-url=@t
connected=?
block=@ud
clients=(set ship)
==
+$ command
$% [%set-credentials api-url=@t]
[%whitelist-clients clients=(set ship)]
@ -26,7 +31,8 @@
==
+$ update (each result error)
+$ status
$% [%connected block=@ud fee=@ud]
$% [%connected block=@ud fee=sats]
[%new-block block=@ud fee=sats blockhash=bytc blockfilter=bytc]
[%disconnected ~]
==
::
@ -38,7 +44,7 @@
[%get-raw-tx =txid]
[%broadcast-tx =rawtx]
[%get-block-count ~]
[%get-block-and-fee ~]
[%get-block-info ~]
==
::
+$ result
@ -48,7 +54,7 @@
[%create-raw-tx =rawtx]
[%broadcast-tx =txid broadcast=? included=?]
[%get-block-count block=@ud]
[%get-block-and-fee block=@ud fee=sats]
[%get-block-info block=@ud fee=sats blockhash=bytc blockfilter=bytc]
==
--

View File

@ -11,6 +11,7 @@
:: pend-piym: incoming payment txs that peer says they have broadcast
:: poym: outgoing payments. One at a time: new replaces old
::
+$ provider [host=ship connected=?]
+$ block @ud
+$ btc-state [=block fee=sats t=@da]
+$ reqs (map $?(address txid) request:bws)