mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 01:01:37 +03:00
Merge branch 'master' into next/vere
* master: bitcoin: v0.0.2 bitcoin-wallet: set state as default case for handle-provider-update %bitcoin: Implement additional RPC calls from btc-provider. %histogram, %block-headers, %tx-from-pos, %fee, %psbt are now all callable from the btc-provider agent. These actions are necessary in order to get the lightning network working within Urbit. %bitcoin: Added %regtest to arms using the network type definition. %bitcoin: add regtest type to network
This commit is contained in:
commit
9bdbca6095
@ -11,7 +11,7 @@
|
||||
|%
|
||||
++ prefixes
|
||||
^- (map network tape)
|
||||
(my [[%main "bc"] [%testnet "tb"] ~])
|
||||
(my [[%main "bc"] [%testnet "tb"] [%regtest "bcrt"] ~])
|
||||
++ charset "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
|
||||
+$ raw-decoded [hrp=tape data=(list @) checksum=(list @)]
|
||||
:: below is a port of: https://github.com/bitcoinjs/bech32/blob/master/index.js
|
||||
|
@ -56,6 +56,8 @@
|
||||
1^0x0
|
||||
%testnet
|
||||
1^0x1
|
||||
%regtest
|
||||
1^0x1
|
||||
==
|
||||
:- (cat:byt ~[1^typ pubkey.h])
|
||||
%- cat:byt
|
||||
|
@ -4,7 +4,7 @@
|
||||
:: chyg: whether account is (non-)change. 0 or 1
|
||||
:: bytc: "btc-byts" with dat cast to @ux
|
||||
|%
|
||||
+$ network ?(%main %testnet)
|
||||
+$ network ?(%main %testnet %regtest)
|
||||
+$ hexb [wid=@ dat=@ux] :: hex byts
|
||||
+$ bits [wid=@ dat=@ub]
|
||||
+$ xpub @ta
|
||||
|
@ -169,12 +169,17 @@
|
||||
%+ req-card act
|
||||
^- action:rpc-types
|
||||
?- -.act
|
||||
%address-info [%get-address-info address.act]
|
||||
%tx-info [%get-tx-vals txid.act]
|
||||
%raw-tx [%get-raw-tx txid.act]
|
||||
%broadcast-tx [%broadcast-tx rawtx.act]
|
||||
%ping [%get-block-info ~]
|
||||
%block-info [%get-block-info block.act]
|
||||
%address-info [%get-address-info address.act]
|
||||
%tx-info [%get-tx-vals txid.act]
|
||||
%raw-tx [%get-raw-tx txid.act]
|
||||
%broadcast-tx [%broadcast-tx rawtx.act]
|
||||
%ping [%get-block-info ~]
|
||||
%block-info [%get-block-info block.act]
|
||||
%histogram [%get-histogram ~]
|
||||
%block-headers [%get-block-headers start.act count.act cp.act]
|
||||
%tx-from-pos [%get-tx-from-pos height.act pos.act merkle.act]
|
||||
%fee [%get-fee block.act]
|
||||
%psbt [%update-psbt psbt.act]
|
||||
==
|
||||
::
|
||||
++ req-card
|
||||
@ -309,6 +314,31 @@
|
||||
?> ?=([%get-block-info *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %block-info network.host-info +.r] ship)]
|
||||
::
|
||||
%histogram
|
||||
?> ?=([%get-histogram *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %histogram +.r] ship)]
|
||||
::
|
||||
%block-headers
|
||||
?> ?=([%get-block-headers *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %block-headers +.r] ship)]
|
||||
::
|
||||
%tx-from-pos
|
||||
?> ?=([%get-tx-from-pos *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %tx-from-pos +.r] ship)]
|
||||
::
|
||||
%fee
|
||||
?> ?=([%get-fee *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %fee +.r] ship)]
|
||||
::
|
||||
%psbt
|
||||
?> ?=([%update-psbt *] r)
|
||||
:_ state
|
||||
~[(send-update:hc [%.y %psbt +.r] ship)]
|
||||
==
|
||||
::
|
||||
++ connection-error
|
||||
|
@ -900,7 +900,7 @@
|
||||
?: =(~ prov) `state
|
||||
?. =(host:(need prov) src.bowl) `state
|
||||
?. ?=(%.y -.upd) `state
|
||||
?- -.p.upd
|
||||
?+ -.p.upd `state
|
||||
%address-info
|
||||
:: located in the helper in Scan Logic to keep all of that unified
|
||||
::
|
||||
|
@ -5,7 +5,7 @@
|
||||
glob-http+['https://bootstrap.urbit.org/glob-0v3.7b5q1.gn30e.cpfem.abmqg.qh77v.glob' 0v3.7b5q1.gn30e.cpfem.abmqg.qh77v]
|
||||
image+'https://urbit.ewr1.vultrobjects.com/hastuc-dibtux/2021.8.24..02.57.38-bitcoin.svg'
|
||||
base+'bitcoin'
|
||||
version+[0 0 1]
|
||||
version+[0 0 2]
|
||||
license+'MIT'
|
||||
website+'https://tlon.io'
|
||||
==
|
||||
|
@ -74,6 +74,7 @@
|
||||
:- ?- network
|
||||
%main 1^0x0
|
||||
%testnet 1^0x6f
|
||||
%regtest 1^0x6f
|
||||
==
|
||||
~[(hash-160:bcu pubkey)]
|
||||
::
|
||||
@ -84,6 +85,7 @@
|
||||
:~ ?- network
|
||||
%main 1^0x5
|
||||
%testnet 1^0xc4
|
||||
%regtest 1^0xc4
|
||||
==
|
||||
%- hash-160:bcu
|
||||
(cat:byt:bcu ~[2^0x14 (hash-160:bcu pubkey)])
|
||||
@ -109,7 +111,8 @@
|
||||
++ is-base58
|
||||
|= at=tape
|
||||
^- ?
|
||||
?| =("m" (scag 1 at))
|
||||
?| =("n" (scag 1 at))
|
||||
=("m" (scag 1 at))
|
||||
=("1" (scag 1 at))
|
||||
=("3" (scag 1 at))
|
||||
=("2" (scag 1 at))
|
||||
@ -120,6 +123,7 @@
|
||||
^- ?
|
||||
?| =("bc1" (scag 3 at))
|
||||
=("tb1" (scag 3 at))
|
||||
=("bcrt1" (scag 5 at))
|
||||
==
|
||||
--
|
||||
::
|
||||
|
@ -423,6 +423,21 @@
|
||||
::
|
||||
%get-block-info
|
||||
[id.res (block-info res.res)]
|
||||
::
|
||||
%get-histogram
|
||||
[id.res ((ar (ar ni)) res.res)]
|
||||
::
|
||||
%get-block-headers
|
||||
[id.res (block-headers res.res)]
|
||||
::
|
||||
%get-tx-from-pos
|
||||
[id.res (tx-from-pos res.res)]
|
||||
::
|
||||
%get-fee
|
||||
[id.res (ne res.res)]
|
||||
::
|
||||
%update-psbt
|
||||
[id.res (so res.res)]
|
||||
==
|
||||
::
|
||||
++ address-info
|
||||
@ -433,7 +448,7 @@
|
||||
[%block ni]
|
||||
==
|
||||
++ utxo
|
||||
%- ot
|
||||
%- ot
|
||||
:~ ['tx_pos' ni]
|
||||
['tx_hash' (cu from-cord:hxb:bcu so)]
|
||||
[%height ni]
|
||||
@ -474,11 +489,25 @@
|
||||
[%blockhash (cu from-cord:hxb:bcu so)]
|
||||
[%blockfilter (cu from-cord:hxb:bcu so)]
|
||||
==
|
||||
++ block-headers
|
||||
%- ot
|
||||
:~ [%count ni]
|
||||
[%hex (cu from-cord:hxb:bcu so)]
|
||||
[%max ni]
|
||||
[%root (cu:dejs-soft:format from-cord:hxb:bcu so:dejs-soft:format)]
|
||||
[%branch (ar (cu from-cord:hxb:bcu so))]
|
||||
==
|
||||
++ tx-from-pos
|
||||
%- ot
|
||||
:~ [%tx-hash (cu from-cord:hxb:bcu so)]
|
||||
[%merkle (ar (cu from-cord:hxb:bcu so))]
|
||||
==
|
||||
--
|
||||
--
|
||||
::
|
||||
++ rpc-action-to-http
|
||||
|= [endpoint=@t ract=action:rpc-types:bp]
|
||||
=, enjs:format
|
||||
|^ ^- request:http
|
||||
?- -.ract
|
||||
%get-address-info
|
||||
@ -510,6 +539,39 @@
|
||||
?~(block.ract '' (rsh [3 2] (scot %ui u.block.ract)))
|
||||
%- get-request
|
||||
(mk-url '/getblockinfo/' param)
|
||||
::
|
||||
%get-histogram
|
||||
%- get-request
|
||||
(mk-url '/feehistogram' '')
|
||||
::
|
||||
%get-block-headers
|
||||
%+ post-request
|
||||
%+ mk-url '/blockheaders' ''
|
||||
%- pairs
|
||||
:~ [%start (numb start.ract)]
|
||||
[%count (numb count.ract)]
|
||||
[%cp (numb (fall cp.ract 0))]
|
||||
==
|
||||
::
|
||||
%get-tx-from-pos
|
||||
%+ post-request
|
||||
%+ mk-url '/txfrompos' ''
|
||||
%- pairs
|
||||
:~ [%height (numb height.ract)]
|
||||
[%pos (numb pos.ract)]
|
||||
[%merkle %b merkle.ract]
|
||||
==
|
||||
::
|
||||
%get-fee
|
||||
%- get-request
|
||||
%+ mk-url '/estimatefee/'
|
||||
%- crip
|
||||
%+ scow %ud block.ract
|
||||
::
|
||||
%update-psbt
|
||||
%- get-request
|
||||
%+ mk-url '/updatepsbt/'
|
||||
%- en:base64:mimes:html [(lent (trip psbt.ract)) psbt.ract]
|
||||
==
|
||||
++ mk-url
|
||||
|= [base=@t params=@t]
|
||||
|
@ -33,6 +33,11 @@
|
||||
[%broadcast-tx rawtx=hexb]
|
||||
[%ping ~]
|
||||
[%block-info block=(unit @ud)]
|
||||
[%histogram ~]
|
||||
[%block-headers start=@ud count=@ud cp=(unit @ud)]
|
||||
[%tx-from-pos height=@ud pos=@ud merkle=?]
|
||||
[%fee block=@ud]
|
||||
[%psbt psbt=@t]
|
||||
==
|
||||
::
|
||||
+$ result
|
||||
@ -41,6 +46,11 @@
|
||||
[%raw-tx txid=hexb rawtx=hexb]
|
||||
[%broadcast-tx txid=hexb broadcast=? included=?]
|
||||
[%block-info =network block=@ud fee=(unit sats) blockhash=hexb blockfilter=hexb]
|
||||
[%histogram hist=(list (list @ud))]
|
||||
[%block-headers count=@ud hex=hexb max=@ud root=(unit hexb) branch=(list hexb)]
|
||||
[%tx-from-pos tx-hash=hexb merkle=(list hexb)]
|
||||
[%fee fee=@rd]
|
||||
[%psbt psbt=@t]
|
||||
==
|
||||
+$ error
|
||||
$% [%not-connected status=@ud]
|
||||
@ -64,6 +74,11 @@
|
||||
[%broadcast-tx rawtx=hexb]
|
||||
[%get-block-count ~]
|
||||
[%get-block-info block=(unit @ud)]
|
||||
[%get-histogram ~]
|
||||
[%get-block-headers start=@ud count=@ud cp=(unit @ud)]
|
||||
[%get-tx-from-pos height=@ud pos=@ud merkle=?]
|
||||
[%get-fee block=@ud]
|
||||
[%update-psbt psbt=@t]
|
||||
==
|
||||
::
|
||||
+$ result
|
||||
@ -74,7 +89,11 @@
|
||||
[%broadcast-tx txid=hexb broadcast=? included=?]
|
||||
[%get-block-count block=@ud]
|
||||
[%get-block-info block=@ud fee=(unit sats) blockhash=hexb blockfilter=hexb]
|
||||
|
||||
[%get-histogram hist=(list (list @ud))]
|
||||
[%get-block-headers count=@ud hex=hexb max=@ud root=(unit hexb) branch=(list hexb)]
|
||||
[%get-tx-from-pos tx-hash=hexb merkle=(list hexb)]
|
||||
[%get-fee fee=@rd]
|
||||
[%update-psbt psbt=@t]
|
||||
==
|
||||
--
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user