2020-10-02 13:40:57 +03:00
|
|
|
:: btc-bridge.hoon
|
|
|
|
:: Proxy for accessing BTC full node
|
2020-09-27 16:16:33 +03:00
|
|
|
::
|
2020-10-03 10:57:16 +03:00
|
|
|
/- *btc-bridge, bnh=btc-node-hook
|
2020-09-27 16:16:33 +03:00
|
|
|
/+ dbug, default-agent
|
|
|
|
|%
|
|
|
|
+$ versioned-state
|
|
|
|
$% state-0
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state-0 [%0 counter=@]
|
|
|
|
::
|
|
|
|
+$ card card:agent:gall
|
|
|
|
::
|
|
|
|
--
|
|
|
|
%- agent:dbug
|
|
|
|
=| state-0
|
|
|
|
=* state -
|
|
|
|
^- agent:gall
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
hc ~(. +> bowl)
|
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
^- (quip card _this)
|
2020-10-02 13:40:57 +03:00
|
|
|
~& > '%btc-bridge initialized successfully'
|
2020-10-03 10:57:16 +03:00
|
|
|
:- ~[[%pass /btc-node-hook/[(scot %da now.bowl)] %agent [our.bowl %btc-node-hook] %watch /responses]]
|
2020-10-02 13:40:57 +03:00
|
|
|
this
|
2020-09-27 16:16:33 +03:00
|
|
|
++ on-save
|
|
|
|
^- vase
|
|
|
|
!>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old-state=vase
|
|
|
|
^- (quip card _this)
|
2020-10-02 13:40:57 +03:00
|
|
|
~& > '%btc-bridge recompiled successfully'
|
2020-09-27 16:16:33 +03:00
|
|
|
`this(state !<(versioned-state old-state))
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%noun
|
|
|
|
?+ q.vase (on-poke:def mark vase)
|
2020-10-02 14:05:41 +03:00
|
|
|
%status
|
|
|
|
:_ this
|
|
|
|
~[[%pass / %agent [our.bowl %btc-node-hook] %poke %btc-node-hook-action !>([%get-block-count ~])]]
|
2020-09-27 16:16:33 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-watch on-watch:def
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
2020-10-02 14:05:41 +03:00
|
|
|
++ on-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
2020-10-03 10:57:16 +03:00
|
|
|
?+ -.sign (on-agent:def wire sign)
|
|
|
|
%fact
|
|
|
|
?+ -.cage.sign (on-agent:def wire sign)
|
|
|
|
%btc-node-hook-response
|
|
|
|
=/ resp=btc-node-hook-response:bnh
|
|
|
|
!<(btc-node-hook-response:bnh +.cage.sign)
|
|
|
|
~& > resp
|
|
|
|
`this
|
|
|
|
==
|
|
|
|
==
|
2020-09-27 16:16:33 +03:00
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
:: helper core
|