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:
Joe Bryan 2022-08-11 15:57:09 -04:00
commit 9bdbca6095
9 changed files with 130 additions and 13 deletions

View File

@ -11,7 +11,7 @@
|% |%
++ prefixes ++ prefixes
^- (map network tape) ^- (map network tape)
(my [[%main "bc"] [%testnet "tb"] ~]) (my [[%main "bc"] [%testnet "tb"] [%regtest "bcrt"] ~])
++ charset "qpzry9x8gf2tvdw0s3jn54khce6mua7l" ++ charset "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
+$ raw-decoded [hrp=tape data=(list @) checksum=(list @)] +$ raw-decoded [hrp=tape data=(list @) checksum=(list @)]
:: below is a port of: https://github.com/bitcoinjs/bech32/blob/master/index.js :: below is a port of: https://github.com/bitcoinjs/bech32/blob/master/index.js

View File

@ -56,6 +56,8 @@
1^0x0 1^0x0
%testnet %testnet
1^0x1 1^0x1
%regtest
1^0x1
== ==
:- (cat:byt ~[1^typ pubkey.h]) :- (cat:byt ~[1^typ pubkey.h])
%- cat:byt %- cat:byt

View File

@ -4,7 +4,7 @@
:: chyg: whether account is (non-)change. 0 or 1 :: chyg: whether account is (non-)change. 0 or 1
:: bytc: "btc-byts" with dat cast to @ux :: bytc: "btc-byts" with dat cast to @ux
|% |%
+$ network ?(%main %testnet) +$ network ?(%main %testnet %regtest)
+$ hexb [wid=@ dat=@ux] :: hex byts +$ hexb [wid=@ dat=@ux] :: hex byts
+$ bits [wid=@ dat=@ub] +$ bits [wid=@ dat=@ub]
+$ xpub @ta +$ xpub @ta

View File

@ -169,12 +169,17 @@
%+ req-card act %+ req-card act
^- action:rpc-types ^- action:rpc-types
?- -.act ?- -.act
%address-info [%get-address-info address.act] %address-info [%get-address-info address.act]
%tx-info [%get-tx-vals txid.act] %tx-info [%get-tx-vals txid.act]
%raw-tx [%get-raw-tx txid.act] %raw-tx [%get-raw-tx txid.act]
%broadcast-tx [%broadcast-tx rawtx.act] %broadcast-tx [%broadcast-tx rawtx.act]
%ping [%get-block-info ~] %ping [%get-block-info ~]
%block-info [%get-block-info block.act] %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 ++ req-card
@ -309,6 +314,31 @@
?> ?=([%get-block-info *] r) ?> ?=([%get-block-info *] r)
:_ state :_ state
~[(send-update:hc [%.y %block-info network.host-info +.r] ship)] ~[(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 ++ connection-error

View File

@ -900,7 +900,7 @@
?: =(~ prov) `state ?: =(~ prov) `state
?. =(host:(need prov) src.bowl) `state ?. =(host:(need prov) src.bowl) `state
?. ?=(%.y -.upd) `state ?. ?=(%.y -.upd) `state
?- -.p.upd ?+ -.p.upd `state
%address-info %address-info
:: located in the helper in Scan Logic to keep all of that unified :: located in the helper in Scan Logic to keep all of that unified
:: ::

View File

@ -5,7 +5,7 @@
glob-http+['https://bootstrap.urbit.org/glob-0v3.7b5q1.gn30e.cpfem.abmqg.qh77v.glob' 0v3.7b5q1.gn30e.cpfem.abmqg.qh77v] 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' image+'https://urbit.ewr1.vultrobjects.com/hastuc-dibtux/2021.8.24..02.57.38-bitcoin.svg'
base+'bitcoin' base+'bitcoin'
version+[0 0 1] version+[0 0 2]
license+'MIT' license+'MIT'
website+'https://tlon.io' website+'https://tlon.io'
== ==

View File

@ -74,6 +74,7 @@
:- ?- network :- ?- network
%main 1^0x0 %main 1^0x0
%testnet 1^0x6f %testnet 1^0x6f
%regtest 1^0x6f
== ==
~[(hash-160:bcu pubkey)] ~[(hash-160:bcu pubkey)]
:: ::
@ -84,6 +85,7 @@
:~ ?- network :~ ?- network
%main 1^0x5 %main 1^0x5
%testnet 1^0xc4 %testnet 1^0xc4
%regtest 1^0xc4
== ==
%- hash-160:bcu %- hash-160:bcu
(cat:byt:bcu ~[2^0x14 (hash-160:bcu pubkey)]) (cat:byt:bcu ~[2^0x14 (hash-160:bcu pubkey)])
@ -109,7 +111,8 @@
++ is-base58 ++ is-base58
|= at=tape |= at=tape
^- ? ^- ?
?| =("m" (scag 1 at)) ?| =("n" (scag 1 at))
=("m" (scag 1 at))
=("1" (scag 1 at)) =("1" (scag 1 at))
=("3" (scag 1 at)) =("3" (scag 1 at))
=("2" (scag 1 at)) =("2" (scag 1 at))
@ -120,6 +123,7 @@
^- ? ^- ?
?| =("bc1" (scag 3 at)) ?| =("bc1" (scag 3 at))
=("tb1" (scag 3 at)) =("tb1" (scag 3 at))
=("bcrt1" (scag 5 at))
== ==
-- --
:: ::

View File

@ -423,6 +423,21 @@
:: ::
%get-block-info %get-block-info
[id.res (block-info res.res)] [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 ++ address-info
@ -433,7 +448,7 @@
[%block ni] [%block ni]
== ==
++ utxo ++ utxo
%- ot %- ot
:~ ['tx_pos' ni] :~ ['tx_pos' ni]
['tx_hash' (cu from-cord:hxb:bcu so)] ['tx_hash' (cu from-cord:hxb:bcu so)]
[%height ni] [%height ni]
@ -474,11 +489,25 @@
[%blockhash (cu from-cord:hxb:bcu so)] [%blockhash (cu from-cord:hxb:bcu so)]
[%blockfilter (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 ++ rpc-action-to-http
|= [endpoint=@t ract=action:rpc-types:bp] |= [endpoint=@t ract=action:rpc-types:bp]
=, enjs:format
|^ ^- request:http |^ ^- request:http
?- -.ract ?- -.ract
%get-address-info %get-address-info
@ -510,6 +539,39 @@
?~(block.ract '' (rsh [3 2] (scot %ui u.block.ract))) ?~(block.ract '' (rsh [3 2] (scot %ui u.block.ract)))
%- get-request %- get-request
(mk-url '/getblockinfo/' param) (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 ++ mk-url
|= [base=@t params=@t] |= [base=@t params=@t]

View File

@ -33,6 +33,11 @@
[%broadcast-tx rawtx=hexb] [%broadcast-tx rawtx=hexb]
[%ping ~] [%ping ~]
[%block-info block=(unit @ud)] [%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 +$ result
@ -41,6 +46,11 @@
[%raw-tx txid=hexb rawtx=hexb] [%raw-tx txid=hexb rawtx=hexb]
[%broadcast-tx txid=hexb broadcast=? included=?] [%broadcast-tx txid=hexb broadcast=? included=?]
[%block-info =network block=@ud fee=(unit sats) blockhash=hexb blockfilter=hexb] [%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 +$ error
$% [%not-connected status=@ud] $% [%not-connected status=@ud]
@ -64,6 +74,11 @@
[%broadcast-tx rawtx=hexb] [%broadcast-tx rawtx=hexb]
[%get-block-count ~] [%get-block-count ~]
[%get-block-info block=(unit @ud)] [%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 +$ result
@ -74,7 +89,11 @@
[%broadcast-tx txid=hexb broadcast=? included=?] [%broadcast-tx txid=hexb broadcast=? included=?]
[%get-block-count block=@ud] [%get-block-count block=@ud]
[%get-block-info block=@ud fee=(unit sats) blockhash=hexb blockfilter=hexb] [%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]
== ==
-- --
-- --