mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 01:52:42 +03:00
move Electrum to GET
This commit is contained in:
parent
fd0655b068
commit
87b7b230f6
@ -2,7 +2,7 @@
|
|||||||
:: Proxy for accessing BTC full node
|
:: Proxy for accessing BTC full node
|
||||||
::
|
::
|
||||||
/- *btc-bridge, bnh=btc-node-hook
|
/- *btc-bridge, bnh=btc-node-hook
|
||||||
/+ dbug, default-agent, base64, lib=btc-node-json
|
/+ dbug, default-agent, base64, blib=btc-node-json
|
||||||
|%
|
|%
|
||||||
+$ versioned-state
|
+$ versioned-state
|
||||||
$% state-0
|
$% state-0
|
||||||
@ -47,11 +47,7 @@
|
|||||||
%btc-bridge-command
|
%btc-bridge-command
|
||||||
(handle-command:hc !<(command vase))
|
(handle-command:hc !<(command vase))
|
||||||
%btc-bridge-rpc-action
|
%btc-bridge-rpc-action
|
||||||
=/ act=rpc-action !<(rpc-action vase)
|
(handle-rpc-action !<(rpc-action vase))
|
||||||
?+ -.act (on-poke:def mark vase)
|
|
||||||
%brpc
|
|
||||||
(handle-action +.act)
|
|
||||||
==
|
|
||||||
==
|
==
|
||||||
[cards this]
|
[cards this]
|
||||||
::
|
::
|
||||||
@ -90,22 +86,25 @@
|
|||||||
`state(clients.status (~(uni in clients.status) users.comm))
|
`state(clients.status (~(uni in clients.status) users.comm))
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
++ gen-request
|
++ btc-rpc-auth-header
|
||||||
|= act=btc-node-hook-action:bnh
|
=* user rpc-user.bc.credentials
|
||||||
|
=* pass rpc-password.bc.credentials
|
||||||
|
:- 'Authorization'
|
||||||
|
;: (cury cat 3)
|
||||||
|
'Basic '
|
||||||
|
%- ~(en base64 | &)
|
||||||
|
(as-octs:mimes:html :((cury cat 3) user ':' pass))
|
||||||
|
==
|
||||||
|
++ gen-btc-request
|
||||||
|
|= req=request:bitcoin-core:rpc
|
||||||
^- request:http
|
^- request:http
|
||||||
=* user rpc-user.credentials
|
=* endpoint rpc-url.bc.credentials
|
||||||
=* pass rpc-password.credentials
|
|
||||||
=* endpoint rpc-url.credentials
|
|
||||||
=/ body=request:rpc:jstd
|
=/ body=request:rpc:jstd
|
||||||
(request-to-rpc:btc-rpc:lib act)
|
(request-to-rpc:btc-rpc:blib req)
|
||||||
=/ =header-list:http
|
=/ =header-list:http
|
||||||
:~ ['Content-Type' 'application/json']
|
:~ ['Content-Type' 'application/json']
|
||||||
:- 'Authorization'
|
btc-rpc-auth-header
|
||||||
;: (cury cat 3)
|
==
|
||||||
'Basic '
|
|
||||||
%- ~(en base64 | &)
|
|
||||||
(as-octs:mimes:html :((cury cat 3) user ':' pass))
|
|
||||||
== ==
|
|
||||||
:* %'POST'
|
:* %'POST'
|
||||||
endpoint
|
endpoint
|
||||||
header-list
|
header-list
|
||||||
@ -115,12 +114,26 @@
|
|||||||
(en-json (request-to-json:rpc:jstd body))
|
(en-json (request-to-json:rpc:jstd body))
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ handle-action
|
++ gen-electrum-request
|
||||||
|= act=btc-node-hook-action:bnh
|
|= req=request:electrum:rpc
|
||||||
|
~& >>> req
|
||||||
|
*request:http
|
||||||
|
++ gen-request
|
||||||
|
|= ract=rpc-action
|
||||||
|
^- request:http
|
||||||
|
?- -.ract
|
||||||
|
%erpc
|
||||||
|
(gen-electrum-request +.ract)
|
||||||
|
%brpc
|
||||||
|
(gen-btc-request +.ract)
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ handle-rpc-action
|
||||||
|
|= ract=rpc-action
|
||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
=/ out *outbound-config:iris
|
=/ out *outbound-config:iris
|
||||||
=/ req=request:http
|
=/ req=request:http
|
||||||
(gen-request act)
|
(gen-request ract)
|
||||||
:_ state
|
:_ state
|
||||||
[%pass /[(scot %da now.bowl)] %arvo %i %request req out]~
|
[%pass /[(scot %da now.bowl)] %arvo %i %request req out]~
|
||||||
::
|
::
|
||||||
@ -184,7 +197,7 @@
|
|||||||
?. ?=([%result *] rpc-resp)
|
?. ?=([%result *] rpc-resp)
|
||||||
~& [%error +.rpc-resp]
|
~& [%error +.rpc-resp]
|
||||||
[~ state]
|
[~ state]
|
||||||
~& > (parse-response:btc-rpc:lib rpc-resp)
|
~& > (parse-response:btc-rpc:blib rpc-resp)
|
||||||
[~ state]
|
[~ state]
|
||||||
::
|
::
|
||||||
--
|
--
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
## NOTE
|
## NOTE
|
||||||
The below requires norsyr's fix to `decompress-point` in order to work.
|
The below requires norsyr's fix to `decompress-point` in order to work.
|
||||||
|
|
||||||
|
## Set Credentials and Ping Servers
|
||||||
|
```
|
||||||
|
:btc-bridge|command [%become-host [rpc-url='http://localhost:8332' rpc-user='__cookie__' rpc-password='b813c98bde1d4489e2889269559d1f42920fb367c59ed43eb7668ceeabde2272'] [rpc-url='http://localhost:50001']]
|
||||||
|
|
||||||
|
:btc-bridge|rpc-action [%brpc %get-block-count ~]
|
||||||
|
:btc-bridge|rpc-action [%erpc %get-balance-scripthash 'c5d92092c3d6793e159d93a195c4b12b4110d2b4721862b1e208ae206858c25c']
|
||||||
|
```
|
||||||
|
|
||||||
## Working with BTC RPC Library
|
## Working with BTC RPC Library
|
||||||
```
|
```
|
||||||
|start :btc-bridge
|
|start :btc-bridge
|
||||||
|
21
lib/electrum-rpc-json.hoon
Normal file
21
lib/electrum-rpc-json.hoon
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/- *btc-bridge
|
||||||
|
/+ lib=btc-node-json
|
||||||
|
:: dummy core until needed
|
||||||
|
|%
|
||||||
|
++ blank 42
|
||||||
|
:: TODO: generate GET URLS here, or even the whole http request!!
|
||||||
|
:: ++ electrum-rpc
|
||||||
|
:: |%
|
||||||
|
:: ++ request-to-rpc
|
||||||
|
:: =, enjs:format
|
||||||
|
:: |= req=request:electrum:rpc
|
||||||
|
:: ^- request:rpc:jstd
|
||||||
|
:: ?- -.req
|
||||||
|
:: %get-address-balance
|
||||||
|
:: :* id='0'
|
||||||
|
:: method='blockchain.scripthash.get_balance'
|
||||||
|
:: params=[%list ~[[%s address.req]]]
|
||||||
|
:: ==
|
||||||
|
:: ==
|
||||||
|
:: --
|
||||||
|
--
|
@ -1,7 +1,8 @@
|
|||||||
/- *btc, bnh=btc-node-hook
|
/- *btc, bnh=btc-node-hook
|
||||||
|
|
||||||
|%
|
|%
|
||||||
+$ credentials [rpc-url=@t rpc-user=@t rpc-password=@t]
|
+$ btc-credentials [rpc-url=@t rpc-user=@t rpc-password=@t]
|
||||||
|
+$ electrum-credentials [rpc-url=@t]
|
||||||
|
+$ credentials [bc=btc-credentials ec=electrum-credentials]
|
||||||
+$ status
|
+$ status
|
||||||
$% [%host connected=? clients=(set ship)]
|
$% [%host connected=? clients=(set ship)]
|
||||||
[%client connected=? host=(unit ship)]
|
[%client connected=? host=(unit ship)]
|
||||||
@ -19,20 +20,21 @@
|
|||||||
[%allow-clients users=(set ship)]
|
[%allow-clients users=(set ship)]
|
||||||
==
|
==
|
||||||
+$ rpc-action
|
+$ rpc-action
|
||||||
$% [%erpc action:electrum:rpc]
|
$% [%erpc request:electrum:rpc]
|
||||||
[%brpc action:bitcoin-core:rpc]
|
[%brpc request:bitcoin-core:rpc]
|
||||||
==
|
==
|
||||||
++ rpc
|
++ rpc
|
||||||
|%
|
|%
|
||||||
++ electrum
|
++ electrum
|
||||||
|%
|
|%
|
||||||
+$ action
|
+$ request
|
||||||
$% [%timluc ~]
|
$% [%get-address-balance =address]
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
++ bitcoin-core
|
++ bitcoin-core
|
||||||
|%
|
|%
|
||||||
+$ action btc-node-hook-action:bnh
|
+$ request btc-node-hook-action:bnh
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user