mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-12 15:01:38 +03:00
working btc-bridge
This commit is contained in:
parent
a0645a0c30
commit
48183e57be
@ -1,7 +1,7 @@
|
|||||||
:: bippy-bridge.hoon
|
:: btc-bridge.hoon
|
||||||
:: Provider for accessing BTC full node
|
:: Proxy for accessing BTC full node
|
||||||
::
|
::
|
||||||
/- *bippy-bridge
|
/- *btc-bridge
|
||||||
/+ dbug, default-agent
|
/+ dbug, default-agent
|
||||||
|%
|
|%
|
||||||
+$ versioned-state
|
+$ versioned-state
|
||||||
@ -24,15 +24,16 @@
|
|||||||
::
|
::
|
||||||
++ on-init
|
++ on-init
|
||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
~& > '%bippy-bridge initialized successfully'
|
~& > '%btc-bridge initialized successfully'
|
||||||
`this
|
:- ~[[%pass /response %agent [our.bowl %btc-node-hook] %watch /response]]
|
||||||
|
this
|
||||||
++ on-save
|
++ on-save
|
||||||
^- vase
|
^- vase
|
||||||
!>(state)
|
!>(state)
|
||||||
++ on-load
|
++ on-load
|
||||||
|= old-state=vase
|
|= old-state=vase
|
||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
~& > '%bippy-bridge recompiled successfully'
|
~& > '%btc-bridge recompiled successfully'
|
||||||
`this(state !<(versioned-state old-state))
|
`this(state !<(versioned-state old-state))
|
||||||
++ on-poke
|
++ on-poke
|
||||||
|= [=mark =vase]
|
|= [=mark =vase]
|
||||||
|
@ -61,7 +61,11 @@
|
|||||||
:: because we handle permissioning at higher-level agents.
|
:: because we handle permissioning at higher-level agents.
|
||||||
::
|
::
|
||||||
?> (team:title our.bowl src.bowl)
|
?> (team:title our.bowl src.bowl)
|
||||||
`this
|
?+ pax (on-watch:def pax)
|
||||||
|
[%response ~]
|
||||||
|
~& > "%btc-node-hook: subscription on {pax}"
|
||||||
|
`this
|
||||||
|
==
|
||||||
++ on-leave on-leave:def
|
++ on-leave on-leave:def
|
||||||
++ on-peek on-peek:def
|
++ on-peek on-peek:def
|
||||||
++ on-agent on-agent:def
|
++ on-agent on-agent:def
|
||||||
@ -181,6 +185,15 @@
|
|||||||
|= btc-resp=btc-node-hook-response
|
|= btc-resp=btc-node-hook-response
|
||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
:_ state
|
:_ state
|
||||||
|
:: If the head term is a type of call we are watching, then
|
||||||
|
:: broadcast it to subscribers on the response path
|
||||||
|
::
|
||||||
|
=/ broadcast-response=(list card)
|
||||||
|
?: (~(has in watched-calls) -.btc-resp)
|
||||||
|
~[[%give %fact ~[/response] %noun !>(3)]]
|
||||||
|
~
|
||||||
|
%+ weld
|
||||||
|
broadcast-response
|
||||||
^- (list card)
|
^- (list card)
|
||||||
?+ -.btc-resp
|
?+ -.btc-resp
|
||||||
:: By default we just print all RPC responses that are not
|
:: By default we just print all RPC responses that are not
|
||||||
|
@ -11,32 +11,29 @@ The below requires norsyr's fix to `decompress-point` in order to work.
|
|||||||
**Import lib; optionally set up env**
|
**Import lib; optionally set up env**
|
||||||
```
|
```
|
||||||
=btca -build-file %/lib/btc-address/hoon
|
=btca -build-file %/lib/btc-address/hoon
|
||||||
|
=mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
|
||||||
|
|
||||||
=bip32 -build-file %/lib/bip32/hoon
|
=bip32 -build-file %/lib/bip32/hoon
|
||||||
=ecc secp256k1:secp:crypto
|
=ecc secp256k1:secp:crypto
|
||||||
=xpub "xpub6DnWFmBQfQm1wxvKkCJjXwE6H4v8FTwUuhjDQ9ZpJnFDfhA8Dwmg71yPKyjUE93D2CB6MdnWNvGmwsb3fpd4oRJ2YcyMZoMpLU3BjpmQAny"
|
=zpub "zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"
|
||||||
=parent-zpub "zpub6rmyMSPvm5aexi2PidLFG5ERHCeNQgT3KrkXT6pEPK82zFntRUE5MqwEZCanG5NPzmDvfJ9vAr6NxzTx9FAPTAEN1JFPcL1M7CXNd5WKcP9"
|
|
||||||
=zpub "zpub6sLyD5WyhVybzoATevSndC5jmhHjfxKjDA5A21DXzoYUJyFyfUo9cW7WX7veTkKVzHjh2Npvfcm5KTT89go29p3PJtscYH4CiYzVbwV5iJW"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Test child public key from xpub**
|
**Test child public key from xpub**
|
||||||
```
|
```
|
||||||
`@ux`(child-from-xpub:btca xpub 0)
|
`@ux`(child-from-xpub:btca zpub 0)
|
||||||
(child-from-xpub:btca xpub (dec (bex 31)))
|
(child-from-xpub:btca xpub (dec (bex 31)))
|
||||||
|
|
||||||
:: should error as index is too high (hardened key range)
|
:: should error as index is too high (hardened key range)
|
||||||
(child-from-xpub:btca xpub (bex 31))
|
(child-from-xpub:btca zpub (bex 31))
|
||||||
```
|
```
|
||||||
|
|
||||||
**Same, with Jose's bip32 library**
|
**Same, with Jose's bip32 library**
|
||||||
```
|
```
|
||||||
`@ux`(compress-point:secp256k1:secp:crypto pub:(derive-public:(from-extended:bip32 xpub) 0))
|
:: get 0 index in non-change account
|
||||||
`@ux`(compress-point:secp256k1:secp:crypto pub:(derive-public:(from-extended:bip32 zpub) 0))
|
`@ux`(compress-point:ecc pub:(derive-public:(derive-public:(from-extended:bip32 zpub) 0) 0))
|
||||||
|
|
||||||
:: get same zpub point as above starting from parent-zpub
|
|
||||||
`@ux`(compress-point:ecc pub:(derive-public:(derive-public:(from-extended:bip32 parent-zpub) 0) 0))
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Deprecated: Sample Child Derivations
|
## Deprecated: `btc-address` Child Derivations
|
||||||
|
|
||||||
**Test xpub parsing**
|
**Test xpub parsing**
|
||||||
```
|
```
|
||||||
|
19
ted/ph/add.hoon
Normal file
19
ted/ph/add.hoon
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/- spider
|
||||||
|
/+ *ph-io, bip32
|
||||||
|
=, strand=strand:spider
|
||||||
|
=, secp256k1:secp:crypto
|
||||||
|
^- thread:spider
|
||||||
|
|= args=vase
|
||||||
|
=/ m (strand ,vase)
|
||||||
|
=/ zpub=tape
|
||||||
|
"zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"
|
||||||
|
=/ pubkey
|
||||||
|
derive-public:(from-extended:bip32 zpub)
|
||||||
|
;< ~ bind:m start-simple
|
||||||
|
;< ~ bind:m (raw-ship ~bud ~)
|
||||||
|
;< ~ bind:m (dojo ~bud "|start %btc-node-store")
|
||||||
|
;< ~ bind:m (dojo ~bud "|start %btc-node-hook")
|
||||||
|
;< ~ bind:m (dojo ~bud "(add 9 299)")
|
||||||
|
;< ~ bind:m (wait-for-output ~bud "308")
|
||||||
|
;< ~ bind:m end-simple
|
||||||
|
(pure:m *vase)
|
Loading…
Reference in New Issue
Block a user