From c99242136687f4ba108d6c03d78eecc59a5cd2d4 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Mon, 13 Sep 2021 11:18:22 +1000 Subject: [PATCH 1/3] bitcoin: package and split --- pkg/bitcoin/app/btc-provider.hoon | 4 +- pkg/bitcoin/app/btc-wallet.hoon | 4 +- pkg/bitcoin/desk.bill | 3 +- pkg/bitcoin/desk.docket | 2 +- pkg/bitcoin/lib/agentio.hoon | 1 + pkg/bitcoin/lib/azimuth.hoon | 1 + pkg/bitcoin/lib/azimuthio.hoon | 1 + pkg/bitcoin/lib/bip/b158.hoon | 250 +- pkg/bitcoin/lib/bip/b173.hoon | 145 +- pkg/bitcoin/lib/bip/b174.hoon | 183 +- pkg/bitcoin/lib/bip32.hoon | 244 +- pkg/bitcoin/lib/bip39.hoon | 47 +- pkg/bitcoin/lib/bip39/english.hoon | 2053 +---------------- pkg/bitcoin/lib/dbug.hoon | 1 + pkg/bitcoin/lib/default-agent.hoon | 1 + pkg/bitcoin/lib/docket.hoon | 1 + pkg/bitcoin/lib/ethio.hoon | 1 + pkg/bitcoin/lib/group.hoon | 3 + pkg/bitcoin/lib/language-server/build.hoon | 1 + pkg/bitcoin/lib/language-server/complete.hoon | 1 + .../lib/language-server/easy-print.hoon | 1 + pkg/bitcoin/lib/language-server/json.hoon | 1 + pkg/bitcoin/lib/language-server/parser.hoon | 1 + .../lib/language-server/rune-snippet.hoon | 1 + pkg/bitcoin/lib/mip.hoon | 1 + pkg/bitcoin/lib/server.hoon | 1 + pkg/bitcoin/lib/shoe.hoon | 1 + pkg/bitcoin/lib/skeleton.hoon | 1 + pkg/bitcoin/lib/sole.hoon | 1 + pkg/bitcoin/lib/strand.hoon | 1 + pkg/bitcoin/lib/strandio.hoon | 1 + pkg/bitcoin/lib/treaty.hoon | 1 + pkg/bitcoin/lib/verb.hoon | 1 + pkg/bitcoin/mar/belt.hoon | 1 + pkg/bitcoin/mar/bill.hoon | 1 + pkg/bitcoin/mar/blit.hoon | 1 + pkg/bitcoin/mar/docket.hoon | 1 + pkg/bitcoin/mar/hoon.hoon | 1 + pkg/bitcoin/mar/htm.hoon | 1 + pkg/bitcoin/mar/html.hoon | 1 + pkg/bitcoin/mar/httr.hoon | 1 + pkg/bitcoin/mar/hymn.hoon | 1 + pkg/bitcoin/mar/js.hoon | 1 + pkg/bitcoin/mar/json.hoon | 1 + pkg/bitcoin/mar/json/rpc/response.hoon | 1 + pkg/bitcoin/mar/kelvin.hoon | 1 + .../mar/language-server/rpc/notification.hoon | 1 + .../mar/language-server/rpc/request.hoon | 1 + .../mar/language-server/rpc/response.hoon | 1 + pkg/bitcoin/mar/mime.hoon | 1 + pkg/bitcoin/mar/noun.hoon | 1 + pkg/bitcoin/mar/path.hoon | 1 + pkg/bitcoin/mar/png.hoon | 1 + pkg/bitcoin/mar/purl.hoon | 1 + pkg/bitcoin/mar/sole/action.hoon | 1 + pkg/bitcoin/mar/sole/effect.hoon | 1 + pkg/bitcoin/mar/svg.hoon | 1 + pkg/bitcoin/mar/tang.hoon | 1 + pkg/bitcoin/mar/tape.hoon | 1 + pkg/bitcoin/mar/txt-diff.hoon | 1 + pkg/bitcoin/mar/txt.hoon | 1 + pkg/bitcoin/mar/udon.hoon | 1 + pkg/bitcoin/mar/umd.hoon | 1 + pkg/bitcoin/mar/urb.hoon | 1 + pkg/bitcoin/mar/urbit.hoon | 1 + pkg/bitcoin/mar/woff2.hoon | 1 + pkg/bitcoin/mar/xml.hoon | 1 + pkg/bitcoin/sur/bill.hoon | 1 + pkg/bitcoin/sur/docket.hoon | 1 + pkg/bitcoin/sur/hood.hoon | 1 + pkg/bitcoin/sur/settings.hoon | 32 +- pkg/bitcoin/sur/sole.hoon | 1 + pkg/bitcoin/sur/spider.hoon | 1 + pkg/bitcoin/sur/verb.hoon | 1 + pkg/garden-dev/lib/mip.hoon | 55 + pkg/garden/lib/mip.hoon | 56 +- 76 files changed, 135 insertions(+), 3008 deletions(-) create mode 120000 pkg/bitcoin/lib/agentio.hoon create mode 120000 pkg/bitcoin/lib/azimuth.hoon create mode 120000 pkg/bitcoin/lib/azimuthio.hoon mode change 100644 => 120000 pkg/bitcoin/lib/bip/b158.hoon mode change 100644 => 120000 pkg/bitcoin/lib/bip/b173.hoon mode change 100644 => 120000 pkg/bitcoin/lib/bip/b174.hoon mode change 100644 => 120000 pkg/bitcoin/lib/bip32.hoon mode change 100644 => 120000 pkg/bitcoin/lib/bip39.hoon mode change 100644 => 120000 pkg/bitcoin/lib/bip39/english.hoon create mode 120000 pkg/bitcoin/lib/dbug.hoon create mode 120000 pkg/bitcoin/lib/default-agent.hoon create mode 120000 pkg/bitcoin/lib/docket.hoon create mode 120000 pkg/bitcoin/lib/ethio.hoon create mode 120000 pkg/bitcoin/lib/language-server/build.hoon create mode 120000 pkg/bitcoin/lib/language-server/complete.hoon create mode 120000 pkg/bitcoin/lib/language-server/easy-print.hoon create mode 120000 pkg/bitcoin/lib/language-server/json.hoon create mode 120000 pkg/bitcoin/lib/language-server/parser.hoon create mode 120000 pkg/bitcoin/lib/language-server/rune-snippet.hoon create mode 120000 pkg/bitcoin/lib/mip.hoon create mode 120000 pkg/bitcoin/lib/server.hoon create mode 120000 pkg/bitcoin/lib/shoe.hoon create mode 120000 pkg/bitcoin/lib/skeleton.hoon create mode 120000 pkg/bitcoin/lib/sole.hoon create mode 120000 pkg/bitcoin/lib/strand.hoon create mode 120000 pkg/bitcoin/lib/strandio.hoon create mode 120000 pkg/bitcoin/lib/treaty.hoon create mode 120000 pkg/bitcoin/lib/verb.hoon create mode 120000 pkg/bitcoin/mar/belt.hoon create mode 120000 pkg/bitcoin/mar/bill.hoon create mode 120000 pkg/bitcoin/mar/blit.hoon create mode 120000 pkg/bitcoin/mar/docket.hoon create mode 120000 pkg/bitcoin/mar/hoon.hoon create mode 120000 pkg/bitcoin/mar/htm.hoon create mode 120000 pkg/bitcoin/mar/html.hoon create mode 120000 pkg/bitcoin/mar/httr.hoon create mode 120000 pkg/bitcoin/mar/hymn.hoon create mode 120000 pkg/bitcoin/mar/js.hoon create mode 120000 pkg/bitcoin/mar/json.hoon create mode 120000 pkg/bitcoin/mar/json/rpc/response.hoon create mode 120000 pkg/bitcoin/mar/kelvin.hoon create mode 120000 pkg/bitcoin/mar/language-server/rpc/notification.hoon create mode 120000 pkg/bitcoin/mar/language-server/rpc/request.hoon create mode 120000 pkg/bitcoin/mar/language-server/rpc/response.hoon create mode 120000 pkg/bitcoin/mar/mime.hoon create mode 120000 pkg/bitcoin/mar/noun.hoon create mode 120000 pkg/bitcoin/mar/path.hoon create mode 120000 pkg/bitcoin/mar/png.hoon create mode 120000 pkg/bitcoin/mar/purl.hoon create mode 120000 pkg/bitcoin/mar/sole/action.hoon create mode 120000 pkg/bitcoin/mar/sole/effect.hoon create mode 120000 pkg/bitcoin/mar/svg.hoon create mode 120000 pkg/bitcoin/mar/tang.hoon create mode 120000 pkg/bitcoin/mar/tape.hoon create mode 120000 pkg/bitcoin/mar/txt-diff.hoon create mode 120000 pkg/bitcoin/mar/txt.hoon create mode 120000 pkg/bitcoin/mar/udon.hoon create mode 120000 pkg/bitcoin/mar/umd.hoon create mode 120000 pkg/bitcoin/mar/urb.hoon create mode 120000 pkg/bitcoin/mar/urbit.hoon create mode 120000 pkg/bitcoin/mar/woff2.hoon create mode 120000 pkg/bitcoin/mar/xml.hoon create mode 120000 pkg/bitcoin/sur/bill.hoon create mode 120000 pkg/bitcoin/sur/docket.hoon create mode 120000 pkg/bitcoin/sur/hood.hoon mode change 100644 => 120000 pkg/bitcoin/sur/settings.hoon create mode 120000 pkg/bitcoin/sur/sole.hoon create mode 120000 pkg/bitcoin/sur/spider.hoon create mode 120000 pkg/bitcoin/sur/verb.hoon create mode 100644 pkg/garden-dev/lib/mip.hoon mode change 100644 => 120000 pkg/garden/lib/mip.hoon diff --git a/pkg/bitcoin/app/btc-provider.hoon b/pkg/bitcoin/app/btc-provider.hoon index 67151bc1f8..af4a694885 100644 --- a/pkg/bitcoin/app/btc-provider.hoon +++ b/pkg/bitcoin/app/btc-provider.hoon @@ -342,6 +342,7 @@ :: helper core ~% %btc-provider-helper ..card ~ |_ =bowl:gall ++* grp ~(. groupl bowl) ++ send-status |= [=status ship=(unit ship)] ^- card @@ -379,9 +380,10 @@ :: ++ in-group =/ gs ~(tap in groups.whitelist) + ?. is-running:grp %.n |- ?~ gs %.n - ?: (~(is-member groupl bowl) user i.gs) + ?: (is-member:grp user i.gs) %.y $(gs t.gs) -- diff --git a/pkg/bitcoin/app/btc-wallet.hoon b/pkg/bitcoin/app/btc-wallet.hoon index a1970f1981..86c05df721 100644 --- a/pkg/bitcoin/app/btc-wallet.hoon +++ b/pkg/bitcoin/app/btc-wallet.hoon @@ -73,8 +73,8 @@ ^- (quip card _this) ~& > '%btc-wallet initialized' :: - =/ warning=event:settings [%put-entry %btc-wallet %warning %b %.y] - =/ currency=event:settings [%put-entry %btc-wallet %currency %s 'USD'] + =/ warning=event:settings [%put-entry q.byk.bowl %btc-wallet %warning %b %.y] + =/ currency=event:settings [%put-entry q.byk.bowl %btc-wallet %currency %s 'USD'] =/ cards=(list card) :~ (poke-our:hc %settings-store %settings-event !>(warning)) (poke-our:hc %settings-store %settings-event !>(currency)) diff --git a/pkg/bitcoin/desk.bill b/pkg/bitcoin/desk.bill index 7875acb9ac..aa63ffd779 100644 --- a/pkg/bitcoin/desk.bill +++ b/pkg/bitcoin/desk.bill @@ -1,6 +1,5 @@ :~ :- %apes - :~ %btc-provider - %btc-wallet + :~ %btc-wallet == :- %fish ~ == diff --git a/pkg/bitcoin/desk.docket b/pkg/bitcoin/desk.docket index ca6340b520..32cd059b55 100644 --- a/pkg/bitcoin/desk.docket +++ b/pkg/bitcoin/desk.docket @@ -2,7 +2,7 @@ title+'Bitcoin' info+'BTC wallet for Urbit. Testing' color+0xf9.8e40 - glob+'https://bootstrap.urbit.org/glob-0v2.3kv9h.9i6cv.vfu2o.roq7e.g983m.glob' + glob-http+'https://bootstrap.urbit.org/glob-0v2.sl9s6.ud2bs.l9ft0.mstja.5f8kt.glob' image+'https://urbit.ewr1.vultrobjects.com/hastuc-dibtux/2021.8.24..02.57.38-bitcoin.svg' base+'bitcoin' version+[0 0 1] diff --git a/pkg/bitcoin/lib/agentio.hoon b/pkg/bitcoin/lib/agentio.hoon new file mode 120000 index 0000000000..959a498431 --- /dev/null +++ b/pkg/bitcoin/lib/agentio.hoon @@ -0,0 +1 @@ +../../base-dev/lib/agentio.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/azimuth.hoon b/pkg/bitcoin/lib/azimuth.hoon new file mode 120000 index 0000000000..2bacb02b79 --- /dev/null +++ b/pkg/bitcoin/lib/azimuth.hoon @@ -0,0 +1 @@ +../../base-dev/lib/azimuth.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/azimuthio.hoon b/pkg/bitcoin/lib/azimuthio.hoon new file mode 120000 index 0000000000..0b5df7063f --- /dev/null +++ b/pkg/bitcoin/lib/azimuthio.hoon @@ -0,0 +1 @@ +../../base-dev/lib/azimuthio.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/bip/b158.hoon b/pkg/bitcoin/lib/bip/b158.hoon deleted file mode 100644 index eb0eb7f0f8..0000000000 --- a/pkg/bitcoin/lib/bip/b158.hoon +++ /dev/null @@ -1,249 +0,0 @@ -/- bc=bitcoin -/+ bcu=bitcoin-utils -|% -++ params - |% - ++ p 19 - ++ m 784.931 - -- -:: -++ siphash - |= [k=byts m=byts] - ^- byts - |^ - ?> =(wid.k 16) - ?> (lte (met 3 dat.k) wid.k) - ?> (lte (met 3 dat.m) wid.m) - =. k (flim:sha k) - =. m (flim:sha m) - (flim:sha (fin (comp m (init dat.k)))) - :: Initialise internal state - :: - ++ init - |= k=@ - ^- [@ @ @ @] - =/ k0=@ (end [6 1] k) - =/ k1=@ (cut 6 [1 1] k) - :^ (mix k0 0x736f.6d65.7073.6575) - (mix k1 0x646f.7261.6e64.6f6d) - (mix k0 0x6c79.6765.6e65.7261) - (mix k1 0x7465.6462.7974.6573) - :: - :: Compression rounds - ++ comp - |= [m=byts v=[v0=@ v1=@ v2=@ v3=@]] - ^- [@ @ @ @] - =/ len=@ud (div wid.m 8) - =/ last=@ (lsh [3 7] (mod wid.m 256)) - =| i=@ud - =| w=@ - |- - =. w (cut 6 [i 1] dat.m) - ?: =(i len) - =. v3.v (mix v3.v (mix last w)) - =. v (rnd (rnd v)) - =. v0.v (mix v0.v (mix last w)) - v - %= $ - v =. v3.v (mix v3.v w) - =. v (rnd (rnd v)) - =. v0.v (mix v0.v w) - v - i (add i 1) - == - :: - :: Finalisation rounds - ++ fin - |= v=[v0=@ v1=@ v2=@ v3=@] - ^- byts - =. v2.v (mix v2.v 0xff) - =. v (rnd (rnd (rnd (rnd v)))) - :- 8 - :(mix v0.v v1.v v2.v v3.v) - :: - :: Sipround - ++ rnd - |= [v0=@ v1=@ v2=@ v3=@] - ^- [@ @ @ @] - =. v0 (~(sum fe 6) v0 v1) - =. v2 (~(sum fe 6) v2 v3) - =. v1 (~(rol fe 6) 0 13 v1) - =. v3 (~(rol fe 6) 0 16 v3) - =. v1 (mix v1 v0) - =. v3 (mix v3 v2) - =. v0 (~(rol fe 6) 0 32 v0) - =. v2 (~(sum fe 6) v2 v1) - =. v0 (~(sum fe 6) v0 v3) - =. v1 (~(rol fe 6) 0 17 v1) - =. v3 (~(rol fe 6) 0 21 v3) - =. v1 (mix v1 v2) - =. v3 (mix v3 v0) - =. v2 (~(rol fe 6) 0 32 v2) - [v0 v1 v2 v3] - -- -:: +str: bit streams -:: read is from the front -:: write appends to the back -:: -++ str - |% - ++ read-bit - |= s=bits:bc - ^- [bit=@ub rest=bits:bc] - ?> (gth wid.s 0) - :* ?:((gth wid.s (met 0 dat.s)) 0b0 0b1) - [(dec wid.s) (end [0 (dec wid.s)] dat.s)] - == - :: - ++ read-bits - |= [n=@ s=bits:bc] - ^- [bits:bc rest=bits:bc] - =| bs=bits:bc - |- - ?: =(n 0) [bs s] - =^ b s (read-bit s) - $(n (dec n), bs (write-bits bs [1 b])) - :: - ++ write-bits - |= [s1=bits:bc s2=bits:bc] - ^- bits:bc - [(add wid.s1 wid.s2) (can 0 ~[s2 s1])] - -- -:: +gol: Golomb-Rice encoding/decoding -:: -++ gol - |% - :: +en: encode x and append to end of s - :: - s: bits stream - :: - x: number to add to the stream - :: - p: golomb-rice p param - :: - ++ en - |= [s=bits:bc x=@ p=@] - ^- bits:bc - =+ q=(rsh [0 p] x) - =+ unary=[+(q) (lsh [0 1] (dec (bex q)))] - =+ r=[p (end [0 p] x)] - %+ write-bits:str s - (write-bits:str unary r) - :: - ++ de - |= [s=bits:bc p=@] - ^- [delta=@ rest=bits:bc] - |^ ?> (gth wid.s 0) - =^ q s (get-q s) - =^ r s (read-bits:str p s) - [(add dat.r (lsh [0 p] q)) s] - :: - ++ get-q - |= s=bits:bc - =| q=@ - =^ first-bit s (read-bit:str s) - |- - ?: =(0 first-bit) [q s] - =^ b s (read-bit:str s) - $(first-bit b, q +(q)) - -- - -- -:: +hsh -:: -++ hsh - |% - :: +to-range - :: - item: scriptpubkey to hash - :: - f: N*M - :: - k: key for siphash (end of blockhash, reversed) - :: - ++ to-range - |= [item=byts f=@ k=byts] - ^- @ - (rsh [0 64] (mul f (swp 3 dat:(siphash k item)))) - :: +set-construct: return sorted hashes of scriptpubkeys - :: - ++ set-construct - |= [items=(list byts) k=byts f=@] - ^- (list @) - %+ sort - %+ turn items - |= item=byts - (to-range item f k) - lth - -- -:: -++ parse-filter - |= filter=hexb:bc - ^- [n=@ux gcs-set=bits:bc] - =/ n n:(de:csiz:bcu filter) - =/ lead=@ ?:(=(1 wid.n) 1 +(wid.n)) - :- dat.n - [(mul 8 (sub wid.filter lead)) `@ub`dat:(drop:byt:bcu lead filter)] -:: +to-key: blockhash (little endian) to key for siphash -:: -++ to-key - |= blockhash=tape - ^- byts - %+ take:byt:bcu 16 - %- flip:byt:bcu - (from-cord:hxb:bcu (crip blockhash)) -:: +match: whether block filter matches *any* target scriptpubkeys -:: - filter: full block filter, with leading N -:: - k: key for siphash (end of blockhash, reversed) -:: - targets: scriptpubkeys to match -:: -++ match - |= [filter=hexb:bc k=byts targets=(list byts)] - ^- ? - =/ [p=@ m=@] [p:params m:params] - =/ [n=@ux gcs-set=bits:bc] (parse-filter filter) - =+ target-hs=(set-construct:hsh targets k (mul n m)) - =+ last-val=0 - |- - ?~ target-hs %.n - ?: =(last-val i.target-hs) - %.y - ?: (gth last-val i.target-hs) - $(target-hs t.target-hs) - :: last-val is less than target: check next val in GCS, if any - :: - ?: (lth wid.gcs-set p) %.n - =^ delta gcs-set - (de:gol gcs-set p) - $(last-val (add delta last-val)) -:: +all-match: returns all target byts that match -:: - filter: full block filter, with leading N -:: - targets: scriptpubkeys to match -:: -++ all-match - |= [filter=hexb:bc blockhash=hexb:bc targets=(list [address:bc byts])] - ^- (set [address:bc hexb:bc]) - =/ k (to-key (trip (to-cord:hxb:bcu blockhash))) - %- ~(gas in *(set [address:bc hexb:bc])) - =/ [p=@ m=@] [p:params m:params] - =/ [n=@ux gcs-set=bits:bc] (parse-filter filter) - =/ target-map=(map @ [address:bc hexb:bc]) - %- ~(gas by *(map @ [address:bc hexb:bc])) - %+ turn targets - |= [a=address:bc t=hexb:bc] - [(to-range:hsh t (mul n m) k) a t] - =+ target-hs=(sort ~(tap in ~(key by target-map)) lth) - =+ last-val=0 - =| matches=(list @) - |- - ?~ target-hs - (murn matches ~(get by target-map)) - ?: =(last-val i.target-hs) - %= $ - target-hs t.target-hs - matches [last-val matches] - == - ?: (gth last-val i.target-hs) - $(target-hs t.target-hs) - :: last-val is less than target: get next val in GCS, if any - :: - ?: (lth wid.gcs-set p) - (murn matches ~(get by target-map)) - =^ delta gcs-set - (de:gol gcs-set p) - $(last-val (add delta last-val)) -:: --- diff --git a/pkg/bitcoin/lib/bip/b158.hoon b/pkg/bitcoin/lib/bip/b158.hoon new file mode 120000 index 0000000000..cba919a854 --- /dev/null +++ b/pkg/bitcoin/lib/bip/b158.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/bip/b158.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/bip/b173.hoon b/pkg/bitcoin/lib/bip/b173.hoon deleted file mode 100644 index e2c46db1ac..0000000000 --- a/pkg/bitcoin/lib/bip/b173.hoon +++ /dev/null @@ -1,144 +0,0 @@ -:: BIP173: Bech32 Addresses -:: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki -:: -:: Heavily copies: -:: https://github.com/bitcoinjs/bech32/blob/master/index.js -:: -/- sur=bitcoin -/+ bcu=bitcoin-utils -=, sur -=, bcu -|% -++ prefixes - ^- (map network tape) - (my [[%main "bc"] [%testnet "tb"] ~]) -++ charset "qpzry9x8gf2tvdw0s3jn54khce6mua7l" -+$ raw-decoded [hrp=tape data=(list @) checksum=(list @)] -:: below is a port of: https://github.com/bitcoinjs/bech32/blob/master/index.js -:: -++ polymod - |= values=(list @) - |^ ^- @ - =/ gen=(list @ux) - ~[0x3b6a.57b2 0x2650.8e6d 0x1ea1.19fa 0x3d42.33dd 0x2a14.62b3] - =/ chk=@ 1 - |- ?~ values chk - =/ top (rsh [0 25] chk) - =. chk - (mix i.values (lsh [0 5] (dis chk 0x1ff.ffff))) - $(values t.values, chk (update-chk chk top gen)) -:: - ++ update-chk - |= [chk=@ top=@ gen=(list @ux)] - =/ is (gulf 0 4) - |- ?~ is chk - ?: =(1 (dis 1 (rsh [0 i.is] top))) - $(is t.is, chk (mix chk (snag i.is gen))) - $(is t.is) - -- -:: -++ expand-hrp - |= hrp=tape - ^- (list @) - =/ front (turn hrp |=(p=@tD (rsh [0 5] p))) - =/ back (turn hrp |=(p=@tD (dis 31 p))) - (zing ~[front ~[0] back]) -:: -++ verify-checksum - |= [hrp=tape data-and-checksum=(list @)] - ^- ? - %- |=(a=@ =(1 a)) - %- polymod - (weld (expand-hrp hrp) data-and-checksum) -:: -++ checksum - |= [hrp=tape data=(list @)] - ^- (list @) - :: xor 1 with the polymod - :: - =/ pmod=@ - %+ mix 1 - %- polymod - (zing ~[(expand-hrp hrp) data (reap 6 0)]) - %+ turn (gulf 0 5) - |=(i=@ (dis 31 (rsh [0 (mul 5 (sub 5 i))] pmod))) -:: -++ charset-to-value - |= c=@tD - ^- (unit @) - (find ~[c] charset) -++ value-to-charset - |= value=@ - ^- (unit @tD) - ?: (gth value 31) ~ - `(snag value charset) -:: -++ is-valid - |= [bech=tape last-1-pos=@] ^- ? - ?& ?|(=((cass bech) bech) =((cuss bech) bech)) :: to upper or to lower is same as bech - (gte last-1-pos 1) - (lte (add last-1-pos 7) (lent bech)) - (lte (lent bech) 90) - (levy bech |=(c=@tD (gte c 33))) - (levy bech |=(c=@tD (lte c 126))) - == -:: data should be 5bit words -:: -++ encode-raw - |= [hrp=tape data=(list @)] - ^- cord - =/ combined=(list @) - (weld data (checksum hrp data)) - %- crip - (zing ~[hrp "1" (tape (murn combined value-to-charset))]) -++ decode-raw - |= body=cord - ^- (unit raw-decoded) - =/ bech (cass (trip body)) :: to lowercase - =/ pos (flop (fand "1" bech)) - ?~ pos ~ - =/ last-1=@ i.pos - ?. (is-valid bech last-1) :: check bech32 validity (not segwit validity or checksum) - ~ - =/ hrp (scag last-1 bech) - =/ encoded-data-and-checksum=(list @) - (slag +(last-1) bech) - =/ data-and-checksum=(list @) - %+ murn encoded-data-and-checksum - charset-to-value - ?. =((lent encoded-data-and-checksum) (lent data-and-checksum)) :: ensure all were in CHARSET - ~ - ?. (verify-checksum hrp data-and-checksum) - ~ - =/ checksum-pos (sub (lent data-and-checksum) 6) - `[hrp (scag checksum-pos data-and-checksum) (slag checksum-pos data-and-checksum)] -:: +from-address: BIP173 bech32 address encoding to hex -:: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki -:: expects to drop a leading 5-bit 0 (the witness version) -:: -++ from-address - |= body=cord - ^- hexb - ~| "Invalid bech32 address" - =/ d=(unit raw-decoded) (decode-raw body) - ?> ?=(^ d) - =/ bs=bits (from-atoms:bit 5 data.u.d) - =/ byt-len=@ (div (sub wid.bs 5) 8) - ?> =(5^0b0 (take:bit 5 bs)) - ?> ?| =(20 byt-len) - =(32 byt-len) - == - [byt-len `@ux`dat:(take:bit (mul 8 byt-len) (drop:bit 5 bs))] -:: pubkey is the 33 byte ECC compressed public key -:: -++ encode-pubkey - |= [=network pubkey=byts] - ^- (unit cord) - ?. =(33 wid.pubkey) - ~|('pubkey must be a 33 byte ECC compressed public key' !!) - =/ prefix (~(get by prefixes) network) - ?~ prefix ~ - :- ~ - %+ encode-raw u.prefix - [0v0 (to-atoms:bit 5 [160 `@ub`dat:(hash-160 pubkey)])] --- diff --git a/pkg/bitcoin/lib/bip/b173.hoon b/pkg/bitcoin/lib/bip/b173.hoon new file mode 120000 index 0000000000..2999150e20 --- /dev/null +++ b/pkg/bitcoin/lib/bip/b173.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/bip/b173.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/bip/b174.hoon b/pkg/bitcoin/lib/bip/b174.hoon deleted file mode 100644 index 3bae71d929..0000000000 --- a/pkg/bitcoin/lib/bip/b174.hoon +++ /dev/null @@ -1,182 +0,0 @@ -:: BIP174: PSBTs -:: https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki -:: -/- sur=bitcoin -/+ bcu=bitcoin-utils -=, sur -=, bcu -|% -++ en - |% - ++ globals - |= rawtx=hexb - ^- map:psbt - :~ [[1 0x0] rawtx] - == - :: - ++ input - |= [only-witness=? i=in:psbt] - ^- map:psbt - %+ weld - ?: only-witness ~ - ~[[1^0x0 rawtx.i]] - :~ (witness-tx i) - (hdkey %input hdkey.i) - == - :: - ++ output - |= =out:psbt - ^- map:psbt - ?~ hk.out ~ - :~ (hdkey %output u.hk.out) - == - :: - ++ witness-tx - |= i=in:psbt - ^- keyval:psbt - :- [1 0x1] - %- cat:byt - :~ (flip:byt 8^value.utxo.i) - 1^0x16 - 2^0x14 - (hash-160 pubkey.hdkey.i) - == - :: - ++ hdkey - |= [=target:psbt h=^hdkey] - ^- keyval:psbt - =/ typ=@ux - ?- target - %input 0x6 - %output 0x2 - == - =/ coin-type=hexb - ?- network.h - %main - 1^0x0 - %testnet - 1^0x1 - == - :- (cat:byt ~[1^typ pubkey.h]) - %- cat:byt - :~ fprint.h - 1^`@ux`bipt.h 3^0x80 - coin-type 3^0x80 - 4^0x80 - 1^`@ux`chyg.h 3^0x0 - (flip:byt 4^idx.h) - == - :: - ++ keyval-byts - |= kv=keyval:psbt - ^- hexb - %- cat:byt - :~ 1^wid.key.kv - key.kv - 1^wid.val.kv - val.kv - == - :: - ++ map-byts - |= m=map:psbt - ^- (unit hexb) - ?~ m ~ - :- ~ - %- cat:byt - (turn m keyval-byts) - -- - ++ base64 - |= b=hexb - ^- base64:psbt - %- en:base64:mimes:html - (flip:byt b) -:: +encode: make base64 cord of PSBT -:: - only-witness: don't include non-witness UTXO -:: -++ encode - |= $: only-witness=? - rawtx=hexb - txid=hexb - inputs=(list in:psbt) - outputs=(list out:psbt) - == - ^- base64:psbt - =/ sep=(unit hexb) `1^0x0 - =/ final=(list (unit hexb)) - %+ join sep - %+ turn - %- zing - :~ ~[(globals:en rawtx)] - (turn inputs (cury input:en only-witness)) - (turn outputs output:en) - == - map-byts:en - %- base64:en - ^- byts - %- cat:byt - %+ weld ~[[5 0x70.7362.74ff]] - (murn (snoc final sep) same) -:: -++ parse - |= psbt-base64=cord - ^- (list map:psbt) - =/ todo=hexb - (drop:byt 5 (to-byts psbt-base64)) - =| acc=(list map:psbt) - =| m=map:psbt - |- - ?: =(wid.todo 0) - (snoc acc m) - :: 0x0: map separator - :: - ?: =(1^0x0 (take:byt 1 todo)) - $(acc (snoc acc m), m *map:psbt, todo (drop:byt 1 todo)) - =^ kv todo (next-keyval todo) - $(m (snoc m kv)) -:: +get-txid: extract txid from a valid PSBT -:: -++ get-txid - |= psbt-base64=cord - ^- hexb - =/ tx=hexb - %- raw-tx - %+ drop:byt 5 - (to-byts psbt-base64) - %- flip:byt - (dsha256 tx) -:: +raw-tx: extract hex transaction -:: looks for key 0x0 in global map -:: crashes if tx not in hex -:: -++ raw-tx - |= b=hexb - ^- hexb - |- - ?: =(wid.b 0) !! - ?: =(1^0x0 (take:byt 1 b)) !! - =/ nk (next-keyval b) - ?: =(0x0 dat.key.kv.nk) - val.kv.nk - $(b rest.nk) -:: +next-keyval: returns next key-val in a PSBT map -:: input first byte must be a map key length -:: -++ next-keyval - |= b=hexb - ^- [kv=keyval:psbt rest=hexb] - =/ klen dat:(take:byt 1 b) - =/ k (take:byt klen (drop:byt 1 b)) - =/ vlen dat:(take:byt 1 (drop:byt (add 1 klen) b)) - =/ v (take:byt vlen (drop:byt (add 2 klen) b)) - ?> ?&((gth wid.k 0) (gth wid.v 0)) - :- [k v] - (drop:byt ;:(add 2 klen vlen) b) -:: -++ to-byts - |= psbt-base64=cord - ^- hexb - ~| "Invalid PSBT" - =+ p=(de:base64:mimes:html psbt-base64) - ?~ p !! - (flip:byt u.p) --- diff --git a/pkg/bitcoin/lib/bip/b174.hoon b/pkg/bitcoin/lib/bip/b174.hoon new file mode 120000 index 0000000000..bc6cae53bb --- /dev/null +++ b/pkg/bitcoin/lib/bip/b174.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/bip/b174.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/bip32.hoon b/pkg/bitcoin/lib/bip32.hoon deleted file mode 100644 index 02187ad877..0000000000 --- a/pkg/bitcoin/lib/bip32.hoon +++ /dev/null @@ -1,243 +0,0 @@ -:: bip32 implementation in hoon -:: -:: to use, call one of the core initialization arms. -:: using the produced core, derive as needed and take out the data you want. -:: -::NOTE tested to be correct against -:: https://en.bitcoin.it/wiki/BIP_0032_TestVectors -:: -=, hmac:crypto -=, secp:crypto -=+ ecc=secp256k1 -:: -:: prv: private key -:: pub: public key -:: cad: chain code -:: dep: depth in chain -:: ind: index at depth -:: pif: parent fingerprint (4 bytes) -|_ [prv=@ pub=point.ecc cad=@ dep=@ud ind=@ud pif=@] -:: -+$ keyc [key=@ cai=@] :: prv/pub key + chain code -:: -:: elliptic curve operations and values -:: -++ point priv-to-pub.ecc -:: -++ ser-p compress-point.ecc -:: -++ n n:t.ecc -:: -:: core initialization -:: -++ from-seed - |= byts - ^+ +> - =+ der=(hmac-sha512l [12 'dees nioctiB'] [wid dat]) - =+ pri=(cut 3 [32 32] der) - +>.$(prv pri, pub (point pri), cad (cut 3 [0 32] der)) -:: -++ from-private - |= keyc - +>(prv key, pub (point key), cad cai) -:: -++ from-public - |= keyc - +>(pub (decompress-point.ecc key), cad cai) -:: -++ from-public-point - |= [pon=point.ecc cai=@] - +>(pub pon, cad cai) -:: -++ from-extended - |= t=tape - =+ x=(de-base58check 4 t) - => |% - ++ take - |= b=@ud - ^- [v=@ x=@] - :- (end [3 b] x) - (rsh [3 b] x) - -- - =^ k x (take 33) - =^ c x (take 32) - =^ i x (take 4) - =^ p x (take 4) - =^ d x (take 1) - ?> =(0 x) :: sanity check - %. [d i p] - =< set-metadata - =+ v=(swag [1 3] t) - ?: =("prv" v) (from-private k c) - ?: =("pub" v) (from-public k c) - !! -:: -++ set-metadata - |= [d=@ud i=@ud p=@] - +>(dep d, ind i, pif p) -:: -:: derivation -:: -++ derivation-path - ;~ pfix - ;~(pose (jest 'm/') (easy ~)) - %+ most fas - ;~ pose - %+ cook - |=(i=@ (add i (bex 31))) - ;~(sfix dem soq) - :: - dem - == == -:: -++ derive-path - |= t=tape - %- derive-sequence - (scan t derivation-path) -:: -++ derive-sequence - |= j=(list @u) - ?~ j +> - =. +> (derive i.j) - $(j t.j) -:: -++ derive - ?: =(0 prv) - derive-public - derive-private -:: -++ derive-private - |= i=@u - ^+ +> - :: we must have a private key to derive the next one - ?: =(0 prv) - ~| %know-no-private-key - !! - :: derive child at i - =/ [left=@ right=@] - =- [(cut 3 [32 32] -) (cut 3 [0 32] -)] - %+ hmac-sha512l [32 cad] - :- 37 - ?: (gte i (bex 31)) - :: hardened child - (can 3 ~[4^i 32^prv 1^0]) - :: normal child - (can 3 ~[4^i 33^(ser-p (point prv))]) - =+ key=(mod (add left prv) n) - :: rare exception, invalid key, go to the next one - ?: |(=(0 key) (gte left n)) $(i +(i)) - %_ +>.$ - prv key - pub (point key) - cad right - dep +(dep) - ind i - pif fingerprint - == -:: -++ derive-public - |= i=@u - ^+ +> - :: public keys can't be hardened - ?: (gte i (bex 31)) - ~| %cant-derive-hardened-public-key - !! - :: derive child at i - =/ [left=@ right=@] - =- [(cut 3 [32 32] -) (cut 3 [0 32] -)] - %+ hmac-sha512l [32 cad] - 37^(can 3 ~[4^i 33^(ser-p pub)]) - :: rare exception, invalid key, go to the next one - ?: (gte left n) $(i +(i)) ::TODO or child key is "point at infinity" - %_ +>.$ - pub (add-points.ecc (point left) pub) - cad right - dep +(dep) - ind i - pif fingerprint - == -:: -:: rendering -:: -++ private-key ?.(=(0 prv) prv ~|(%know-no-private-key !!)) -++ public-key (ser-p pub) -++ chain-code cad -++ private-chain [private-key cad] -++ public-chain [public-key cad] -:: -++ identity (hash160 public-key) -++ fingerprint (cut 3 [16 4] identity) -:: -++ address - |= network=?(%main %regtest %testnet) - ^- @uc - :: removes checksum - :: - %+ rsh [3 4] - %+ en-base58check - [4 (version-bytes network %pub %.n)] - [20 identity] -:: -++ prv-extended - |= network=?(%main %regtest %testnet) - %+ en-b58c-bip32 (version-bytes network %prv %.y) - (build-extended private-key) -:: -++ pub-extended - |= network=?(%main %regtest %testnet) - %+ en-b58c-bip32 (version-bytes network %pub %.y) - (build-extended public-key) -:: -++ build-extended - |= key=@ - %+ can 3 - :~ 33^key - 32^cad - 4^ind - 4^pif - 1^dep - == -:: -++ en-b58c-bip32 - |= [v=@ k=@] - %- en-base58:mimes:html - (en-base58check [4 v] [74 k]) -:: -:: base58check -:: -++ en-base58check - :: v: version bytes - :: d: data - |= [v=byts d=byts] - =+ p=[(add wid.v wid.d) (can 3 ~[d v])] - =- (can 3 ~[4^- p]) - %+ rsh [3 28] - (sha-256l:sha 32 (sha-256l:sha p)) -:: -++ de-base58check - :: vw: amount of version bytes - |= [vw=@u t=tape] - =+ x=(de-base58:mimes:html t) - =+ hash=(sha-256l:sha 32 (sha-256:sha (rsh [3 4] x))) - ?> =((end [3 4] x) (rsh [3 28] hash)) - (cut 3 [vw (sub (met 3 x) (add 4 vw))] x) -:: -++ hash160 - |= d=@ - (ripemd-160:ripemd:crypto 32 (sha-256:sha d)) -:: -++ version-bytes - |= [network=?(%main %regtest %testnet) type=?(%pub %prv) bip32=?] - ^- @ux - |^ - ?- type - %pub ?:(bip32 xpub-key pay-to-pubkey) - %prv ?:(bip32 xprv-key private-key) - == - :: - ++ pay-to-pubkey ?:(=(network %main) 0x0 0x6f) - ++ private-key ?:(=(network %main) 0x80 0xef) - ++ xpub-key ?:(=(network %main) 0x488.b21e 0x435.87cf) - ++ xprv-key ?:(=(network %main) 0x488.ade4 0x435.8394) - -- --- diff --git a/pkg/bitcoin/lib/bip32.hoon b/pkg/bitcoin/lib/bip32.hoon new file mode 120000 index 0000000000..1cbb7f8924 --- /dev/null +++ b/pkg/bitcoin/lib/bip32.hoon @@ -0,0 +1 @@ +../../base-dev/lib/bip32.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/bip39.hoon b/pkg/bitcoin/lib/bip39.hoon deleted file mode 100644 index cc33fe479f..0000000000 --- a/pkg/bitcoin/lib/bip39.hoon +++ /dev/null @@ -1,46 +0,0 @@ -:: bip39 implementation in hoon -:: -/+ bip39-english -:: -|% -++ from-entropy - |= byts - ^- tape - =. wid (mul wid 8) - ~| [%unsupported-entropy-bit-length wid] - ?> &((gte wid 128) (lte wid 256)) - :: - =+ cs=(div wid 32) - =/ check=@ - %+ rsh [0 (sub 256 cs)] - (sha-256l:sha (div wid 8) dat) - =/ bits=byts - :- (add wid cs) - %+ can 0 - :~ cs^check - wid^dat - == - :: - =/ pieces - |- ^- (list @) - :- (end [0 11] dat.bits) - ?: (lte wid.bits 11) ~ - $(bits [(sub wid.bits 11) (rsh [0 11] dat.bits)]) - :: - =/ words=(list tape) - %+ turn pieces - |= ind=@ud - (snag ind `(list tape)`bip39-english) - :: - %+ roll (flop words) - |= [nex=tape all=tape] - ?~ all nex - :(weld all " " nex) -:: -::NOTE always produces a 512-bit result -++ to-seed - |= [mnem=tape pass=tape] - ^- @ - %- hmac-sha512t:pbkdf:crypto - [(crip mnem) (crip (weld "mnemonic" pass)) 2.048 64] --- diff --git a/pkg/bitcoin/lib/bip39.hoon b/pkg/bitcoin/lib/bip39.hoon new file mode 120000 index 0000000000..36c4b7e834 --- /dev/null +++ b/pkg/bitcoin/lib/bip39.hoon @@ -0,0 +1 @@ +../../base-dev/lib/bip39.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/bip39/english.hoon b/pkg/bitcoin/lib/bip39/english.hoon deleted file mode 100644 index 60de893177..0000000000 --- a/pkg/bitcoin/lib/bip39/english.hoon +++ /dev/null @@ -1,2052 +0,0 @@ -:: english wordlist for use in bip39 -^- (list tape) -:~ - "abandon" - "ability" - "able" - "about" - "above" - "absent" - "absorb" - "abstract" - "absurd" - "abuse" - "access" - "accident" - "account" - "accuse" - "achieve" - "acid" - "acoustic" - "acquire" - "across" - "act" - "action" - "actor" - "actress" - "actual" - "adapt" - "add" - "addict" - "address" - "adjust" - "admit" - "adult" - "advance" - "advice" - "aerobic" - "affair" - "afford" - "afraid" - "again" - "age" - "agent" - "agree" - "ahead" - "aim" - "air" - "airport" - "aisle" - "alarm" - "album" - "alcohol" - "alert" - "alien" - "all" - "alley" - "allow" - "almost" - "alone" - "alpha" - "already" - "also" - "alter" - "always" - "amateur" - "amazing" - "among" - "amount" - "amused" - "analyst" - "anchor" - "ancient" - "anger" - "angle" - "angry" - "animal" - "ankle" - "announce" - "annual" - "another" - "answer" - "antenna" - "antique" - "anxiety" - "any" - "apart" - "apology" - "appear" - "apple" - "approve" - "april" - "arch" - "arctic" - "area" - "arena" - "argue" - "arm" - "armed" - "armor" - "army" - "around" - "arrange" - "arrest" - "arrive" - "arrow" - "art" - "artefact" - "artist" - "artwork" - "ask" - "aspect" - "assault" - "asset" - "assist" - "assume" - "asthma" - "athlete" - "atom" - "attack" - "attend" - "attitude" - "attract" - "auction" - "audit" - "august" - "aunt" - "author" - "auto" - "autumn" - "average" - "avocado" - "avoid" - "awake" - "aware" - "away" - "awesome" - "awful" - "awkward" - "axis" - "baby" - "bachelor" - "bacon" - "badge" - "bag" - "balance" - "balcony" - "ball" - "bamboo" - "banana" - "banner" - "bar" - "barely" - "bargain" - "barrel" - "base" - "basic" - "basket" - "battle" - "beach" - "bean" - "beauty" - "because" - "become" - "beef" - "before" - "begin" - "behave" - "behind" - "believe" - "below" - "belt" - "bench" - "benefit" - "best" - "betray" - "better" - "between" - "beyond" - "bicycle" - "bid" - "bike" - "bind" - "biology" - "bird" - "birth" - "bitter" - "black" - "blade" - "blame" - "blanket" - "blast" - "bleak" - "bless" - "blind" - "blood" - "blossom" - "blouse" - "blue" - "blur" - "blush" - "board" - "boat" - "body" - "boil" - "bomb" - "bone" - "bonus" - "book" - "boost" - "border" - "boring" - "borrow" - "boss" - "bottom" - "bounce" - "box" - "boy" - "bracket" - "brain" - "brand" - "brass" - "brave" - "bread" - "breeze" - "brick" - "bridge" - "brief" - "bright" - "bring" - "brisk" - "broccoli" - "broken" - "bronze" - "broom" - "brother" - "brown" - "brush" - "bubble" - "buddy" - "budget" - "buffalo" - "build" - "bulb" - "bulk" - "bullet" - "bundle" - "bunker" - "burden" - "burger" - "burst" - "bus" - "business" - "busy" - "butter" - "buyer" - "buzz" - "cabbage" - "cabin" - "cable" - "cactus" - "cage" - "cake" - "call" - "calm" - "camera" - "camp" - "can" - "canal" - "cancel" - "candy" - "cannon" - "canoe" - "canvas" - "canyon" - "capable" - "capital" - "captain" - "car" - "carbon" - "card" - "cargo" - "carpet" - "carry" - "cart" - "case" - "cash" - "casino" - "castle" - "casual" - "cat" - "catalog" - "catch" - "category" - "cattle" - "caught" - "cause" - "caution" - "cave" - "ceiling" - "celery" - "cement" - "census" - "century" - "cereal" - "certain" - "chair" - "chalk" - "champion" - "change" - "chaos" - "chapter" - "charge" - "chase" - "chat" - "cheap" - "check" - "cheese" - "chef" - "cherry" - "chest" - "chicken" - "chief" - "child" - "chimney" - "choice" - "choose" - "chronic" - "chuckle" - "chunk" - "churn" - "cigar" - "cinnamon" - "circle" - "citizen" - "city" - "civil" - "claim" - "clap" - "clarify" - "claw" - "clay" - "clean" - "clerk" - "clever" - "click" - "client" - "cliff" - "climb" - "clinic" - "clip" - "clock" - "clog" - "close" - "cloth" - "cloud" - "clown" - "club" - "clump" - "cluster" - "clutch" - "coach" - "coast" - "coconut" - "code" - "coffee" - "coil" - "coin" - "collect" - "color" - "column" - "combine" - "come" - "comfort" - "comic" - "common" - "company" - "concert" - "conduct" - "confirm" - "congress" - "connect" - "consider" - "control" - "convince" - "cook" - "cool" - "copper" - "copy" - "coral" - "core" - "corn" - "correct" - "cost" - "cotton" - "couch" - "country" - "couple" - "course" - "cousin" - "cover" - "coyote" - "crack" - "cradle" - "craft" - "cram" - "crane" - "crash" - "crater" - "crawl" - "crazy" - "cream" - "credit" - "creek" - "crew" - "cricket" - "crime" - "crisp" - "critic" - "crop" - "cross" - "crouch" - "crowd" - "crucial" - "cruel" - "cruise" - "crumble" - "crunch" - "crush" - "cry" - "crystal" - "cube" - "culture" - "cup" - "cupboard" - "curious" - "current" - "curtain" - "curve" - "cushion" - "custom" - "cute" - "cycle" - "dad" - "damage" - "damp" - "dance" - "danger" - "daring" - "dash" - "daughter" - "dawn" - "day" - "deal" - "debate" - "debris" - "decade" - "december" - "decide" - "decline" - "decorate" - "decrease" - "deer" - "defense" - "define" - "defy" - "degree" - "delay" - "deliver" - "demand" - "demise" - "denial" - "dentist" - "deny" - "depart" - "depend" - "deposit" - "depth" - "deputy" - "derive" - "describe" - "desert" - "design" - "desk" - "despair" - "destroy" - "detail" - "detect" - "develop" - "device" - "devote" - "diagram" - "dial" - "diamond" - "diary" - "dice" - "diesel" - "diet" - "differ" - "digital" - "dignity" - "dilemma" - "dinner" - "dinosaur" - "direct" - "dirt" - "disagree" - "discover" - "disease" - "dish" - "dismiss" - "disorder" - "display" - "distance" - "divert" - "divide" - "divorce" - "dizzy" - "doctor" - "document" - "dog" - "doll" - "dolphin" - "domain" - "donate" - "donkey" - "donor" - "door" - "dose" - "double" - "dove" - "draft" - "dragon" - "drama" - "drastic" - "draw" - "dream" - "dress" - "drift" - "drill" - "drink" - "drip" - "drive" - "drop" - "drum" - "dry" - "duck" - "dumb" - "dune" - "during" - "dust" - "dutch" - "duty" - "dwarf" - "dynamic" - "eager" - "eagle" - "early" - "earn" - "earth" - "easily" - "east" - "easy" - "echo" - "ecology" - "economy" - "edge" - "edit" - "educate" - "effort" - "egg" - "eight" - "either" - "elbow" - "elder" - "electric" - "elegant" - "element" - "elephant" - "elevator" - "elite" - "else" - "embark" - "embody" - "embrace" - "emerge" - "emotion" - "employ" - "empower" - "empty" - "enable" - "enact" - "end" - "endless" - "endorse" - "enemy" - "energy" - "enforce" - "engage" - "engine" - "enhance" - "enjoy" - "enlist" - "enough" - "enrich" - "enroll" - "ensure" - "enter" - "entire" - "entry" - "envelope" - "episode" - "equal" - "equip" - "era" - "erase" - "erode" - "erosion" - "error" - "erupt" - "escape" - "essay" - "essence" - "estate" - "eternal" - "ethics" - "evidence" - "evil" - "evoke" - "evolve" - "exact" - "example" - "excess" - "exchange" - "excite" - "exclude" - "excuse" - "execute" - "exercise" - "exhaust" - "exhibit" - "exile" - "exist" - "exit" - "exotic" - "expand" - "expect" - "expire" - "explain" - "expose" - "express" - "extend" - "extra" - "eye" - "eyebrow" - "fabric" - "face" - "faculty" - "fade" - "faint" - "faith" - "fall" - "false" - "fame" - "family" - "famous" - "fan" - "fancy" - "fantasy" - "farm" - "fashion" - "fat" - "fatal" - "father" - "fatigue" - "fault" - "favorite" - "feature" - "february" - "federal" - "fee" - "feed" - "feel" - "female" - "fence" - "festival" - "fetch" - "fever" - "few" - "fiber" - "fiction" - "field" - "figure" - "file" - "film" - "filter" - "final" - "find" - "fine" - "finger" - "finish" - "fire" - "firm" - "first" - "fiscal" - "fish" - "fit" - "fitness" - "fix" - "flag" - "flame" - "flash" - "flat" - "flavor" - "flee" - "flight" - "flip" - "float" - "flock" - "floor" - "flower" - "fluid" - "flush" - "fly" - "foam" - "focus" - "fog" - "foil" - "fold" - "follow" - "food" - "foot" - "force" - "forest" - "forget" - "fork" - "fortune" - "forum" - "forward" - "fossil" - "foster" - "found" - "fox" - "fragile" - "frame" - "frequent" - "fresh" - "friend" - "fringe" - "frog" - "front" - "frost" - "frown" - "frozen" - "fruit" - "fuel" - "fun" - "funny" - "furnace" - "fury" - "future" - "gadget" - "gain" - "galaxy" - "gallery" - "game" - "gap" - "garage" - "garbage" - "garden" - "garlic" - "garment" - "gas" - "gasp" - "gate" - "gather" - "gauge" - "gaze" - "general" - "genius" - "genre" - "gentle" - "genuine" - "gesture" - "ghost" - "giant" - "gift" - "giggle" - "ginger" - "giraffe" - "girl" - "give" - "glad" - "glance" - "glare" - "glass" - "glide" - "glimpse" - "globe" - "gloom" - "glory" - "glove" - "glow" - "glue" - "goat" - "goddess" - "gold" - "good" - "goose" - "gorilla" - "gospel" - "gossip" - "govern" - "gown" - "grab" - "grace" - "grain" - "grant" - "grape" - "grass" - "gravity" - "great" - "green" - "grid" - "grief" - "grit" - "grocery" - "group" - "grow" - "grunt" - "guard" - "guess" - "guide" - "guilt" - "guitar" - "gun" - "gym" - "habit" - "hair" - "half" - "hammer" - "hamster" - "hand" - "happy" - "harbor" - "hard" - "harsh" - "harvest" - "hat" - "have" - "hawk" - "hazard" - "head" - "health" - "heart" - "heavy" - "hedgehog" - "height" - "hello" - "helmet" - "help" - "hen" - "hero" - "hidden" - "high" - "hill" - "hint" - "hip" - "hire" - "history" - "hobby" - "hockey" - "hold" - "hole" - "holiday" - "hollow" - "home" - "honey" - "hood" - "hope" - "horn" - "horror" - "horse" - "hospital" - "host" - "hotel" - "hour" - "hover" - "hub" - "huge" - "human" - "humble" - "humor" - "hundred" - "hungry" - "hunt" - "hurdle" - "hurry" - "hurt" - "husband" - "hybrid" - "ice" - "icon" - "idea" - "identify" - "idle" - "ignore" - "ill" - "illegal" - "illness" - "image" - "imitate" - "immense" - "immune" - "impact" - "impose" - "improve" - "impulse" - "inch" - "include" - "income" - "increase" - "index" - "indicate" - "indoor" - "industry" - "infant" - "inflict" - "inform" - "inhale" - "inherit" - "initial" - "inject" - "injury" - "inmate" - "inner" - "innocent" - "input" - "inquiry" - "insane" - "insect" - "inside" - "inspire" - "install" - "intact" - "interest" - "into" - "invest" - "invite" - "involve" - "iron" - "island" - "isolate" - "issue" - "item" - "ivory" - "jacket" - "jaguar" - "jar" - "jazz" - "jealous" - "jeans" - "jelly" - "jewel" - "job" - "join" - "joke" - "journey" - "joy" - "judge" - "juice" - "jump" - "jungle" - "junior" - "junk" - "just" - "kangaroo" - "keen" - "keep" - "ketchup" - "key" - "kick" - "kid" - "kidney" - "kind" - "kingdom" - "kiss" - "kit" - "kitchen" - "kite" - "kitten" - "kiwi" - "knee" - "knife" - "knock" - "know" - "lab" - "label" - "labor" - "ladder" - "lady" - "lake" - "lamp" - "language" - "laptop" - "large" - "later" - "latin" - "laugh" - "laundry" - "lava" - "law" - "lawn" - "lawsuit" - "layer" - "lazy" - "leader" - "leaf" - "learn" - "leave" - "lecture" - "left" - "leg" - "legal" - "legend" - "leisure" - "lemon" - "lend" - "length" - "lens" - "leopard" - "lesson" - "letter" - "level" - "liar" - "liberty" - "library" - "license" - "life" - "lift" - "light" - "like" - "limb" - "limit" - "link" - "lion" - "liquid" - "list" - "little" - "live" - "lizard" - "load" - "loan" - "lobster" - "local" - "lock" - "logic" - "lonely" - "long" - "loop" - "lottery" - "loud" - "lounge" - "love" - "loyal" - "lucky" - "luggage" - "lumber" - "lunar" - "lunch" - "luxury" - "lyrics" - "machine" - "mad" - "magic" - "magnet" - "maid" - "mail" - "main" - "major" - "make" - "mammal" - "man" - "manage" - "mandate" - "mango" - "mansion" - "manual" - "maple" - "marble" - "march" - "margin" - "marine" - "market" - "marriage" - "mask" - "mass" - "master" - "match" - "material" - "math" - "matrix" - "matter" - "maximum" - "maze" - "meadow" - "mean" - "measure" - "meat" - "mechanic" - "medal" - "media" - "melody" - "melt" - "member" - "memory" - "mention" - "menu" - "mercy" - "merge" - "merit" - "merry" - "mesh" - "message" - "metal" - "method" - "middle" - "midnight" - "milk" - "million" - "mimic" - "mind" - "minimum" - "minor" - "minute" - "miracle" - "mirror" - "misery" - "miss" - "mistake" - "mix" - "mixed" - "mixture" - "mobile" - "model" - "modify" - "mom" - "moment" - "monitor" - "monkey" - "monster" - "month" - "moon" - "moral" - "more" - "morning" - "mosquito" - "mother" - "motion" - "motor" - "mountain" - "mouse" - "move" - "movie" - "much" - "muffin" - "mule" - "multiply" - "muscle" - "museum" - "mushroom" - "music" - "must" - "mutual" - "myself" - "mystery" - "myth" - "naive" - "name" - "napkin" - "narrow" - "nasty" - "nation" - "nature" - "near" - "neck" - "need" - "negative" - "neglect" - "neither" - "nephew" - "nerve" - "nest" - "net" - "network" - "neutral" - "never" - "news" - "next" - "nice" - "night" - "noble" - "noise" - "nominee" - "noodle" - "normal" - "north" - "nose" - "notable" - "note" - "nothing" - "notice" - "novel" - "now" - "nuclear" - "number" - "nurse" - "nut" - "oak" - "obey" - "object" - "oblige" - "obscure" - "observe" - "obtain" - "obvious" - "occur" - "ocean" - "october" - "odor" - "off" - "offer" - "office" - "often" - "oil" - "okay" - "old" - "olive" - "olympic" - "omit" - "once" - "one" - "onion" - "online" - "only" - "open" - "opera" - "opinion" - "oppose" - "option" - "orange" - "orbit" - "orchard" - "order" - "ordinary" - "organ" - "orient" - "original" - "orphan" - "ostrich" - "other" - "outdoor" - "outer" - "output" - "outside" - "oval" - "oven" - "over" - "own" - "owner" - "oxygen" - "oyster" - "ozone" - "pact" - "paddle" - "page" - "pair" - "palace" - "palm" - "panda" - "panel" - "panic" - "panther" - "paper" - "parade" - "parent" - "park" - "parrot" - "party" - "pass" - "patch" - "path" - "patient" - "patrol" - "pattern" - "pause" - "pave" - "payment" - "peace" - "peanut" - "pear" - "peasant" - "pelican" - "pen" - "penalty" - "pencil" - "people" - "pepper" - "perfect" - "permit" - "person" - "pet" - "phone" - "photo" - "phrase" - "physical" - "piano" - "picnic" - "picture" - "piece" - "pig" - "pigeon" - "pill" - "pilot" - "pink" - "pioneer" - "pipe" - "pistol" - "pitch" - "pizza" - "place" - "planet" - "plastic" - "plate" - "play" - "please" - "pledge" - "pluck" - "plug" - "plunge" - "poem" - "poet" - "point" - "polar" - "pole" - "police" - "pond" - "pony" - "pool" - "popular" - "portion" - "position" - "possible" - "post" - "potato" - "pottery" - "poverty" - "powder" - "power" - "practice" - "praise" - "predict" - "prefer" - "prepare" - "present" - "pretty" - "prevent" - "price" - "pride" - "primary" - "print" - "priority" - "prison" - "private" - "prize" - "problem" - "process" - "produce" - "profit" - "program" - "project" - "promote" - "proof" - "property" - "prosper" - "protect" - "proud" - "provide" - "public" - "pudding" - "pull" - "pulp" - "pulse" - "pumpkin" - "punch" - "pupil" - "puppy" - "purchase" - "purity" - "purpose" - "purse" - "push" - "put" - "puzzle" - "pyramid" - "quality" - "quantum" - "quarter" - "question" - "quick" - "quit" - "quiz" - "quote" - "rabbit" - "raccoon" - "race" - "rack" - "radar" - "radio" - "rail" - "rain" - "raise" - "rally" - "ramp" - "ranch" - "random" - "range" - "rapid" - "rare" - "rate" - "rather" - "raven" - "raw" - "razor" - "ready" - "real" - "reason" - "rebel" - "rebuild" - "recall" - "receive" - "recipe" - "record" - "recycle" - "reduce" - "reflect" - "reform" - "refuse" - "region" - "regret" - "regular" - "reject" - "relax" - "release" - "relief" - "rely" - "remain" - "remember" - "remind" - "remove" - "render" - "renew" - "rent" - "reopen" - "repair" - "repeat" - "replace" - "report" - "require" - "rescue" - "resemble" - "resist" - "resource" - "response" - "result" - "retire" - "retreat" - "return" - "reunion" - "reveal" - "review" - "reward" - "rhythm" - "rib" - "ribbon" - "rice" - "rich" - "ride" - "ridge" - "rifle" - "right" - "rigid" - "ring" - "riot" - "ripple" - "risk" - "ritual" - "rival" - "river" - "road" - "roast" - "robot" - "robust" - "rocket" - "romance" - "roof" - "rookie" - "room" - "rose" - "rotate" - "rough" - "round" - "route" - "royal" - "rubber" - "rude" - "rug" - "rule" - "run" - "runway" - "rural" - "sad" - "saddle" - "sadness" - "safe" - "sail" - "salad" - "salmon" - "salon" - "salt" - "salute" - "same" - "sample" - "sand" - "satisfy" - "satoshi" - "sauce" - "sausage" - "save" - "say" - "scale" - "scan" - "scare" - "scatter" - "scene" - "scheme" - "school" - "science" - "scissors" - "scorpion" - "scout" - "scrap" - "screen" - "script" - "scrub" - "sea" - "search" - "season" - "seat" - "second" - "secret" - "section" - "security" - "seed" - "seek" - "segment" - "select" - "sell" - "seminar" - "senior" - "sense" - "sentence" - "series" - "service" - "session" - "settle" - "setup" - "seven" - "shadow" - "shaft" - "shallow" - "share" - "shed" - "shell" - "sheriff" - "shield" - "shift" - "shine" - "ship" - "shiver" - "shock" - "shoe" - "shoot" - "shop" - "short" - "shoulder" - "shove" - "shrimp" - "shrug" - "shuffle" - "shy" - "sibling" - "sick" - "side" - "siege" - "sight" - "sign" - "silent" - "silk" - "silly" - "silver" - "similar" - "simple" - "since" - "sing" - "siren" - "sister" - "situate" - "six" - "size" - "skate" - "sketch" - "ski" - "skill" - "skin" - "skirt" - "skull" - "slab" - "slam" - "sleep" - "slender" - "slice" - "slide" - "slight" - "slim" - "slogan" - "slot" - "slow" - "slush" - "small" - "smart" - "smile" - "smoke" - "smooth" - "snack" - "snake" - "snap" - "sniff" - "snow" - "soap" - "soccer" - "social" - "sock" - "soda" - "soft" - "solar" - "soldier" - "solid" - "solution" - "solve" - "someone" - "song" - "soon" - "sorry" - "sort" - "soul" - "sound" - "soup" - "source" - "south" - "space" - "spare" - "spatial" - "spawn" - "speak" - "special" - "speed" - "spell" - "spend" - "sphere" - "spice" - "spider" - "spike" - "spin" - "spirit" - "split" - "spoil" - "sponsor" - "spoon" - "sport" - "spot" - "spray" - "spread" - "spring" - "spy" - "square" - "squeeze" - "squirrel" - "stable" - "stadium" - "staff" - "stage" - "stairs" - "stamp" - "stand" - "start" - "state" - "stay" - "steak" - "steel" - "stem" - "step" - "stereo" - "stick" - "still" - "sting" - "stock" - "stomach" - "stone" - "stool" - "story" - "stove" - "strategy" - "street" - "strike" - "strong" - "struggle" - "student" - "stuff" - "stumble" - "style" - "subject" - "submit" - "subway" - "success" - "such" - "sudden" - "suffer" - "sugar" - "suggest" - "suit" - "summer" - "sun" - "sunny" - "sunset" - "super" - "supply" - "supreme" - "sure" - "surface" - "surge" - "surprise" - "surround" - "survey" - "suspect" - "sustain" - "swallow" - "swamp" - "swap" - "swarm" - "swear" - "sweet" - "swift" - "swim" - "swing" - "switch" - "sword" - "symbol" - "symptom" - "syrup" - "system" - "table" - "tackle" - "tag" - "tail" - "talent" - "talk" - "tank" - "tape" - "target" - "task" - "taste" - "tattoo" - "taxi" - "teach" - "team" - "tell" - "ten" - "tenant" - "tennis" - "tent" - "term" - "test" - "text" - "thank" - "that" - "theme" - "then" - "theory" - "there" - "they" - "thing" - "this" - "thought" - "three" - "thrive" - "throw" - "thumb" - "thunder" - "ticket" - "tide" - "tiger" - "tilt" - "timber" - "time" - "tiny" - "tip" - "tired" - "tissue" - "title" - "toast" - "tobacco" - "today" - "toddler" - "toe" - "together" - "toilet" - "token" - "tomato" - "tomorrow" - "tone" - "tongue" - "tonight" - "tool" - "tooth" - "top" - "topic" - "topple" - "torch" - "tornado" - "tortoise" - "toss" - "total" - "tourist" - "toward" - "tower" - "town" - "toy" - "track" - "trade" - "traffic" - "tragic" - "train" - "transfer" - "trap" - "trash" - "travel" - "tray" - "treat" - "tree" - "trend" - "trial" - "tribe" - "trick" - "trigger" - "trim" - "trip" - "trophy" - "trouble" - "truck" - "true" - "truly" - "trumpet" - "trust" - "truth" - "try" - "tube" - "tuition" - "tumble" - "tuna" - "tunnel" - "turkey" - "turn" - "turtle" - "twelve" - "twenty" - "twice" - "twin" - "twist" - "two" - "type" - "typical" - "ugly" - "umbrella" - "unable" - "unaware" - "uncle" - "uncover" - "under" - "undo" - "unfair" - "unfold" - "unhappy" - "uniform" - "unique" - "unit" - "universe" - "unknown" - "unlock" - "until" - "unusual" - "unveil" - "update" - "upgrade" - "uphold" - "upon" - "upper" - "upset" - "urban" - "urge" - "usage" - "use" - "used" - "useful" - "useless" - "usual" - "utility" - "vacant" - "vacuum" - "vague" - "valid" - "valley" - "valve" - "van" - "vanish" - "vapor" - "various" - "vast" - "vault" - "vehicle" - "velvet" - "vendor" - "venture" - "venue" - "verb" - "verify" - "version" - "very" - "vessel" - "veteran" - "viable" - "vibrant" - "vicious" - "victory" - "video" - "view" - "village" - "vintage" - "violin" - "virtual" - "virus" - "visa" - "visit" - "visual" - "vital" - "vivid" - "vocal" - "voice" - "void" - "volcano" - "volume" - "vote" - "voyage" - "wage" - "wagon" - "wait" - "walk" - "wall" - "walnut" - "want" - "warfare" - "warm" - "warrior" - "wash" - "wasp" - "waste" - "water" - "wave" - "way" - "wealth" - "weapon" - "wear" - "weasel" - "weather" - "web" - "wedding" - "weekend" - "weird" - "welcome" - "west" - "wet" - "whale" - "what" - "wheat" - "wheel" - "when" - "where" - "whip" - "whisper" - "wide" - "width" - "wife" - "wild" - "will" - "win" - "window" - "wine" - "wing" - "wink" - "winner" - "winter" - "wire" - "wisdom" - "wise" - "wish" - "witness" - "wolf" - "woman" - "wonder" - "wood" - "wool" - "word" - "work" - "world" - "worry" - "worth" - "wrap" - "wreck" - "wrestle" - "wrist" - "write" - "wrong" - "yard" - "year" - "yellow" - "you" - "young" - "youth" - "zebra" - "zero" - "zone" - "zoo" -== diff --git a/pkg/bitcoin/lib/bip39/english.hoon b/pkg/bitcoin/lib/bip39/english.hoon new file mode 120000 index 0000000000..f1ea0fe31d --- /dev/null +++ b/pkg/bitcoin/lib/bip39/english.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/bip39/english.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/dbug.hoon b/pkg/bitcoin/lib/dbug.hoon new file mode 120000 index 0000000000..04f6855f78 --- /dev/null +++ b/pkg/bitcoin/lib/dbug.hoon @@ -0,0 +1 @@ +../../base-dev/lib/dbug.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/default-agent.hoon b/pkg/bitcoin/lib/default-agent.hoon new file mode 120000 index 0000000000..698f6802d4 --- /dev/null +++ b/pkg/bitcoin/lib/default-agent.hoon @@ -0,0 +1 @@ +../../base-dev/lib/default-agent.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/docket.hoon b/pkg/bitcoin/lib/docket.hoon new file mode 120000 index 0000000000..e0f69ee1e3 --- /dev/null +++ b/pkg/bitcoin/lib/docket.hoon @@ -0,0 +1 @@ +../../garden-dev/lib/docket.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/ethio.hoon b/pkg/bitcoin/lib/ethio.hoon new file mode 120000 index 0000000000..9c5b581482 --- /dev/null +++ b/pkg/bitcoin/lib/ethio.hoon @@ -0,0 +1 @@ +../../base-dev/lib/ethio.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/group.hoon b/pkg/bitcoin/lib/group.hoon index 1da653b7ec..d314cbdd8f 100644 --- a/pkg/bitcoin/lib/group.hoon +++ b/pkg/bitcoin/lib/group.hoon @@ -4,6 +4,9 @@ |_ =bowl:gall +$ card card:agent:gall :: +++ is-running + .^(? %gu /(scot %p our.bowl)/group-store/(scot %da now.bowl)) +:: ++ resource-for-update |= =vase ^- (list resource) diff --git a/pkg/bitcoin/lib/language-server/build.hoon b/pkg/bitcoin/lib/language-server/build.hoon new file mode 120000 index 0000000000..749928056e --- /dev/null +++ b/pkg/bitcoin/lib/language-server/build.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/language-server/build.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/language-server/complete.hoon b/pkg/bitcoin/lib/language-server/complete.hoon new file mode 120000 index 0000000000..219d824c7b --- /dev/null +++ b/pkg/bitcoin/lib/language-server/complete.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/language-server/complete.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/language-server/easy-print.hoon b/pkg/bitcoin/lib/language-server/easy-print.hoon new file mode 120000 index 0000000000..2160e2f5a6 --- /dev/null +++ b/pkg/bitcoin/lib/language-server/easy-print.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/language-server/easy-print.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/language-server/json.hoon b/pkg/bitcoin/lib/language-server/json.hoon new file mode 120000 index 0000000000..96fe5b5161 --- /dev/null +++ b/pkg/bitcoin/lib/language-server/json.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/language-server/json.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/language-server/parser.hoon b/pkg/bitcoin/lib/language-server/parser.hoon new file mode 120000 index 0000000000..327e1a5de6 --- /dev/null +++ b/pkg/bitcoin/lib/language-server/parser.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/language-server/parser.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/language-server/rune-snippet.hoon b/pkg/bitcoin/lib/language-server/rune-snippet.hoon new file mode 120000 index 0000000000..387505b595 --- /dev/null +++ b/pkg/bitcoin/lib/language-server/rune-snippet.hoon @@ -0,0 +1 @@ +../../../base-dev/lib/language-server/rune-snippet.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/mip.hoon b/pkg/bitcoin/lib/mip.hoon new file mode 120000 index 0000000000..47b46482a3 --- /dev/null +++ b/pkg/bitcoin/lib/mip.hoon @@ -0,0 +1 @@ +../../garden-dev/lib/mip.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/server.hoon b/pkg/bitcoin/lib/server.hoon new file mode 120000 index 0000000000..6176cfc003 --- /dev/null +++ b/pkg/bitcoin/lib/server.hoon @@ -0,0 +1 @@ +../../base-dev/lib/server.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/shoe.hoon b/pkg/bitcoin/lib/shoe.hoon new file mode 120000 index 0000000000..a4aab1dd76 --- /dev/null +++ b/pkg/bitcoin/lib/shoe.hoon @@ -0,0 +1 @@ +../../base-dev/lib/shoe.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/skeleton.hoon b/pkg/bitcoin/lib/skeleton.hoon new file mode 120000 index 0000000000..77626a3276 --- /dev/null +++ b/pkg/bitcoin/lib/skeleton.hoon @@ -0,0 +1 @@ +../../base-dev/lib/skeleton.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/sole.hoon b/pkg/bitcoin/lib/sole.hoon new file mode 120000 index 0000000000..f776890f23 --- /dev/null +++ b/pkg/bitcoin/lib/sole.hoon @@ -0,0 +1 @@ +../../base-dev/lib/sole.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/strand.hoon b/pkg/bitcoin/lib/strand.hoon new file mode 120000 index 0000000000..d95df79480 --- /dev/null +++ b/pkg/bitcoin/lib/strand.hoon @@ -0,0 +1 @@ +../../base-dev/lib/strand.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/strandio.hoon b/pkg/bitcoin/lib/strandio.hoon new file mode 120000 index 0000000000..0caebfac12 --- /dev/null +++ b/pkg/bitcoin/lib/strandio.hoon @@ -0,0 +1 @@ +../../base-dev/lib/strandio.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/treaty.hoon b/pkg/bitcoin/lib/treaty.hoon new file mode 120000 index 0000000000..014f5a1cf2 --- /dev/null +++ b/pkg/bitcoin/lib/treaty.hoon @@ -0,0 +1 @@ +../../base-dev/lib/treaty.hoon \ No newline at end of file diff --git a/pkg/bitcoin/lib/verb.hoon b/pkg/bitcoin/lib/verb.hoon new file mode 120000 index 0000000000..939072347e --- /dev/null +++ b/pkg/bitcoin/lib/verb.hoon @@ -0,0 +1 @@ +../../base-dev/lib/verb.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/belt.hoon b/pkg/bitcoin/mar/belt.hoon new file mode 120000 index 0000000000..0c8999932a --- /dev/null +++ b/pkg/bitcoin/mar/belt.hoon @@ -0,0 +1 @@ +../../base-dev/mar/belt.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/bill.hoon b/pkg/bitcoin/mar/bill.hoon new file mode 120000 index 0000000000..801d99730d --- /dev/null +++ b/pkg/bitcoin/mar/bill.hoon @@ -0,0 +1 @@ +../../base-dev/mar/bill.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/blit.hoon b/pkg/bitcoin/mar/blit.hoon new file mode 120000 index 0000000000..3ea8dc943e --- /dev/null +++ b/pkg/bitcoin/mar/blit.hoon @@ -0,0 +1 @@ +../../base-dev/mar/blit.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/docket.hoon b/pkg/bitcoin/mar/docket.hoon new file mode 120000 index 0000000000..c642f467c4 --- /dev/null +++ b/pkg/bitcoin/mar/docket.hoon @@ -0,0 +1 @@ +../../garden-dev/mar/docket.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/hoon.hoon b/pkg/bitcoin/mar/hoon.hoon new file mode 120000 index 0000000000..95f8f67f9e --- /dev/null +++ b/pkg/bitcoin/mar/hoon.hoon @@ -0,0 +1 @@ +../../base-dev/mar/hoon.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/htm.hoon b/pkg/bitcoin/mar/htm.hoon new file mode 120000 index 0000000000..d29e24bac3 --- /dev/null +++ b/pkg/bitcoin/mar/htm.hoon @@ -0,0 +1 @@ +../../base-dev/mar/htm.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/html.hoon b/pkg/bitcoin/mar/html.hoon new file mode 120000 index 0000000000..14a5f8f7b1 --- /dev/null +++ b/pkg/bitcoin/mar/html.hoon @@ -0,0 +1 @@ +../../base-dev/mar/html.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/httr.hoon b/pkg/bitcoin/mar/httr.hoon new file mode 120000 index 0000000000..5726657784 --- /dev/null +++ b/pkg/bitcoin/mar/httr.hoon @@ -0,0 +1 @@ +../../base-dev/mar/httr.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/hymn.hoon b/pkg/bitcoin/mar/hymn.hoon new file mode 120000 index 0000000000..9051567492 --- /dev/null +++ b/pkg/bitcoin/mar/hymn.hoon @@ -0,0 +1 @@ +../../base-dev/mar/hymn.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/js.hoon b/pkg/bitcoin/mar/js.hoon new file mode 120000 index 0000000000..00189f4c6f --- /dev/null +++ b/pkg/bitcoin/mar/js.hoon @@ -0,0 +1 @@ +../../base-dev/mar/js.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/json.hoon b/pkg/bitcoin/mar/json.hoon new file mode 120000 index 0000000000..e77f85d057 --- /dev/null +++ b/pkg/bitcoin/mar/json.hoon @@ -0,0 +1 @@ +../../base-dev/mar/json.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/json/rpc/response.hoon b/pkg/bitcoin/mar/json/rpc/response.hoon new file mode 120000 index 0000000000..52c97c8648 --- /dev/null +++ b/pkg/bitcoin/mar/json/rpc/response.hoon @@ -0,0 +1 @@ +../../../../base-dev/mar/json/rpc/response.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/kelvin.hoon b/pkg/bitcoin/mar/kelvin.hoon new file mode 120000 index 0000000000..195ebe0dc0 --- /dev/null +++ b/pkg/bitcoin/mar/kelvin.hoon @@ -0,0 +1 @@ +../../base-dev/mar/kelvin.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/language-server/rpc/notification.hoon b/pkg/bitcoin/mar/language-server/rpc/notification.hoon new file mode 120000 index 0000000000..b95e54c353 --- /dev/null +++ b/pkg/bitcoin/mar/language-server/rpc/notification.hoon @@ -0,0 +1 @@ +../../../../base-dev/mar/language-server/rpc/notification.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/language-server/rpc/request.hoon b/pkg/bitcoin/mar/language-server/rpc/request.hoon new file mode 120000 index 0000000000..26203cf5b7 --- /dev/null +++ b/pkg/bitcoin/mar/language-server/rpc/request.hoon @@ -0,0 +1 @@ +../../../../base-dev/mar/language-server/rpc/request.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/language-server/rpc/response.hoon b/pkg/bitcoin/mar/language-server/rpc/response.hoon new file mode 120000 index 0000000000..9dddb2cefd --- /dev/null +++ b/pkg/bitcoin/mar/language-server/rpc/response.hoon @@ -0,0 +1 @@ +../../../../base-dev/mar/language-server/rpc/response.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/mime.hoon b/pkg/bitcoin/mar/mime.hoon new file mode 120000 index 0000000000..0d85898f37 --- /dev/null +++ b/pkg/bitcoin/mar/mime.hoon @@ -0,0 +1 @@ +../../base-dev/mar/mime.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/noun.hoon b/pkg/bitcoin/mar/noun.hoon new file mode 120000 index 0000000000..97cc308763 --- /dev/null +++ b/pkg/bitcoin/mar/noun.hoon @@ -0,0 +1 @@ +../../base-dev/mar/noun.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/path.hoon b/pkg/bitcoin/mar/path.hoon new file mode 120000 index 0000000000..c07b000640 --- /dev/null +++ b/pkg/bitcoin/mar/path.hoon @@ -0,0 +1 @@ +../../base-dev/mar/path.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/png.hoon b/pkg/bitcoin/mar/png.hoon new file mode 120000 index 0000000000..c2d8cf9fa7 --- /dev/null +++ b/pkg/bitcoin/mar/png.hoon @@ -0,0 +1 @@ +../../base-dev/mar/png.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/purl.hoon b/pkg/bitcoin/mar/purl.hoon new file mode 120000 index 0000000000..d0d2cc0de7 --- /dev/null +++ b/pkg/bitcoin/mar/purl.hoon @@ -0,0 +1 @@ +../../base-dev/mar/purl.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/sole/action.hoon b/pkg/bitcoin/mar/sole/action.hoon new file mode 120000 index 0000000000..b349bd7714 --- /dev/null +++ b/pkg/bitcoin/mar/sole/action.hoon @@ -0,0 +1 @@ +../../../base-dev/mar/sole/action.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/sole/effect.hoon b/pkg/bitcoin/mar/sole/effect.hoon new file mode 120000 index 0000000000..bc11205c07 --- /dev/null +++ b/pkg/bitcoin/mar/sole/effect.hoon @@ -0,0 +1 @@ +../../../base-dev/mar/sole/effect.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/svg.hoon b/pkg/bitcoin/mar/svg.hoon new file mode 120000 index 0000000000..2b406c2acd --- /dev/null +++ b/pkg/bitcoin/mar/svg.hoon @@ -0,0 +1 @@ +../../base-dev/mar/svg.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/tang.hoon b/pkg/bitcoin/mar/tang.hoon new file mode 120000 index 0000000000..9206e52b2e --- /dev/null +++ b/pkg/bitcoin/mar/tang.hoon @@ -0,0 +1 @@ +../../base-dev/mar/tang.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/tape.hoon b/pkg/bitcoin/mar/tape.hoon new file mode 120000 index 0000000000..be51fcb2d8 --- /dev/null +++ b/pkg/bitcoin/mar/tape.hoon @@ -0,0 +1 @@ +../../base-dev/mar/tape.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/txt-diff.hoon b/pkg/bitcoin/mar/txt-diff.hoon new file mode 120000 index 0000000000..1f7c042850 --- /dev/null +++ b/pkg/bitcoin/mar/txt-diff.hoon @@ -0,0 +1 @@ +../../base-dev/mar/txt-diff.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/txt.hoon b/pkg/bitcoin/mar/txt.hoon new file mode 120000 index 0000000000..4325415754 --- /dev/null +++ b/pkg/bitcoin/mar/txt.hoon @@ -0,0 +1 @@ +../../base-dev/mar/txt.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/udon.hoon b/pkg/bitcoin/mar/udon.hoon new file mode 120000 index 0000000000..215e0ada9b --- /dev/null +++ b/pkg/bitcoin/mar/udon.hoon @@ -0,0 +1 @@ +../../base-dev/mar/udon.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/umd.hoon b/pkg/bitcoin/mar/umd.hoon new file mode 120000 index 0000000000..9b827a24de --- /dev/null +++ b/pkg/bitcoin/mar/umd.hoon @@ -0,0 +1 @@ +../../base-dev/mar/umd.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/urb.hoon b/pkg/bitcoin/mar/urb.hoon new file mode 120000 index 0000000000..2d8112d1d9 --- /dev/null +++ b/pkg/bitcoin/mar/urb.hoon @@ -0,0 +1 @@ +../../base-dev/mar/urb.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/urbit.hoon b/pkg/bitcoin/mar/urbit.hoon new file mode 120000 index 0000000000..70a62a723f --- /dev/null +++ b/pkg/bitcoin/mar/urbit.hoon @@ -0,0 +1 @@ +../../base-dev/mar/urbit.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/woff2.hoon b/pkg/bitcoin/mar/woff2.hoon new file mode 120000 index 0000000000..beaf4875c4 --- /dev/null +++ b/pkg/bitcoin/mar/woff2.hoon @@ -0,0 +1 @@ +../../base-dev/mar/woff2.hoon \ No newline at end of file diff --git a/pkg/bitcoin/mar/xml.hoon b/pkg/bitcoin/mar/xml.hoon new file mode 120000 index 0000000000..e6323e2157 --- /dev/null +++ b/pkg/bitcoin/mar/xml.hoon @@ -0,0 +1 @@ +../../base-dev/mar/xml.hoon \ No newline at end of file diff --git a/pkg/bitcoin/sur/bill.hoon b/pkg/bitcoin/sur/bill.hoon new file mode 120000 index 0000000000..c048171cb0 --- /dev/null +++ b/pkg/bitcoin/sur/bill.hoon @@ -0,0 +1 @@ +../../base-dev/sur/bill.hoon \ No newline at end of file diff --git a/pkg/bitcoin/sur/docket.hoon b/pkg/bitcoin/sur/docket.hoon new file mode 120000 index 0000000000..e13676adb2 --- /dev/null +++ b/pkg/bitcoin/sur/docket.hoon @@ -0,0 +1 @@ +../../garden-dev/sur/docket.hoon \ No newline at end of file diff --git a/pkg/bitcoin/sur/hood.hoon b/pkg/bitcoin/sur/hood.hoon new file mode 120000 index 0000000000..b212f501ef --- /dev/null +++ b/pkg/bitcoin/sur/hood.hoon @@ -0,0 +1 @@ +../../base-dev/sur/hood.hoon \ No newline at end of file diff --git a/pkg/bitcoin/sur/settings.hoon b/pkg/bitcoin/sur/settings.hoon deleted file mode 100644 index 67a071f7da..0000000000 --- a/pkg/bitcoin/sur/settings.hoon +++ /dev/null @@ -1,31 +0,0 @@ -|% -+$ settings-0 (map key bucket-0) -+$ bucket-0 (map key val-0) -+$ val-0 - $% [%s p=@t] - [%b p=?] - [%n p=@] - == -:: -+$ settings (map key bucket) -+$ bucket (map key val) -+$ key term -+$ val - $~ [%n 0] - $% [%s p=@t] - [%b p=?] - [%n p=@] - [%a p=(list val)] - == -+$ event - $% [%put-bucket =key =bucket] - [%del-bucket =key] - [%put-entry buc=key =key =val] - [%del-entry buc=key =key] - == -+$ data - $% [%all =settings] - [%bucket =bucket] - [%entry =val] - == --- diff --git a/pkg/bitcoin/sur/settings.hoon b/pkg/bitcoin/sur/settings.hoon new file mode 120000 index 0000000000..c2c70beefe --- /dev/null +++ b/pkg/bitcoin/sur/settings.hoon @@ -0,0 +1 @@ +../../garden-dev/sur/settings.hoon \ No newline at end of file diff --git a/pkg/bitcoin/sur/sole.hoon b/pkg/bitcoin/sur/sole.hoon new file mode 120000 index 0000000000..8cac118917 --- /dev/null +++ b/pkg/bitcoin/sur/sole.hoon @@ -0,0 +1 @@ +../../base-dev/sur/sole.hoon \ No newline at end of file diff --git a/pkg/bitcoin/sur/spider.hoon b/pkg/bitcoin/sur/spider.hoon new file mode 120000 index 0000000000..12ae2c1877 --- /dev/null +++ b/pkg/bitcoin/sur/spider.hoon @@ -0,0 +1 @@ +../../base-dev/sur/spider.hoon \ No newline at end of file diff --git a/pkg/bitcoin/sur/verb.hoon b/pkg/bitcoin/sur/verb.hoon new file mode 120000 index 0000000000..1a6100d9ce --- /dev/null +++ b/pkg/bitcoin/sur/verb.hoon @@ -0,0 +1 @@ +../../base-dev/sur/verb.hoon \ No newline at end of file diff --git a/pkg/garden-dev/lib/mip.hoon b/pkg/garden-dev/lib/mip.hoon new file mode 100644 index 0000000000..322a4c85f9 --- /dev/null +++ b/pkg/garden-dev/lib/mip.hoon @@ -0,0 +1,55 @@ +|% +++ mip :: map of maps + |$ [kex key value] + (map kex (map key value)) +:: +++ bi :: mip engine + =| a=(map * (map)) + |@ + ++ del + |* [b=* c=*] + =+ d=(~(gut by a) b ~) + =+ e=(~(del by d) c) + ?~ e + (~(del by a) b) + (~(put by a) b e) + :: + ++ get + |* [b=* c=*] + => .(b `_?>(?=(^ a) p.n.a)`b, c `_?>(?=(^ a) ?>(?=(^ q.n.a) p.n.q.n.a))`c) + ^- (unit _?>(?=(^ a) ?>(?=(^ q.n.a) q.n.q.n.a))) + (~(get by (~(gut by a) b ~)) c) + :: + ++ got + |* [b=* c=*] + (need (get b c)) + :: + ++ gut + |* [b=* c=* d=*] + (~(gut by (~(gut by a) b ~)) c d) + :: + ++ has + |* [b=* c=*] + !=(~ (get b c)) + :: + ++ key + |* b=* + ~(key by (~(gut by a) b ~)) + :: + ++ put + |* [b=* c=* d=*] + %+ ~(put by a) b + %. [c d] + %~ put by + (~(gut by a) b ~) + :: + ++ tap + ::NOTE naive turn-based implementation find-errors ): + =< $ + =+ b=`_?>(?=(^ a) *(list [x=_p.n.a _?>(?=(^ q.n.a) [y=p v=q]:n.q.n.a)]))`~ + |. ^+ b + ?~ a + b + $(a r.a, b (welp (turn ~(tap by q.n.a) (lead p.n.a)) $(a l.a))) + -- +-- diff --git a/pkg/garden/lib/mip.hoon b/pkg/garden/lib/mip.hoon deleted file mode 100644 index 322a4c85f9..0000000000 --- a/pkg/garden/lib/mip.hoon +++ /dev/null @@ -1,55 +0,0 @@ -|% -++ mip :: map of maps - |$ [kex key value] - (map kex (map key value)) -:: -++ bi :: mip engine - =| a=(map * (map)) - |@ - ++ del - |* [b=* c=*] - =+ d=(~(gut by a) b ~) - =+ e=(~(del by d) c) - ?~ e - (~(del by a) b) - (~(put by a) b e) - :: - ++ get - |* [b=* c=*] - => .(b `_?>(?=(^ a) p.n.a)`b, c `_?>(?=(^ a) ?>(?=(^ q.n.a) p.n.q.n.a))`c) - ^- (unit _?>(?=(^ a) ?>(?=(^ q.n.a) q.n.q.n.a))) - (~(get by (~(gut by a) b ~)) c) - :: - ++ got - |* [b=* c=*] - (need (get b c)) - :: - ++ gut - |* [b=* c=* d=*] - (~(gut by (~(gut by a) b ~)) c d) - :: - ++ has - |* [b=* c=*] - !=(~ (get b c)) - :: - ++ key - |* b=* - ~(key by (~(gut by a) b ~)) - :: - ++ put - |* [b=* c=* d=*] - %+ ~(put by a) b - %. [c d] - %~ put by - (~(gut by a) b ~) - :: - ++ tap - ::NOTE naive turn-based implementation find-errors ): - =< $ - =+ b=`_?>(?=(^ a) *(list [x=_p.n.a _?>(?=(^ q.n.a) [y=p v=q]:n.q.n.a)]))`~ - |. ^+ b - ?~ a - b - $(a r.a, b (welp (turn ~(tap by q.n.a) (lead p.n.a)) $(a l.a))) - -- --- diff --git a/pkg/garden/lib/mip.hoon b/pkg/garden/lib/mip.hoon new file mode 120000 index 0000000000..47b46482a3 --- /dev/null +++ b/pkg/garden/lib/mip.hoon @@ -0,0 +1 @@ +../../garden-dev/lib/mip.hoon \ No newline at end of file From 6b5942b59ac157e67a07113b8c0ae91431e994d2 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Mon, 13 Sep 2021 11:19:11 +1000 Subject: [PATCH 2/3] btc-wallet: update build, fix routing --- pkg/btc-wallet/config/webpack.dev.js | 37 ++- pkg/btc-wallet/config/webpack.prod.js | 11 +- pkg/btc-wallet/public/index.html | 30 ++ pkg/btc-wallet/src/index.js | 4 +- pkg/btc-wallet/src/js/channel.js | 290 ++++++++++++++++++ pkg/btc-wallet/src/js/components/lib/body.js | 4 +- .../src/js/components/lib/header.js | 2 +- pkg/btc-wallet/src/js/components/root.js | 2 +- pkg/btc-wallet/src/js/store.js | 4 +- pkg/btc-wallet/src/js/subscription.js | 1 + 10 files changed, 357 insertions(+), 28 deletions(-) create mode 100644 pkg/btc-wallet/public/index.html create mode 100644 pkg/btc-wallet/src/js/channel.js diff --git a/pkg/btc-wallet/config/webpack.dev.js b/pkg/btc-wallet/config/webpack.dev.js index 368de77177..532f849740 100644 --- a/pkg/btc-wallet/config/webpack.dev.js +++ b/pkg/btc-wallet/config/webpack.dev.js @@ -1,6 +1,6 @@ const path = require('path'); const webpack = require('webpack'); -// const HtmlWebpackPlugin = require('html-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); // const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const urbitrc = require('./urbitrc'); const fs = require('fs-extra'); @@ -33,6 +33,7 @@ let devServer = { host: '0.0.0.0', disableHostCheck: true, historyApiFallback: true, + publicPath: '/apps/bitcoin/', }; const router = _.mapKeys(urbitrc.FLEET || {}, (value, key) => `${key}.localhost:9000`); @@ -40,22 +41,19 @@ const router = _.mapKeys(urbitrc.FLEET || {}, (value, key) => `${key}.localhost: if(urbitrc.URL) { devServer = { ...devServer, - index: '', - proxy: { - '/~btc/js/bundle/index.*.js': { - target: 'http://localhost:9000', - pathRewrite: (req, path) => { - return '/index.js' + index: 'index.html', + proxy: [{ + target: 'http://localhost:9000', + changeOrigin: true, + target: urbitrc.URL, + router, + context: path => { + if(path === '/apps/bitcoin/desk.js') { + return true; } - }, - '**': { - changeOrigin: true, - target: urbitrc.URL, - router, - // ensure proxy doesn't timeout channels - proxyTimeout: 0 + return !path.startsWith('/apps/bitcoin') } - } + }] }; } @@ -107,7 +105,12 @@ module.exports = { devtool: 'inline-source-map', devServer: devServer, plugins: [ - new UrbitShipPlugin(urbitrc) + new UrbitShipPlugin(urbitrc), + new HtmlWebpackPlugin({ + title: 'Bitcoin Wallet', + template: './public/index.html' + }) + ], watch: true, watchOptions: { @@ -118,7 +121,7 @@ module.exports = { filename: 'index.js', chunkFilename: 'index.js', path: path.resolve(__dirname, '../dist'), - publicPath: '/', + publicPath: '/apps/bitcoin/', globalObject: 'this' }, optimization: { diff --git a/pkg/btc-wallet/config/webpack.prod.js b/pkg/btc-wallet/config/webpack.prod.js index ed7403784e..7f184e5473 100644 --- a/pkg/btc-wallet/config/webpack.prod.js +++ b/pkg/btc-wallet/config/webpack.prod.js @@ -1,5 +1,6 @@ const path = require('path'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); // const urbitrc = require('./urbitrc'); module.exports = { @@ -44,14 +45,18 @@ module.exports = { }, devtool: 'source-map', plugins: [ - new CleanWebpackPlugin() + new CleanWebpackPlugin(), + new HtmlWebpackPlugin({ + title: 'Bitcoin Wallet', + template: './public/index.html' + }) ], output: { filename: (pathData) => { return pathData.chunk.name === 'app' ? 'index.[contenthash].js' : '[name].js'; }, - path: path.resolve(__dirname, `../../arvo/app/btc-wallet/js/bundle`), - publicPath: '/', + path: path.resolve(__dirname, 'dist'), + publicPath: '/apps/bitcoin/', }, optimization: { minimize: true, diff --git a/pkg/btc-wallet/public/index.html b/pkg/btc-wallet/public/index.html new file mode 100644 index 0000000000..059cc631d4 --- /dev/null +++ b/pkg/btc-wallet/public/index.html @@ -0,0 +1,30 @@ + + + + Wallet + + + + + + + + + +
+
+ + + + diff --git a/pkg/btc-wallet/src/index.js b/pkg/btc-wallet/src/index.js index d4852ef264..5aa431a923 100644 --- a/pkg/btc-wallet/src/index.js +++ b/pkg/btc-wallet/src/index.js @@ -2,7 +2,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Root } from './js/components/root.js'; import { api } from './js/api.js'; -import { subscription } from "./js/subscription.js"; +import Channel from './js/channel'; import './css/indigo-static.css'; import './css/fonts.css'; @@ -10,7 +10,7 @@ import './css/custom.css'; // rebuild x3 -const channel = new window.channel(); +const channel = new Channel(); api.setChannel(window.ship, channel); diff --git a/pkg/btc-wallet/src/js/channel.js b/pkg/btc-wallet/src/js/channel.js new file mode 100644 index 0000000000..48d7e62ef4 --- /dev/null +++ b/pkg/btc-wallet/src/js/channel.js @@ -0,0 +1,290 @@ +export default class Channel { + constructor() { + this.init(); + this.deleteOnUnload(); + + // a way to handle channel errors + // + // + this.onChannelError = (err) => { + console.error('event source error: ', err); + }; + this.onChannelOpen = (e) => { + console.log('open', e); + }; + } + + init() { + this.debounceInterval = 500; + // unique identifier: current time and random number + // + this.uid = + new Date().getTime().toString() + + "-" + + Math.random().toString(16).slice(-6); + + this.requestId = 1; + + // the currently connected EventSource + // + this.eventSource = null; + + // the id of the last EventSource event we received + // + this.lastEventId = 0; + + // this last event id acknowledgment sent to the server + // + this.lastAcknowledgedEventId = 0; + + // a registry of requestId to successFunc/failureFunc + // + // These functions are registered during a +poke and are executed + // in the onServerEvent()/onServerError() callbacks. Only one of + // the functions will be called, and the outstanding poke will be + // removed after calling the success or failure function. + // + + this.outstandingPokes = new Map(); + + // a registry of requestId to subscription functions. + // + // These functions are registered during a +subscribe and are + // executed in the onServerEvent()/onServerError() callbacks. The + // event function will be called whenever a new piece of data on this + // subscription is available, which may be 0, 1, or many times. The + // disconnect function may be called exactly once. + // + this.outstandingSubscriptions = new Map(); + + this.outstandingJSON = []; + + this.debounceTimer = null; + } + + resetDebounceTimer() { + if (this.debounceTimer) { + clearTimeout(this.debounceTimer); + this.debounceTimer = null; + } + this.debounceTimer = setTimeout(() => { + this.sendJSONToChannel(); + }, this.debounceInterval) + } + + setOnChannelError(onError = (err) => {}) { + this.onChannelError = onError; + } + + setOnChannelOpen(onOpen = (e) => {}) { + this.onChannelOpen = onOpen; + } + + deleteOnUnload() { + window.addEventListener("beforeunload", (event) => { + this.delete(); + }); + } + + clearQueue() { + clearTimeout(this.debounceTimer); + this.debounceTimer = null; + this.sendJSONToChannel(); + } + + // sends a poke to an app on an urbit ship + // + poke(ship, app, mark, json, successFunc, failureFunc) { + let id = this.nextId(); + this.outstandingPokes.set( + id, + { + success: successFunc, + fail: failureFunc + } + ); + + const j = { + id, + action: "poke", + ship, + app, + mark, + json + }; + + this.sendJSONToChannel(j); + } + + // subscribes to a path on an specific app and ship. + // + // Returns a subscription id, which is the same as the same internal id + // passed to your Urbit. + subscribe( + ship, + app, + path, + connectionErrFunc = () => {}, + eventFunc = () => {}, + quitFunc = () => {}, + subAckFunc = () => {}, + ) { + let id = this.nextId(); + this.outstandingSubscriptions.set( + id, + { + err: connectionErrFunc, + event: eventFunc, + quit: quitFunc, + subAck: subAckFunc + } + ); + + const json = { + id, + action: "subscribe", + ship, + app, + path + } + + this.resetDebounceTimer(); + + this.outstandingJSON.push(json); + return id; + } + + // quit the channel + // + delete() { + let id = this.nextId(); + clearInterval(this.ackTimer); + navigator.sendBeacon(this.channelURL(), JSON.stringify([{ + id, + action: "delete" + }])); + if (this.eventSource) { + this.eventSource.close(); + } + } + + // unsubscribe to a specific subscription + // + unsubscribe(subscription) { + let id = this.nextId(); + this.sendJSONToChannel({ + id, + action: "unsubscribe", + subscription + }); + } + + // sends a JSON command command to the server. + // + sendJSONToChannel(j) { + let req = new XMLHttpRequest(); + req.open("PUT", this.channelURL()); + req.setRequestHeader("Content-Type", "application/json"); + + if (this.lastEventId == this.lastAcknowledgedEventId) { + if (j) { + this.outstandingJSON.push(j); + } + + if (this.outstandingJSON.length > 0) { + let x = JSON.stringify(this.outstandingJSON); + req.send(x); + } + } else { + // we add an acknowledgment to clear the server side queue + // + // The server side puts messages it sends us in a queue until we + // acknowledge that we received it. + // + let payload = [ + ...this.outstandingJSON, + {action: "ack", "event-id": this.lastEventId} + ]; + if (j) { + payload.push(j) + } + let x = JSON.stringify(payload); + req.send(x); + + this.lastAcknowledgedEventId = this.lastEventId; + } + this.outstandingJSON = []; + + this.connectIfDisconnected(); + } + + // connects to the EventSource if we are not currently connected + // + connectIfDisconnected() { + if (this.eventSource) { + return; + } + + this.eventSource = new EventSource(this.channelURL(), {withCredentials:true}); + this.eventSource.onmessage = e => { + this.lastEventId = parseInt(e.lastEventId, 10); + + let obj = JSON.parse(e.data); + let pokeFuncs = this.outstandingPokes.get(obj.id); + let subFuncs = this.outstandingSubscriptions.get(obj.id); + + if (obj.response == "poke" && !!pokeFuncs) { + let funcs = pokeFuncs; + if (obj.hasOwnProperty("ok")) { + funcs["success"](); + } else if (obj.hasOwnProperty("err")) { + funcs["fail"](obj.err); + } else { + console.error("Invalid poke response: ", obj); + } + this.outstandingPokes.delete(obj.id); + + } else if (obj.response == "subscribe" || + (obj.response == "poke" && !!subFuncs)) { + let funcs = subFuncs; + + if (obj.hasOwnProperty("err")) { + funcs["err"](obj.err); + this.outstandingSubscriptions.delete(obj.id); + } else if (obj.hasOwnProperty("ok")) { + funcs["subAck"](obj); + } + } else if (obj.response == "diff") { + // ensure we ack before channel clogs + if((this.lastEventId - this.lastAcknowledgedEventId) > 30) { + this.clearQueue(); + } + + let funcs = subFuncs; + funcs["event"](obj.json); + } else if (obj.response == "quit") { + let funcs = subFuncs; + funcs["quit"](obj); + this.outstandingSubscriptions.delete(obj.id); + } else { + console.log("Unrecognized response: ", e); + } + } + + this.eventSource.onopen = this.onChannelOpen; + + this.eventSource.onerror = e => { + this.delete(); + this.init(); + this.onChannelError(e); + } + } + + channelURL() { + return "/~/channel/" + this.uid; + } + + nextId() { + return this.requestId++; + } +} diff --git a/pkg/btc-wallet/src/js/components/lib/body.js b/pkg/btc-wallet/src/js/components/lib/body.js index eff8c8d8ef..0fe1d798d6 100644 --- a/pkg/btc-wallet/src/js/components/lib/body.js +++ b/pkg/btc-wallet/src/js/components/lib/body.js @@ -40,7 +40,7 @@ export default class Body extends Component { } else { return ( - + - + + {loaded ? ( diff --git a/pkg/btc-wallet/src/js/store.js b/pkg/btc-wallet/src/js/store.js index 40cd3270fe..c10097bcc6 100644 --- a/pkg/btc-wallet/src/js/store.js +++ b/pkg/btc-wallet/src/js/store.js @@ -7,7 +7,7 @@ class Store { constructor() { this.state = { loadedBtc: false, - loadedSettings: false, + loadedSettings: true, loaded: false, providerPerms: {}, shipWallets: {}, @@ -23,7 +23,7 @@ class Store { BTC: { last: 1, symbol: 'BTC' } }, denomination: 'BTC', - showWarning: true, + showWarning: false, error: '', broadcastSuccess: false, }; diff --git a/pkg/btc-wallet/src/js/subscription.js b/pkg/btc-wallet/src/js/subscription.js index d83f65d92b..10adfe1c68 100644 --- a/pkg/btc-wallet/src/js/subscription.js +++ b/pkg/btc-wallet/src/js/subscription.js @@ -19,6 +19,7 @@ export class Subscription { } initializeSettings() { + return; let app = 'settings-store'; let path = '/bucket/btc-wallet'; From 61ed89c708b6b3be6184fb8185c08be4c858c9b3 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Mon, 13 Sep 2021 11:36:17 +1000 Subject: [PATCH 3/3] btc-wallet: update for new settings --- pkg/btc-wallet/public/index.html | 2 +- pkg/btc-wallet/src/js/components/lib/currencyPicker.js | 1 + pkg/btc-wallet/src/js/components/lib/warning.js | 1 + pkg/btc-wallet/src/js/subscription.js | 3 +-- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/btc-wallet/public/index.html b/pkg/btc-wallet/public/index.html index 059cc631d4..3bd4223211 100644 --- a/pkg/btc-wallet/public/index.html +++ b/pkg/btc-wallet/public/index.html @@ -24,7 +24,7 @@
- + diff --git a/pkg/btc-wallet/src/js/components/lib/currencyPicker.js b/pkg/btc-wallet/src/js/components/lib/currencyPicker.js index 053201bf61..baa2da5632 100644 --- a/pkg/btc-wallet/src/js/components/lib/currencyPicker.js +++ b/pkg/btc-wallet/src/js/components/lib/currencyPicker.js @@ -30,6 +30,7 @@ export default class CurrencyPicker extends Component { } let setCurrency = { "put-entry": { + desk: window.desk, value: newCurrency, "entry-key": "currency", "bucket-key": "btc-wallet", diff --git a/pkg/btc-wallet/src/js/components/lib/warning.js b/pkg/btc-wallet/src/js/components/lib/warning.js index 0feaf75ada..04392ef7e0 100644 --- a/pkg/btc-wallet/src/js/components/lib/warning.js +++ b/pkg/btc-wallet/src/js/components/lib/warning.js @@ -24,6 +24,7 @@ export default class Warning extends Component { store.handleEvent({ data: { bucket: { warning: false}}}); let removeWarning = { "put-entry": { + desk: window.desk, value: false, "entry-key": "warning", "bucket-key": "btc-wallet", diff --git a/pkg/btc-wallet/src/js/subscription.js b/pkg/btc-wallet/src/js/subscription.js index 10adfe1c68..09754a9388 100644 --- a/pkg/btc-wallet/src/js/subscription.js +++ b/pkg/btc-wallet/src/js/subscription.js @@ -19,9 +19,8 @@ export class Subscription { } initializeSettings() { - return; let app = 'settings-store'; - let path = '/bucket/btc-wallet'; + let path = `/bucket/${window.desk}/btc-wallet`; fetch(`/~/scry/${app}${path}.json`).then(res => res.json()) .then(n => {