Merge remote-tracking branch 'origin/dist' into lf/nu-hark-store

This commit is contained in:
Liam Fitzgerald 2021-09-14 12:40:52 +10:00
commit a433e4f911
197 changed files with 78318 additions and 31490 deletions

2
.gitignore vendored
View File

@ -78,3 +78,5 @@ pkg/interface/link-webext/web-ext-artifacts
# Logs
*.log
.vercel

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b8972fd91602b0d2cca76ade229d11aaaca0bc3c89da53c42f4f12895190b4b2
size 13762742
oid sha256:f24c64caed01a0cd6cfc7c82cc540ad1da0c2fd8f4e5e858bae59407e2a90c75
size 13881546

View File

@ -1,3 +1,4 @@
/* Examples
Shared urbit and urbit-worker binaries:

View File

@ -17,6 +17,6 @@
"build:prod": "lerna run build:prod"
},
"lint-staged": {
"*.{js,ts,tsx}": "eslint --cache --fix"
"*.{js,ts,tsx}": "eslint --cache --fix --quiet"
}
}

View File

@ -2,8 +2,8 @@
/+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln
|%
+$ state
$~ [%17 *state:drum *state:helm *state:kiln]
$>(%17 any-state)
$~ [%19 *state:drum *state:helm *state:kiln]
$>(%19 any-state)
::
+$ any-state
$% [ver=?(%1 %2 %3 %4 %5 %6) lac=(map @tas fin-any-state)]
@ -18,6 +18,8 @@
[%15 drum=state-2:drum helm=state:helm kiln=state-2:kiln]
[%16 drum=state-4:drum helm=state:helm kiln=state-3:kiln]
[%17 drum=state-4:drum helm=state:helm kiln=state-4:kiln]
[%18 drum=state-4:drum helm=state:helm kiln=state-5:kiln]
[%19 drum=state-4:drum helm=state:helm kiln=state-6:kiln]
==
+$ any-state-tuple
$: drum=any-state:drum

View File

@ -167,10 +167,9 @@
=+ !<(any=clean-slate-any old-state)
=? any ?=(^ -.any) (old-to-1 any)
=? any ?=(~ -.any) (old-to-1 any)
=^ cards-to-2 any
=^ upgrade-cards any
(old-to-2 any)
=^ cards-to-3 any
(old-to-3 any)
=. any (old-to-3 any)
?> ?=(%3 -.any)
::
=. tid.state tid.any
@ -184,7 +183,7 @@
(handle-stop-thread:sc (yarn-to-tid i.yarns) |)
=^ cards-2 this
$(yarns t.yarns)
[:(weld cards-to-2 cards-to-3 cards-1 cards-2) this]
[:(weld upgrade-cards cards-1 cards-2) this]
::
++ old-to-1
|= old=clean-slate-ket
@ -207,20 +206,16 @@
::
++ old-to-3
|= old=clean-slate-any
^- (quip card clean-slate)
^- clean-slate
?> ?=(?(%2 %3) -.old)
?: ?=(%3 -.old)
`old
:- ~
old
:* %3
starting.old
running.old
tid.old
%- ~(gas by *(map tid [@ta =mark =desk]))
%+ turn ~(tap by serving.old)
|=([=tid id=@ta =mark] [tid id mark q.byk.bowl])
(~(run by serving.old) |=([id=@ta =mark] [id mark q.byk.bowl]))
==
--
::
++ on-poke
@ -552,7 +547,7 @@
=+ .^
=tube:clay
%cc
/(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[output]/json
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[output]/json
==
:_ state(serving (~(del by serving.state) tid))
%+ give-simple-payload:app:server eyre-id

View File

@ -0,0 +1,5 @@
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[[=desk ~] ~]
==
[%kiln-pause desk]

View File

@ -0,0 +1,5 @@
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[[=desk ~] ~]
==
[%kiln-resume desk]

View File

@ -5,7 +5,9 @@
=, format
=* dude dude:gall
|%
+$ state state-4
+$ state state-6
+$ state-6 [%6 pith-6]
+$ state-5 [%5 pith-5]
+$ state-4 [%4 pith-4]
+$ state-3 [%3 pith-3]
+$ state-2 [%2 pith-2]
@ -13,13 +15,32 @@
+$ state-0 [%0 pith-0]
+$ any-state
$~ *state
$% state-4
$% state-6
state-5
state-4
state-3
state-2
state-1
state-0
==
+$ pith-4 ::
::
+$ pith-6
$: wef=(unit weft)
rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) ::
ark=(map desk arak) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
:: map desk to the currently ongoing fuse request
:: and the latest version numbers for beaks to
fus=(map desk per-fuse)
:: used for fuses - every time we get a fuse we
:: bump this. used when calculating hashes to
:: ensure they're unique even when the same
:: request is made multiple times.
hxs=(map desk @ud)
== ::
::
+$ pith-5
$: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) ::
ark=(map desk arak) ::
@ -33,6 +54,28 @@
:: request is made multiple times.
hxs=(map desk @ud)
== ::
::
+$ pith-4 ::
$: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) ::
ark=(map desk arak-4) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
:: map desk to the currently ongoing fuse request
:: and the latest version numbers for beaks to
fus=(map desk per-fuse)
:: used for fuses - every time we get a fuse we
:: bump this. used when calculating hashes to
:: ensure they're unique even when the same
:: request is made multiple times.
hxs=(map desk @ud)
== ::
+$ arak-4
$: =ship
=desk
=aeon
next=(list rung)
=rein
==
+$ pith-3 ::
$: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) ::
@ -51,7 +94,7 @@
$: =ship
=desk
=aeon
next=(list [=aeon =weft])
next=(list rung)
rein=rein-3
==
+$ rein-3
@ -217,22 +260,31 @@
fus.old
hxs.old
==
=? old ?=(%3 -.old)
:* %4
rem.old
syn.old
ark=(~(run by ark.old) |=(a=arak-3 a(rein [liv=& rein.a])))
commit-timer.old
fus.old
hxs.old
==
::
?> ?=(%4 -.old)
=? old ?=(%3 -.old)
:- %4
+.old(ark (~(run by ark.old) |=(a=arak-3 a(rein [liv=& rein.a]))))
::
=? old ?=(%4 -.old)
:- %5
=- +.old(ark -)
%- ~(run by ark.old)
|= a=arak-4
^- arak
[[paused=| ship desk aeon] next rein]:a
=? old ?=(%5 -.old)
[%6 ~ +.old]
::
?> ?=(%6 -.old)
=. +<+.$.abet old
=< abet
?~ old-ota
kiln
abet:(install:vats %base [her sud]:u.old-ota)
=? kiln ?=(^ old-ota)
abet:(install:vats %base [her sud]:u.old-ota)
=? kiln ?=(^ wef)
=/ except=(set desk) (sy %base %kids ~)
(bump:vats u.wef (all-desks-but:vats except) %.n)
=. wef ~
kiln
::
++ on-peek
|= =path
@ -279,7 +331,7 @@
~_ leaf/"kiln: {<lac>} not installed"
vats(loc lac, rak (~(got by ark) lac))
::
++ here "{<loc>} from {<[ship desk]:rak>}"
++ here "{<loc>} from {<[ship desk]:rail.rak>}"
++ make-wire |=(step=@tas /kiln/vats/[loc]/[step])
++ from-wire
|= =wire
@ -299,17 +351,21 @@
++ pyre |=(=tang [%pass /kiln/vats %pyre tang])
++ find (warp %find [%sing %y ud+1 /])
++ sync-da (warp %sync [%sing %w da+now /])
++ sync-ud (warp %sync [%sing %w ud+aeon.rak /])
++ download (warp %download [%sing %v ud+aeon.rak /])
++ warp |=([s=term r=rave] (clay-card s %warp ship.rak desk.rak `r))
++ sync-ud (warp %sync [%sing %w ud+aeon.rail.rak /])
++ download (warp %download [%sing %v ud+aeon.rail.rak /])
++ warp
|= [s=term r=rave]
(clay-card s %warp ship.rail.rak desk.rail.rak `r)
++ merge-main
=/ germ (get-germ loc)
=/ =aeon (dec aeon.rak)
(clay-card %merge-main [%merg loc ship.rak desk.rak ud+aeon germ])
=/ =aeon (dec aeon.rail.rak)
%+ clay-card %merge-main
[%merg loc ship.rail.rak desk.rail.rak ud+aeon germ]
++ merge-kids
=/ germ (get-germ %kids)
=/ =aeon (dec aeon.rak)
(clay-card %merge-kids [%merg %kids ship.rak desk.rak ud+aeon germ])
=/ =aeon (dec aeon.rail.rak)
%+ clay-card %merge-kids
[%merg %kids ship.rail.rak desk.rail.rak ud+aeon germ]
++ clay-card
|= [step=@tas =task:clay]
^- card:agent:gall
@ -359,9 +415,8 @@
?: =(`[her rem] got)
~> %slog.0^leaf/"kiln: already tracking {here:(abed lac)}, ignoring"
vats
=? kiln ?=(^ got) (uninstall lac)
=: loc lac
rak [her rem *aeon next=~ *rein]
rak [[paused=| her rem *aeon] next=~ rein:(fall got *arak)]
==
~> %slog.0^leaf/"kiln: beginning install into {here}"
(emit find:pass)
@ -370,9 +425,37 @@
++ reset
^+ vats
~> %slog.0^leaf/"kiln: resetting tracking for {here}"
=. vats (emit (diff:give %reset loc rak))
=. ark (~(del by ark) loc)
(install loc [ship desk]:rak)
=/ cad (diff:give %reset loc rak)
=. aeon.rail.rak 0
=. next.rak ~
(emil find:pass cad ~)
:: +pause: stop syncing from upstream
::
++ pause
|= lac=desk
^+ vats
=. vats (abed lac)
~> %slog. :+ %0 %leaf
?: paused.rail.rak
"kiln: {<lac>} already paused, ignoring"
"kiln: {<lac>} pausing updates"
=: paused.rail.rak &
aeon.rail.rak 0
==
vats
:: +resume: restart tracking from upstream
::
:: TODO: check whether kelvin is legit
::
++ resume
|= lac=desk
^+ vats
=. vats (abed lac)
~> %slog. :+ %0 %leaf
?. paused.rail.rak
"kiln: {<lac>} already tracking, ignoring"
"kiln: {<lac>} resuming updates"
reset
:: +suspend: shut down all agents, keep syncing
::
++ suspend
@ -423,7 +506,7 @@
=/ ded (find-blocked kel except)
?: force
=. kiln (suspend-many ded)
(bump-many kel (all-desks-but except))
(bump-many kel (all-desks-but (~(uni in except) ded)))
?: =(~ ded)
(bump-many kel (all-desks-but except))
=- (^emit (pyre:pass leaf/- ~))
@ -447,7 +530,16 @@
++ bump-many
|= [kel=weft live=(set desk)]
^+ kiln
=/ liv ~(tap in live)
:: ensure %base is always reloaded first
::
=/ liv
%+ sort ~(tap in live)
|= [a=desk b=desk]
^- ?
?: =(%base a) &
?: =(%base b) |
(lte `@`a `@`b)
::
|- ^+ kiln
?~ liv kiln
$(liv t.liv, kiln (bump-one kel i.liv))
@ -498,6 +590,8 @@
|= syn=sign-arvo
^+ vats
?> ?=(%writ +<.syn)
?: paused.rail.rak
vats
?~ p.syn
~> %slog.0^leaf/"kiln: cancelled (1) install into {here}, aborting"
vats(ark (~(del by ark) loc))
@ -508,54 +602,91 @@
|= syn=sign-arvo
^+ vats
?> ?=(%writ +<.syn)
?: paused.rail.rak
vats
?~ p.syn
~> %slog.0^leaf/"kiln: cancelled (1) install into {here}, retrying"
reset
~> %slog.0^leaf/"kiln: downloading update for {here}"
=? aeon.rak ?=(%w p.p.u.p.syn) ud:;;(cass:clay q.q.r.u.p.syn)
=? aeon.rail.rak ?=(%w p.p.u.p.syn) ud:;;(cass:clay q.q.r.u.p.syn)
(emit download:pass)
::
++ take-download
|= syn=sign-arvo
^+ vats
?> ?=(%writ +<.syn)
?: paused.rail.rak
vats
?~ p.syn
~> %slog.0^leaf/"kiln: cancelled (2) install into {here}, retrying"
reset
~> %slog.0^leaf/"kiln: finished downloading update for {here}"
=/ old-weft `weft`[%zuse zuse]
=/ new-weft (read-kelvin-foreign [ship desk aeon]:rak)
=. aeon.rak +(aeon.rak)
=/ new-weft (read-kelvin-foreign [ship desk aeon]:rail.rak)
=? vats liv.rein.rak
=/ bill (read-bill-foreign [ship desk aeon]:rail.rak)
=/ wan (sy (get-apps-want bill rein.rak))
=/ hav (sy (get-apps-live our loc now))
=/ ded ~(tap in (~(dif in hav) wan))
(stop-dudes ded)
=. aeon.rail.rak +(aeon.rail.rak)
|^ ^+ vats
?: =(%base loc)
do-base
?: (gth num.new-weft num.old-weft)
kelvin-retreat
?: =(num.new-weft num.old-weft)
kelvin-same
kelvin-advance
::
?. =(%base loc)
:: TODO: ?> =(%zuse lal.new-weft) but more flexible for future renames
?: (gth num.new-weft num.old-weft)
~> %slog.0^leaf/"kiln: cannot install {here}, old kelvin {<new-weft>}"
~> %slog.0^leaf/"kiln: will retry at foreign kelvin {<old-weft>}"
=/ =diff [%block loc rak new-weft blockers=(sy %base ~)]
(emil sync-ud:pass (diff:give diff) ~)
?: (lth num.new-weft num.old-weft)
~> %slog.0^leaf/"kiln: future version {<new-weft>}, enqueueing"
=. next.rak (snoc next.rak [(dec aeon.rak) new-weft])
=/ =diff [%block loc rak new-weft blockers=(sy %base ~)]
(emil sync-ud:pass (diff:give diff) ~)
++ kelvin-retreat
^+ vats
~> %slog.0^leaf/"kiln: cannot install {here}, old kelvin {<new-weft>}"
~> %slog.0^leaf/"kiln: will retry at foreign kelvin {<old-weft>}"
=/ =diff [%block loc rak new-weft blockers=(sy %base ~)]
(emil sync-ud:pass (diff:give diff) ~)
::
++ kelvin-advance
^+ vats
~> %slog.0^leaf/"kiln: future version {<new-weft>}, enqueueing"
:: retry upgrade if not blocked anymore
=/ base=arak (~(got by ark) %base)
=. next.rak (snoc next.rak [(dec aeon.rail.rak) new-weft])
=. ark (~(put by ark) loc rak)
=/ =diff [%block loc rak new-weft blockers=(sy %base ~)]
=. vats (emil sync-ud:pass (diff:give diff) ~)
?. &(?=(^ next.base) =(~ (get-blockers weft.i.next.base)))
vats
~> %slog.0^leaf/"kiln: unblocked system update, updating"
=. kiln
(bump-one weft.i.next.base %base)
vats
::
++ kelvin-same
^+ vats
~> %slog.0^leaf/"kiln: merging into {here}"
=. next.rak +:(crank-next %& (dec aeon.rak))
=. next.rak +:(crank-next %& (dec aeon.rail.rak))
(emil ~[merge-main sync-ud]:pass)
::
=/ blockers
?: =(new-weft old-weft)
~
(get-blockers new-weft)
::
?. =(~ blockers)
~> %slog.0^leaf/"kiln: OTA blocked on {<blockers>}"
=. next.rak (snoc next.rak [(dec aeon.rak) new-weft])
=/ =diff [%block loc rak new-weft blockers]
(emil sync-ud:pass (diff:give diff) ~)
~> %slog.0^leaf/"kiln: applying OTA to {here}, kelvin: {<new-weft>}"
=. next.rak +:(crank-next %& (dec aeon.rak))
(emil ~[merge-main sync-ud]:pass)
++ do-base
^+ vats
=/ blockers
?: =(new-weft old-weft)
~
(get-blockers new-weft)
::
?. =(~ blockers)
~> %slog.0^leaf/"kiln: OTA blocked on {<blockers>}"
=. next.rak (snoc next.rak [(dec aeon.rail.rak) new-weft])
=/ =diff [%block loc rak new-weft blockers]
(emil sync-ud:pass (diff:give diff) ~)
~> %slog.0^leaf/"kiln: applying OTA to {here}, kelvin: {<new-weft>}"
=. next.rak +:(crank-next %& (dec aeon.rail.rak))
=. wef
?: =(old-weft new-weft) ~
`new-weft
(emil ~[merge-main sync-ud]:pass)
--
::
++ take-merge-main
|= syn=sign-arvo
@ -577,8 +708,7 @@
(update-running-apps (get-apps-diff our loc now rein.rak))
?. =(%base loc)
vats
=/ except=(set desk) (sy %base %kids ~)
=. kiln (bump-many zuse/zuse (all-desks-but except))
~> %slog.0^leaf/"kiln: bumping {<zuse>}" :: TODO print next
(emit merge-kids:pass)
::
++ take-merge-kids
@ -624,9 +754,9 @@
::
++ crank-next
|= new=(each aeon weft)
^+ [match=*(unit [=aeon =weft]) next.rak]
^+ [match=*(unit rung) next.rak]
=/ rog next.rak
|- ^+ [match=*(unit [=aeon =weft]) next.rak]
|- ^+ [match=*(unit rung) next.rak]
?~ rog [~ next.rak]
?: ?- -.new
%& =(p.new aeon.i.rog)
@ -683,12 +813,14 @@
%kiln-merge =;(f (f !<(_+<.f vase)) poke-merge)
%kiln-mount =;(f (f !<(_+<.f vase)) poke-mount)
%kiln-nuke =;(f (f !<(_+<.f vase)) poke-nuke)
%kiln-suspend =;(f (f !<(_+<.f vase)) poke-suspend)
%kiln-pause =;(f (f !<(_+<.f vase)) poke-pause)
%kiln-permission =;(f (f !<(_+<.f vase)) poke-permission)
%kiln-resume =;(f (f !<(_+<.f vase)) poke-resume)
%kiln-revive =;(f (f !<(_+<.f vase)) poke-revive)
%kiln-rein =;(f (f !<(_+<.f vase)) poke-rein)
%kiln-rm =;(f (f !<(_+<.f vase)) poke-rm)
%kiln-schedule =;(f (f !<(_+<.f vase)) poke-schedule)
%kiln-suspend =;(f (f !<(_+<.f vase)) poke-suspend)
%kiln-sync =;(f (f !<(_+<.f vase)) poke-sync)
%kiln-syncs =;(f (f !<(_+<.f vase)) poke-syncs)
%kiln-track =;(f (f !<(_+<.f vase)) poke-track)
@ -710,7 +842,10 @@
::
++ poke-bump
|= [except=(set desk) force=?]
=/ kel=weft zuse/+(zuse)
=/ =arak
(~(got by ark) %base)
=/ kel=weft
?~(next.arak zuse+zuse weft.i.next.arak)
abet:(bump:vats kel except force)
::
++ poke-cancel
@ -837,6 +972,10 @@
%+ turn (get-apps-have our term now)
|=([=dude ?] [%pass /nuke %arvo %g [%nuke dude]])
::
++ poke-pause
|= =desk
abet:abet:(pause:vats desk)
::
++ poke-permission
|= [syd=desk pax=path pub=?]
=< abet
@ -848,6 +987,10 @@
|= [=desk =rein]
abet:abet:(set-rein:vats +<)
::
++ poke-resume
|= =desk
abet:abet:(resume:vats desk)
::
++ poke-revive
|= =desk
abet:abet:(revive:vats desk)

View File

@ -0,0 +1,24 @@
|%
+$ bump [%kiln-bump except=(set desk) force=_|]
--
|_ b=bump
++ grad %noun
++ grab
|%
++ noun bump
++ json
^- $-(^json bump)
=, dejs:format
%+ pe %kiln-bump
%- ot
:~ except+(as so)
force+bo
==
--
++ grow
|%
++ noun b
--
--

View File

@ -0,0 +1,13 @@
|_ =desk
++ grad %noun
++ grow
|%
++ noun desk
++ json s+desk
--
++ grab
|%
++ noun ^desk
++ json so:dejs:format
--
--

View File

View File

@ -1,5 +1,6 @@
/- *hood
|_ vats=(list vat)
++ grad %noun
++ grow
|%
++ noun vats

View File

@ -580,7 +580,10 @@
=/ yok=(unit yoke) (~(get by yokes.state) dap)
?~ yok
~> %slog.[0 leaf+"gall: no agent to reload: {<dap>}"]
mo-core
cor
?: ?=(%| -.agent)
~> %slog.[0 leaf+"gall: dead agent reload: {<dap>}"]
cor
=/ bek=beak [our q.beak.u.yok p.sign-arvo]
=/ rag (mo-scry-agent-cage dap q.bek p.sign-arvo)
?: ?=(%| -.rag)

View File

@ -260,6 +260,15 @@
;< ~ bind:m (send-raw-card card)
(take-watch-ack wire)
::
++ watch-one
|= [=wire =dock =path]
=/ m (strand ,cage)
^- form:m
;< ~ bind:m (watch wire dock path)
;< =cage bind:m (take-fact wire)
;< ~ bind:m (take-kick wire)
(pure:m cage)
::
++ watch-our
|= [=wire =term =path]
=/ m (strand ,~)

View File

@ -15,15 +15,26 @@
==
:: $arak: foreign vat tracker
::
:: .next is a list of pending commits with future kelvins
:: .rail: upstream tracking state, if any
:: .next: list of pending commits with future kelvins
:: .rein: configuration for agents
::
+$ arak
$: =ship
=desk
=aeon
next=(list [=aeon =weft])
$: =rail
next=(list rung)
=rein
==
:: $rail: upstream tracking state
::
+$ rail
$: paused=?
=ship
=desk
=aeon
==
:: $rung: reference to upstream commit
::
+$ rung [=aeon =weft]
:: $rein: diff from desk manifest
::
:: .liv: suspended?
@ -59,16 +70,18 @@
leaf/"pending: {<(turn next.arak |=([@ lal=@tas num=@] [lal num]))>}"
^- tang
=/ meb (mergebase-hashes our desk now arak)
=/ poz ?:(paused.rail.arak "paused" "tracking")
=/ sat ?:(liv.rein.arak "running" "suspended")
:~ leaf/"/sys/kelvin: {<[lal num]:weft>}"
leaf/"base hash: {?.(=(1 (lent meb)) <meb> <(head meb)>)}"
leaf/"%cz hash: {<hash>}"
leaf/"source ship: {<ship.arak>}"
leaf/"source desk: {<desk.arak>}"
leaf/"source aeon: {<aeon.arak>}"
leaf/"status: {sat}"
leaf/"force on: {?:(=(~ add.rein.arak) "~" <add.rein.arak>)}"
leaf/"force off: {?:(=(~ sub.rein.arak) "~" <sub.rein.arak>)}"
:~ leaf/"/sys/kelvin: {<[lal num]:weft>}"
leaf/"base hash: {?.(=(1 (lent meb)) <meb> <(head meb)>)}"
leaf/"%cz hash: {<hash>}"
leaf/"updates: {sat}"
leaf/"source ship: {<ship.rail.arak>}"
leaf/"source desk: {<desk.rail.arak>}"
leaf/"source aeon: {<aeon.rail.arak>}"
leaf/"agent status: {sat}"
leaf/"force on: {?:(=(~ add.rein.arak) "~" <add.rein.arak>)}"
leaf/"force off: {?:(=(~ sub.rein.arak) "~" <sub.rein.arak>)}"
==
:: +read-kelvin-foreign: read /sys/kelvin from a foreign desk
::
@ -99,6 +112,26 @@
?~ =<(fil .^(arch cy/pax))
~
[~ .^(weft cx/pax)]
:: +read-bill-foreign: read /desk/bill from a foreign desk
::
++ read-bill-foreign
|= [=ship =desk =aeon]
^- bill
=/ her (scot %p ship)
=/ syd (scot %tas desk)
=/ yon (scot %ud aeon)
::
=/ dom .^(dome cv/~[her syd yon])
=/ tak (scot %uv (~(got by hit.dom) let.dom))
=/ yak .^(yaki cs/~[her syd yon %yaki tak])
=/ lob (scot %uv (~(got by q.yak) /desk/bill))
=/ bob .^(blob cs/~[her syd yon %blob lob])
::
;; bill
?- -.bob
%direct q.q.bob
%delta q.r.bob
==
:: +read-bill: read contents of /desk/bill manifest
::
++ read-bill
@ -146,10 +179,10 @@
::
++ mergebase-hashes
|= [our=@p =desk now=@da =arak]
=/ her (scot %p ship.arak)
=/ her (scot %p ship.rail.arak)
=/ ego (scot %p our)
=/ wen (scot %da now)
%+ turn .^((list tako) %cs ~[ego desk wen %base her desk.arak])
%+ turn .^((list tako) %cs ~[ego desk wen %base her desk.rail.arak])
|=(=tako .^(@uv %cs ~[ego desk wen %hash (scot %uv tako)]))
::
++ enjs
@ -191,11 +224,11 @@
kelvin+(numb num.w)
==
::
++ woof
|= w=[=aeon =^weft]
++ rung
|= r=^rung
%- pairs
:~ aeon+(numb aeon.w)
weft+(weft weft.w)
:~ aeon+(numb aeon.r)
weft+(weft weft.r)
==
::
++ rein
@ -208,10 +241,11 @@
++ arak
|= a=^arak
%- pairs
:~ ship+s+(scot %p ship.a)
desk+s+desk.a
aeon+(numb aeon.a)
next+a+(turn next.a woof)
:~ ship+s+(scot %p ship.rail.a)
desk+s+desk.rail.a
paused+b+paused.rail.a
aeon+(numb aeon.rail.a)
next+a+(turn next.a rung)
rein+(rein rein.a)
==
--

View File

@ -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)
--

View File

@ -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))

View File

@ -1,6 +1,5 @@
:~ :- %apes
:~ %btc-provider
%btc-wallet
:~ %btc-wallet
==
:- %fish ~
==

View File

@ -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]

View File

@ -0,0 +1 @@
../../base-dev/lib/agentio.hoon

View File

@ -0,0 +1 @@
../../base-dev/lib/azimuth.hoon

View File

@ -0,0 +1 @@
../../base-dev/lib/azimuthio.hoon

View File

@ -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))
::
--

View File

@ -0,0 +1 @@
../../../base-dev/lib/bip/b158.hoon

View File

@ -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)])]
--

View File

@ -0,0 +1 @@
../../../base-dev/lib/bip/b173.hoon

View File

@ -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)
--

View File

@ -0,0 +1 @@
../../../base-dev/lib/bip/b174.hoon

View File

@ -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)
--
--

1
pkg/bitcoin/lib/bip32.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/bip32.hoon

View File

@ -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]
--

1
pkg/bitcoin/lib/bip39.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/bip39.hoon

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
../../../base-dev/lib/bip39/english.hoon

1
pkg/bitcoin/lib/dbug.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/dbug.hoon

View File

@ -0,0 +1 @@
../../base-dev/lib/default-agent.hoon

1
pkg/bitcoin/lib/docket.hoon Symbolic link
View File

@ -0,0 +1 @@
../../garden-dev/lib/docket.hoon

1
pkg/bitcoin/lib/ethio.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/ethio.hoon

View File

@ -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)

View File

@ -0,0 +1 @@
../../../base-dev/lib/language-server/build.hoon

View File

@ -0,0 +1 @@
../../../base-dev/lib/language-server/complete.hoon

View File

@ -0,0 +1 @@
../../../base-dev/lib/language-server/easy-print.hoon

View File

@ -0,0 +1 @@
../../../base-dev/lib/language-server/json.hoon

View File

@ -0,0 +1 @@
../../../base-dev/lib/language-server/parser.hoon

View File

@ -0,0 +1 @@
../../../base-dev/lib/language-server/rune-snippet.hoon

1
pkg/bitcoin/lib/mip.hoon Symbolic link
View File

@ -0,0 +1 @@
../../garden-dev/lib/mip.hoon

1
pkg/bitcoin/lib/server.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/server.hoon

1
pkg/bitcoin/lib/shoe.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/shoe.hoon

View File

@ -0,0 +1 @@
../../base-dev/lib/skeleton.hoon

1
pkg/bitcoin/lib/sole.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/sole.hoon

1
pkg/bitcoin/lib/strand.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/strand.hoon

View File

@ -0,0 +1 @@
../../base-dev/lib/strandio.hoon

1
pkg/bitcoin/lib/treaty.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/treaty.hoon

1
pkg/bitcoin/lib/verb.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/verb.hoon

1
pkg/bitcoin/mar/belt.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/belt.hoon

1
pkg/bitcoin/mar/bill.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/bill.hoon

1
pkg/bitcoin/mar/blit.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/blit.hoon

1
pkg/bitcoin/mar/docket.hoon Symbolic link
View File

@ -0,0 +1 @@
../../garden-dev/mar/docket.hoon

1
pkg/bitcoin/mar/hoon.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/hoon.hoon

1
pkg/bitcoin/mar/htm.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/htm.hoon

1
pkg/bitcoin/mar/html.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/html.hoon

1
pkg/bitcoin/mar/httr.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/httr.hoon

1
pkg/bitcoin/mar/hymn.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/hymn.hoon

1
pkg/bitcoin/mar/js.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/js.hoon

1
pkg/bitcoin/mar/json.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/json.hoon

View File

@ -0,0 +1 @@
../../../../base-dev/mar/json/rpc/response.hoon

1
pkg/bitcoin/mar/kelvin.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/kelvin.hoon

View File

@ -0,0 +1 @@
../../../../base-dev/mar/language-server/rpc/notification.hoon

View File

@ -0,0 +1 @@
../../../../base-dev/mar/language-server/rpc/request.hoon

View File

@ -0,0 +1 @@
../../../../base-dev/mar/language-server/rpc/response.hoon

1
pkg/bitcoin/mar/mime.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/mime.hoon

1
pkg/bitcoin/mar/noun.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/noun.hoon

1
pkg/bitcoin/mar/path.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/path.hoon

1
pkg/bitcoin/mar/png.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/png.hoon

1
pkg/bitcoin/mar/purl.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/purl.hoon

View File

@ -0,0 +1 @@
../../../base-dev/mar/sole/action.hoon

View File

@ -0,0 +1 @@
../../../base-dev/mar/sole/effect.hoon

1
pkg/bitcoin/mar/svg.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/svg.hoon

1
pkg/bitcoin/mar/tang.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/tang.hoon

1
pkg/bitcoin/mar/tape.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/tape.hoon

View File

@ -0,0 +1 @@
../../base-dev/mar/txt-diff.hoon

1
pkg/bitcoin/mar/txt.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/txt.hoon

1
pkg/bitcoin/mar/udon.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/udon.hoon

1
pkg/bitcoin/mar/umd.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/umd.hoon

1
pkg/bitcoin/mar/urb.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/urb.hoon

1
pkg/bitcoin/mar/urbit.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/urbit.hoon

1
pkg/bitcoin/mar/woff2.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/woff2.hoon

1
pkg/bitcoin/mar/xml.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/xml.hoon

1
pkg/bitcoin/sur/bill.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/sur/bill.hoon

1
pkg/bitcoin/sur/docket.hoon Symbolic link
View File

@ -0,0 +1 @@
../../garden-dev/sur/docket.hoon

1
pkg/bitcoin/sur/hood.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/sur/hood.hoon

View File

@ -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]
==
--

View File

@ -0,0 +1 @@
../../garden-dev/sur/settings.hoon

1
pkg/bitcoin/sur/sole.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/sur/sole.hoon

1
pkg/bitcoin/sur/spider.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/sur/spider.hoon

1
pkg/bitcoin/sur/verb.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/sur/verb.hoon

View File

@ -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: {

View File

@ -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,

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More