zuse installer

This commit is contained in:
timlucmiptev 2020-11-26 11:38:30 +02:00 committed by ixv
parent 70d5d70689
commit 3a98672127
8 changed files with 186 additions and 85 deletions

18
PATCH.md Normal file
View File

@ -0,0 +1,18 @@
zuze patch:
```hoon
++ decompress-point
|= dat=@
^- pont
:: ~& "custom decompress point"
=+ x=(end 3 w dat)
?> =(3 (mod ^p 4))
=+ y=(exp.p (div +(^p) 4) :(sum.p (exp.p 3 x) (pro.p a x) b))
=+ s=(rsh 3 32 dat)
~| [`@ux`s `@ux`dat]
?> |(=(2 s) =(3 s))
:: check parity
::
=? y !=((sub s 2) (mod y 2))
(sub ^p y)
[x y]
```

View File

@ -100,18 +100,38 @@ Above tests w 2 outputs, total fees with 2 inputs of 27.500. Gives:
2. Inputs 0 and 3
## Make a full TXBU
Provider is `~zod`, `~dopzod` is a client.
Provider is `~zod`, `~dopzod` is a client. Use the xpub from PRIVATE.md to have a balance
### setup
On `~zod`:
```
|start %btc-provider
|start %btc-wallet-store
|start %btc-wallet-hook
:btc-provider|command [%set-credentials api-url='http://localhost:50002']
:btc-provider|command [%whitelist-clients `(set ship)`(sy ~[~dopzod])]
=xpubzod 'zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs'
:btc-wallet-hook|action [%set-provider ~zod]
:btc-wallet-store|action [%add-wallet xpubzod ~ [~ 20] [~ 6]]
```
on `~dopzod`:
```
=xpubp PRIVATE.md
|start %btc-wallet-store
|start %btc-wallet-hook
:btc-wallet-hook|action [%set-provider ~zod]
:btc-wallet-store|action [%add-wallet xpubp ~ [~ 20] [~ 6]]
```
### request address
on `~dopzod`:
```
:btc-wallet-hook|action [%req-pay-address payee=~zod value=2.000 [~ 10]]
```
## scrys
```
.^((list @t) %gx /=btc-wallet-store=/scanned/noun)

View File

@ -24,6 +24,7 @@
==
:: provider: maybe ship if provider is set
:: moon-limit: how many addresses a ship and its moons can request in piym
:: feybs: fee/byte in sats for a given ship payee
:: piym/poym-watch: listen to btc-wallet-store for address updates; update payment info
::
+$ state-0
@ -32,6 +33,7 @@
=btc-state
def-wallet=(unit xpub)
moon-limit=@ud
feybs=(map ship sats)
=pend-addr
=piym
poym=(unit txbu:bws)
@ -90,6 +92,7 @@
^- (quip card _this)
?+ -.sign (on-agent:def wire sign)
%kick
~& >>> "kicked from provider {<src.bowl>}"
?~ provider `this
?: ?& ?=(%set-provider -.wire)
=(host.u.provider src.bowl)
@ -138,28 +141,41 @@
::
%req-pay-address
:: TODO: add whitelisting here instead of comet block
:: can't request payment address if poym already building a tx
:: overwrites any payment being built currently
:: can't pay yourself; comets can't pay (could spam requests)
:: forwards poke to payee if payee isn't us
:: wire is /payer/value/timestamp
:: wire is /payer/value/timestamp
::
~| "Can't pay ourselves; can't pay if poym full; no comets"
~| "Can't pay ourselves; no comets"
?< =(src.bowl payee.act)
?< ?&(=(src.bowl our.bowl) ?=(^ poym))
?< ?=(%pawn (clan:title src.bowl))
?< ?=(%pawn (clan:title payee.act))
=+ feyb=?~(feyb.act fee.btc-state u.feyb.act)
=> .(poym ~, feybs (~(put by feybs) payee.act feyb))
:_ state
?. =(payee.act our.bowl)
~[(poke-wallet-hook payee.act act)]
~[(poke-wallet-hook payee.act [%gen-pay-address value.act])]
::
%gen-pay-address
~| "Can't pay ourselves; no comets"
?< =(src.bowl our.bowl)
?< ?=(%pawn (clan:title src.bowl))
?~ def-wallet ~|("btc-wallet-hook: no def-wallet set" !!)
~[(poke-wallet-store [%generate-address u.def-wallet %0 `[src.bowl value.act]])]
:_ state
:~ %- poke-wallet-store
[%generate-address u.def-wallet %0 `[src.bowl value.act]]
==
::
%ret-pay-address
?: =(src.bowl our.bowl) ~|("Can't pay ourselves" !!)
?~ def-wallet ~|("btc-wallet-hook: no def-wallet set" !!)
=+ feyb=(~(gut by feybs) src.bowl fee.btc-state)
?> =(payer.act our.bowl)
:_ state
:~ %- poke-wallet-store
[%generate-txbu u.def-wallet `src.bowl fee.btc-state ~[[address.act value.act]]]
[%generate-txbu u.def-wallet `src.bowl feyb ~[[address.act value.act]]]
==
::
%clear-poym
`state(poym ~)
::
%force-retry
[retry-pend-addr state]
@ -201,7 +217,7 @@
==
::
%raw-tx
?~ poym ~&(>> "btc-wallet-hook: %raw-tx: poym is empty" `state)
?~ poym `state
=. txis.u.poym (update-poym-txis txis.u.poym +.body.p.upd)
:_ state
?:(poym-ready ~[(send-sign-tx u.poym)] ~)
@ -217,7 +233,6 @@
?~ provider ~
?: provider-connected
~[(get-address-info ri host.u.provider a.req)]
~& > "provider not connected"
~
==
::
@ -230,8 +245,8 @@
::
?~ meta.upd ~&(> address.upd `state)
=/ [payer=ship value=sats] u.meta.upd
:- ~[(poke-wallet-hook payer [%ret-pay-address address.upd payer value])]
(update-piym address.upd u.meta.upd)
:_ (update-piym address.upd u.meta.upd)
~[(poke-wallet-hook payer [%ret-pay-address address.upd payer value])]
::
%generate-txbu
:: txbus can potentially use the same UTXO inputs, so if another payment

View File

@ -113,7 +113,7 @@
(update-address +.act)
::
%generate-address
=/ uw=(unit walt) (~(get by walts) xpub.act)
=+ uw=(~(get by walts) xpub.act)
?~ uw
~|("btc-wallet-store: non-existent xpub" !!)
=/ [a=address:btc w=walt]
@ -122,11 +122,11 @@
~[(send-update [%generate-address a meta.act])]
::
%generate-txbu
=/ uw=(unit walt) (~(get by walts) xpub.act)
?~ uw ~&(>>> "btc-wallet-store: non-existent xpub" `state)
=+ w=(~(get by walts) xpub.act)
?~ w ~&(>>> "btc-wallet-store: non-existent xpub" `state)
=/ t=(unit txbu)
%~ select-utxos sut
[u.uw eny.bowl payee.act feyb.act txos.act]
[u.w eny.bowl payee.act feyb.act txos.act]
?~ t ~&(>>> "btc-wallet-store: insufficient balance" `state)
:_ state
~[(send-update [%generate-txbu xpub.act u.t])]

11
install-zuse.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
usage() { printf "Usage: $0 URBIT_PIER_DIRECTORY \n" 1>&2; exit 1; }
if [ $# -eq 0 ]; then
usage
exit 2
fi
PIER=$1
cp sys/zuse.hoon $PIER/
echo "zuse copied"

View File

@ -13,8 +13,8 @@
|= =^txbu
^- json
%- pairs
:~ [%inputs ~]
['associatedKeysets' s+'hi']
:~ :: [%inputs [%a (turn txis.txbu txi)]]
['associatedKeysets' [%a (turn txis.txbu |=(=txi (key key.txi)))]]
['changePath' s+'hi']
['outputScriptHex' s+'hi']
['lockTime' s+'hi']
@ -24,7 +24,26 @@
==
:: TODO inputs, keysets, changeppath, outputscripthex, locktime, sigHashType, segwit, initialTimestamp
:: , additionals ("bech32")
:: TODO: use 'pairs' at the top level
++ txi
|= =^txi ^- json
?> ?=(^ ur.txi)
:- %a
:~ s+(en:base16:mimes:html u.ur.txi)
n+pos.utxo.txi
==
++ key
|= =^key ^- json
:- %s
%^ cat 3 'm/'
%^ cat 3
?- bipt.key
%bip44 '44'
%bip49 '49'
%bip84 '84'
==
%^ cat 3 '/0\'/0\'/'
%^ cat 3 ?:(=(%0 chyg.key) '0/' '1/')
(crip ((d-co:co 0) idx.key))
--
::
++ defaults
@ -143,11 +162,11 @@
::
++ select-utxos
|^ ^- (unit =txbu)
=/ uis=(unit (list input))
=/ is=(unit (list input))
%- single-random-draw
%- zing
(turn ~(val by wach.w) to-inputs)
?~(uis ~ `(inputs-to-txbu u.uis))
?~(is ~ `(inputs-to-txbu u.is))
::
++ to-inputs
|= =addi ^- (list input)

View File

@ -8,7 +8,7 @@
:: piym: incoming payments. Stores all ship moons under their planet.
:: piym-watch/poym-watch:
:: let us link an address back to its incoming/outgoing payment
:: checked when address updates come from btc-wallet-store
:: checked when address updates come from btc-wallet-store
::
+$ btc-state [blockcount=@ud fee=sats t=@da]
+$ pend-addr (map req-id:bp request:bws)
@ -18,12 +18,16 @@
+$ piym (jar ship payment)
+$ piym-watch (map address ship)
+$ poym-watch (map address ship)
:: req-pay-address: request a payment address from another ship
:: gen-pay-address: generate a payment address from our ship to another
::
+$ action
$% [%set-provider provider=ship]
[%set-default-wallet ~]
[%req-pay-address payee=ship value=sats]
[%req-pay-address payee=ship value=sats feyb=(unit sats)]
[%gen-pay-address value=sats]
[%ret-pay-address =address payer=ship value=sats]
[%clear-poym ~]
[%force-retry ~]
==
+$ request

View File

@ -367,7 +367,7 @@
++ pairs
%+ cook
~(gas by *(map @t @t))
%+ more (ifix [. .]:(star ace) mic)
%+ most (ifix [. .]:(star ace) mic)
;~(plug token ;~(pose ;~(pfix tis value) (easy '')))
::
++ value
@ -378,16 +378,16 @@
::NOTE this is ptok:de-purl:html, but can't access that here
%- plus
;~ pose
aln zap hax bus cen pad say tar lus
hep dot ket cab tec bar sig
aln zap hax buc cen pam soq tar lus
hep dot ket cab tic bar sig
==
::
++ quoted-string :: 7230 quoted string
%+ cook crip
%+ ifix [. .]:;~(less (jest '\\"') yel)
%+ ifix [. .]:;~(less (jest '\\"') doq)
%- star
;~ pose
;~(pfix bat ;~(pose (just '\09') ace prn))
;~(pfix bas ;~(pose (just '\09') ace prn))
;~(pose (just '\09') ;~(less (mask "\22\5c\7f") (shim 0x20 0xff)))
==
--
@ -1120,6 +1120,7 @@
{$boot lit/? p/*} :: weird %dill boot
{$crop p/@ud} :: trim kernel state
$>(%crud vane-task) :: error with trace
[%flee session=~] :: unwatch session
{$flog p/flog} :: wrapped error
{$flow p/@tas q/(list gill:gall)} :: terminal config
{$hail ~} :: terminal refresh
@ -1134,6 +1135,7 @@
{$talk p/tank} ::
{$text p/tape} ::
{$veer p/@ta q/path r/@t} :: install vane
[%view session=~] :: watch session blits
$>(%trim vane-task) :: trim state
$>(%vega vane-task) :: report upgrade
{$verb ~} :: verbose mode
@ -1157,6 +1159,7 @@
$% {$bel ~} :: make a noise
{$clr ~} :: clear the screen
{$hop p/@ud} :: set cursor position
[%klr p=stub] :: set styled line
{$lin p/(list @c)} :: set current line
{$mor ~} :: newline
{$sag p/path q/*} :: save to jamfile
@ -4261,7 +4264,7 @@
++ decompress-point
|= dat=@
^- pont
:: ~& "custom decompress point"
:: ~& "custom decompress point"
=+ x=(end 3 w dat)
?> =(3 (mod ^p 4))
=+ y=(exp.p (div +(^p) 4) :(sum.p (exp.p 3 x) (pro.p a x) b))
@ -5365,28 +5368,30 @@
:: ::::
++ format ^?
|%
:: :: ++to-wain:format
++ to-wain :: atom to line list
~% %lore ..is ~
|= lub/@
=| tez/(list @t)
|- ^+ tez
=+ ^= wor
=+ [meg=0 i=0]
|- ^- {meg/@ i/@ end/@f}
=+ gam=(cut 3 [i 1] lub)
?: =(0 gam)
[meg i %.y]
?: =(10 gam)
[meg i %.n]
$(meg (cat 3 meg gam), i +(i))
?: end.wor
(flop ^+(tez [meg.wor tez]))
?: =(0 lub) (flop tez)
$(lub (rsh 3 +(i.wor) lub), tez [meg.wor tez])
:: 0 ending a line (invalid @t) is not preserved :: ++to-wain:format
++ to-wain :: cord to line list
~% %leer ..is ~
|= txt=cord
^- wain
=/ len=@ (met 3 txt)
=/ cut =+(cut -(a 3, c 1, d txt))
=/ sub sub
=| [i=@ out=wain]
|- ^+ out
=+ |- ^- j=@
?: ?| =(i len)
=(10 (cut(b i)))
==
i
$(i +(i))
=. out :_ out
(cut(b i, c (sub j i)))
?: =(j len)
(flop out)
$(i +(j))
:: :: ++of-wain:format
++ of-wain :: line list to atom
|= tez/(list @t)
++ of-wain :: line list to cord
|= tez=wain ^- cord
(rap 3 (join '\0a' tez))
:: :: ++of-wall:format
++ of-wall :: line list to tape
@ -5639,7 +5644,7 @@
[(rash a fel) b]
:: :: ++pa:dejs:format
++ pa :: string as path
(su ;~(pfix net (more net urs:ab)))
(su ;~(pfix fas (more fas urs:ab)))
:: :: ++pe:dejs:format
++ pe :: prefix
|* {pre/* wit/fist}
@ -6201,7 +6206,7 @@
:: :: ++abox:de-json:html
++ abox :: array
%+ stag %a
(ifix [lac (wish rac)] (more (wish com) apex))
(ifix [sel (wish ser)] (more (wish com) apex))
:: :: ++apex:de-json:html
++ apex :: any value
%+ knee *json |. ~+
@ -6233,7 +6238,7 @@
=* wow `(map @t @)`(malt lip)
(sear ~(get by wow) low)
=* tuf ;~(pfix (just 'u') (cook tuft qix:ab))
;~(pose yel net say bas loo tuf)
;~(pose doq fas soq bas loo tuf)
==
:: :: ++expo:de-json:html
++ expo :: exponent
@ -6247,7 +6252,7 @@
;~(plug dot digs)
:: :: ++jcha:de-json:html
++ jcha :: string character
;~(pose ;~(less yel bas prn) esca)
;~(pose ;~(less doq bas prn) esca)
:: :: ++mayb:de-json:html
++ mayb :: optional
|*(bus/rule ;~(pose bus (easy ~)))
@ -6264,7 +6269,7 @@
==
:: :: ++obje:de-json:html
++ obje :: object list
%+ ifix [(wish leb) (wish reb)]
%+ ifix [(wish kel) (wish ker)]
(more (wish com) pear)
:: :: ++obox:de-json:html
++ obox :: object
@ -6278,7 +6283,7 @@
(cook |=(a/@ [a ~]) bus)
:: :: ++stri:de-json:html
++ stri :: string
(cook crip (ifix [yel yel] (star jcha)))
(cook crip (ifix [doq doq] (star jcha)))
:: :: ++tops:de-json:html
++ tops :: strict value
;~(pose abox obox)
@ -6387,14 +6392,14 @@
;~(pfix (plus whit) name)
;~ pose
%+ ifix
:_ yel
;~(plug (ifix [. .]:(star whit) tis) yel)
(star ;~(less yel escp))
:_ doq
;~(plug (ifix [. .]:(star whit) tis) doq)
(star ;~(less doq escp))
::
%+ ifix
:_ say
;~(plug (ifix [. .]:(star whit) tis) say)
(star ;~(less say escp))
:_ soq
;~(plug (ifix [. .]:(star whit) tis) soq)
(star ;~(less soq escp))
::
(easy ~)
==
@ -6410,7 +6415,7 @@
:: :: ++chrd:de-xml:html
++ chrd :: character data
%+ cook |=(a/tape ^-(mars ;/(a)))
(plus ;~(less yel ;~(pose (just `@`10) escp)))
(plus ;~(less doq ;~(pose (just `@`10) escp)))
:: :: ++comt:de-xml:html
++ comt :: comments
=- (ifix [(jest '<!--') (jest '-->')] (star -))
@ -6427,10 +6432,10 @@
;~(less (jest '?>') prn)
:: :: ++escp:de-xml:html
++ escp ::
;~(pose ;~(less led ban pad prn) enty)
;~(pose ;~(less gal gar pam prn) enty)
:: :: ++enty:de-xml:html
++ enty :: entity
%+ ifix pad^mic
%+ ifix pam^mic
;~ pose
=+ def=^+(ent (my:nl [%gt '>'] [%lt '<'] [%amp '&'] [%quot '"'] ~))
%+ sear ~(get by (~(uni by def) ent))
@ -6446,7 +6451,7 @@
;~(plug ;~(plug name attr) (cold ~ (star whit)))
:: :: ++head:de-xml:html
++ head :: opening tag
(ifix [gal ban] ;~(plug name attr))
(ifix [gal gar] ;~(plug name attr))
:: :: ++many:de-xml:html
++ many :: contents
;~(pfix (star comt) (star ;~(sfix ;~(pose apex chrd cdat) (star comt))))
@ -6461,7 +6466,7 @@
;~(pose ;~(plug ;~(sfix chx col) chx) chx)
:: :: ++tail:de-xml:html
++ tail :: closing tag
(ifix [(jest '</') ban] name)
(ifix [(jest '</') gar] name)
:: :: ++whit:de-xml:html
++ whit :: whitespace
(mask ~[' ' `@`0x9 `@`0xa])
@ -6566,8 +6571,13 @@
?^ t.rax
[p.pok [ire q.pok]]:[pok=$(rax t.rax) ire=i.rax]
=/ raf/(like term)
=> |=(a/@ ((sand %tas) (crip (flop (trip a)))))
(;~(sfix (sear . sym) dot) [1^1 (flop (trip i.rax))])
%- ;~ sfix
%+ sear
|=(a/@ ((sand %ta) (crip (flop (trip a)))))
(cook |=(a/tape (rap 3 ^-((list @) a))) (star aln))
dot
==
[1^1 (flop (trip i.rax))]
?~ q.raf
[~ [i.rax ~]]
=+ `{ext/term {@ @} fyl/tape}`u.q.raf
@ -6576,7 +6586,7 @@
:: :: ++apat:de-purl:html
++ apat :: 2396 abs_path
%+ cook deft
;~(pfix net (more net smeg))
;~(pfix fas (more fas smeg))
:: :: ++aurf:de-purl:html
++ aurf :: 2396 with fragment
%+ cook |~(a/purf a)
@ -6597,13 +6607,13 @@
[q.a [[p.a r.a] b]]
::
;~ plug
;~(plug htts (punt ;~(sfix urt:ab vat)) thor)
;~(plug htts (punt ;~(sfix urt:ab pat)) thor)
;~(plug ;~(pose apat (easy *pork)) yque)
==
:: :: ++htts:de-purl:html
++ htts :: scheme
%+ sear ~(get by (malt `(list (pair term ?))`[http+| https+& ~]))
;~(sfix scem ;~(plug col net net))
;~(sfix scem ;~(plug col fas fas))
:: :: ++cock:de-purl:html
++ cock :: cookie
%+ most ;~(plug mic ace)
@ -6623,10 +6633,10 @@
(cook crip (star pquo))
:: :: ++pcar:de-purl:html
++ pcar :: 2396 path char
;~(pose pure pesc psub col vat)
;~(pose pure pesc psub col pat)
:: :: ++pcok:de-purl:html
++ pcok :: cookie char
;~(less bas mic com yel prn)
;~(less bas mic com doq prn)
:: :: ++pesc:de-purl:html
++ pesc :: 2396 escaped
;~(pfix cen mes)
@ -6635,24 +6645,24 @@
(cold ' ' (just '+'))
:: :: ++pque:de-purl:html
++ pque :: 3986 query char
;~(pose pcar net wut)
;~(pose pcar fas wut)
:: :: ++pquo:de-purl:html
++ pquo :: normal query char
;~(pose pure pesc pold net wut col com)
;~(pose pure pesc pold fas wut col com)
:: :: ++pure:de-purl:html
++ pure :: 2396 unreserved
;~(pose aln hep cab dot zap sig tar say lit rit)
;~(pose aln hep cab dot zap sig tar soq pal par)
:: :: ++psub:de-purl:html
++ psub :: 3986 sub-delims
;~ pose
zap bus pad say lit rit
zap buc pam soq pal par
tar lus com mic tis
==
:: :: ++ptok:de-purl:html
++ ptok :: 2616 token
;~ pose
aln zap hax bus cen pad say tar lus
hep dot ket cab tec bar sig
aln zap hax buc cen pam soq tar lus
hep dot ket cab tic bar sig
==
:: :: ++scem:de-purl:html
++ scem :: 2396 scheme
@ -6666,7 +6676,7 @@
(cook crip (plus pcok))
:: :: ++tosk:de-purl:html
++ tosk :: 6265 quoted value
;~(pose tock (ifix [yel yel] tock))
;~(pose tock (ifix [doq doq] tock))
:: :: ++toke:de-purl:html
++ toke :: 2616 token
(cook crip (plus ptok))
@ -6708,7 +6718,7 @@
:: proper query
::
%+ more
;~(pose pad mic)
;~(pose pam mic)
;~(plug fque ;~(pose ;~(pfix tis fquu) (easy '')))
::
:: funky query
@ -8212,7 +8222,7 @@
::
++ function
|* [tag=@tas fun=@t rul=rule]
;~(plug (cold tag (jest fun)) (ifix [lit rit] rul))
;~(plug (cold tag (jest fun)) (ifix [pal par] rul))
::
++ shipname
;~(pfix sig fed:ag)
@ -9177,6 +9187,10 @@
|- ^- seed:able:jael
=/ cub=acru:ames (pit:nu:crub:crypto 512 eny)
=/ who=ship `@`fig:ex:cub
:: disallow 64-bit or smaller addresses
::
?. ?=(%pawn (clan:title who))
$(eny +(eny))
?: (~(has in stars) (^sein:title who))
[who 1 sec:ex:cub ~]
$(eny +(eny))