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] :btc-wallet-hook|action [%set-provider moon1]
=xpub2 'zpub6r8dKyWJ31XF6n69KKeEwLjVC5ruqAbiJ4QCqLsrV36Mvx9WEjUaiPNPGFLHNCCqgCdy6iZC8ZgHsm6a1AUTVBMVbKGemNcWFcwBGSjJKbD' =xpub2 'zpub6r8dKyWJ31XF6n69KKeEwLjVC5ruqAbiJ4QCqLsrV36Mvx9WEjUaiPNPGFLHNCCqgCdy6iZC8ZgHsm6a1AUTVBMVbKGemNcWFcwBGSjJKbD'
=fprint [%4 0xbeef.dead] =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 ### Request Address
Moon2: 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'] :btc-wallet-hook +dbug [%state 'poym']
``` ```

View File

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

View File

@ -31,7 +31,7 @@
:: ::
+$ state-0 +$ state-0
$: %0 $: %0
prov=(unit [host=ship connected=?]) prov=(unit provider)
=reqs =reqs
=btc-state =btc-state
def-wallet=(unit xpub) def-wallet=(unit xpub)
@ -310,27 +310,44 @@
++ handle-provider-status ++ handle-provider-status
|= s=status:bp |= s=status:bp
^- (quip card _state) ^- (quip card _state)
|^
?~ prov `state ?~ prov `state
?. =(host.u.prov src.bowl) `state ?. =(host.u.prov src.bowl) `state
?- -.s ?- -.s
%new-block
~& >> "%new-block"
(connected u.prov block.s fee.s `blockhash.s `blockfilter.s)
::
%connected %connected
:_ %= state ~& >> "%connected"
prov `[host.u.prov %.y] (connected u.prov block.s fee.s ~ ~)
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))
:: ::
%disconnected %disconnected
`state(prov `[host.u.prov %.n]) `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 ++ handle-provider-update
|= upd=update:bp |= upd=update:bp

View File

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

View File

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

View File

@ -1,6 +1,11 @@
/- *btc /- *btc
|% |%
+$ host-info [api-url=@t connected=? clients=(set ship)] +$ host-info
$: api-url=@t
connected=?
block=@ud
clients=(set ship)
==
+$ command +$ command
$% [%set-credentials api-url=@t] $% [%set-credentials api-url=@t]
[%whitelist-clients clients=(set ship)] [%whitelist-clients clients=(set ship)]
@ -26,7 +31,8 @@
== ==
+$ update (each result error) +$ update (each result error)
+$ status +$ status
$% [%connected block=@ud fee=@ud] $% [%connected block=@ud fee=sats]
[%new-block block=@ud fee=sats blockhash=bytc blockfilter=bytc]
[%disconnected ~] [%disconnected ~]
== ==
:: ::
@ -38,7 +44,7 @@
[%get-raw-tx =txid] [%get-raw-tx =txid]
[%broadcast-tx =rawtx] [%broadcast-tx =rawtx]
[%get-block-count ~] [%get-block-count ~]
[%get-block-and-fee ~] [%get-block-info ~]
== ==
:: ::
+$ result +$ result
@ -48,7 +54,7 @@
[%create-raw-tx =rawtx] [%create-raw-tx =rawtx]
[%broadcast-tx =txid broadcast=? included=?] [%broadcast-tx =txid broadcast=? included=?]
[%get-block-count block=@ud] [%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 :: pend-piym: incoming payment txs that peer says they have broadcast
:: poym: outgoing payments. One at a time: new replaces old :: poym: outgoing payments. One at a time: new replaces old
:: ::
+$ provider [host=ship connected=?]
+$ block @ud +$ block @ud
+$ btc-state [=block fee=sats t=@da] +$ btc-state [=block fee=sats t=@da]
+$ reqs (map $?(address txid) request:bws) +$ reqs (map $?(address txid) request:bws)