mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-14 17:41:33 +03:00
address transformations to HTTP
This commit is contained in:
parent
87b7b230f6
commit
290ed873ab
@ -122,6 +122,7 @@
|
||||
|= ract=rpc-action
|
||||
^- request:http
|
||||
?- -.ract
|
||||
|
||||
%erpc
|
||||
(gen-electrum-request +.ract)
|
||||
%brpc
|
||||
|
@ -27,6 +27,13 @@ The below requires norsyr's fix to `decompress-point` in order to work.
|
||||
:btc-node-hook|action [%list-unspent [~ [~ ~ `~[[%bech32 'bc1q20xxd4rep620a0754gc7du9tlxj0h3lu2xwyg5']] ~ ~]]]
|
||||
```
|
||||
|
||||
## Transactions
|
||||
bc1q59u5epktervh6fxqay2dlph0wxu9hjnx6v8n66
|
||||
|
||||
```
|
||||
createrawtransaction '[{"txid" : "033f693fdf995a5ea7fe5c951ab6858c7e6a5fffc58579922cd4fc319c614c5b", "vout" : 0}]' '{"bc1qwsqxh3sdjqgdxl7ewgxftdfm8jjajta5xmv8eu" : 0.00001}'
|
||||
```
|
||||
|
||||
## Handling XPubs
|
||||
**Import lib; optionally set up env**
|
||||
XPub is BIP84, mnemonic:
|
||||
@ -50,6 +57,15 @@ abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon
|
||||
`@ux`(compress-point:ecc pub:(derive-public:(derive-public:(from-extended:bip32 xpub) 0) 0))
|
||||
```
|
||||
|
||||
## Legacy BTC Address Parsing
|
||||
```
|
||||
:: yields the initial addresss
|
||||
`@uc`(scan "17xg1BZLn63zCxdTxbsFLoWpQeSnD7zSHW" fim:ag)
|
||||
|
||||
:: as a cord
|
||||
`@t`(scot %uc `@uc`(scan "17xg1BZLn63zCxdTxbsFLoWpQeSnD7zSHW" fim:ag))
|
||||
```
|
||||
|
||||
## BIP 173 (Bech32 Addresses)
|
||||
```
|
||||
=btc -build-file %/lib/btc/hoon
|
||||
|
27
lib/electrum-rpc-http.hoon
Normal file
27
lib/electrum-rpc-http.hoon
Normal file
@ -0,0 +1,27 @@
|
||||
/- *btc-bridge, *btc
|
||||
/+ lib=btc-node-json
|
||||
|%
|
||||
++ address-to-cord
|
||||
|= =address ^- cord
|
||||
?: ?=([%legacy *] address)
|
||||
(scot %uc +.address)
|
||||
+.address
|
||||
++ http-request
|
||||
|= url=@t
|
||||
^- request:http
|
||||
[%'GET' url ~ ~]
|
||||
::
|
||||
++ electrum-rpc
|
||||
|%
|
||||
++ request-to-http
|
||||
|= [endpoint=@t req=request:electrum:rpc]
|
||||
^- request:http
|
||||
?- -.req
|
||||
%get-address-balance
|
||||
%- http-request
|
||||
%^ cat 3
|
||||
(cat 3 endpoint '/addresses/balance/')
|
||||
(address-to-cord address.req)
|
||||
==
|
||||
--
|
||||
--
|
@ -1,21 +0,0 @@
|
||||
/- *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,5 +1,6 @@
|
||||
|%
|
||||
+$ network ?(%main %testnet)
|
||||
+$ bech32-address $%([%bech32 tape])
|
||||
+$ address ?(@uc bech32-address)
|
||||
+$ legacy-address $%([%legacy @uc])
|
||||
+$ bech32-address $%([%bech32 cord])
|
||||
+$ address ?(legacy-address bech32-address)
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user