|
|
@@ -158,7 +158,8 @@
|
|
|
+$ cause
|
|
|
$% [%keygen entropy=byts salt=byts]
|
|
|
[%derive-child key-type=?(%pub %prv) i=@ label=(unit @t)]
|
|
|
- [%import-keys keys=(list (pair trek coil))]
|
|
|
+ [%import-keys keys=(list (pair trek meta))]
|
|
|
+ [%export-keys ~]
|
|
|
[%import-master-pubkey key=@t cc=@t] :: base58-encoded pubkey + chain code
|
|
|
[%make-tx dat=draft]
|
|
|
[%list-notes-by-pubkey pubkey=@t] :: base58-encoded pubkey
|
|
|
@@ -361,14 +362,14 @@
|
|
|
|* meg=tape
|
|
|
|* *
|
|
|
?. bug +<
|
|
|
- ~> %slog.[1 (crip "WARN: !! {meg} !!")]
|
|
|
+ ~> %slog.[1 (cat 3 'wallet: warning: ' (crip meg))]
|
|
|
+<
|
|
|
::
|
|
|
++ debug
|
|
|
|* meg=tape
|
|
|
|* *
|
|
|
?. bug +<
|
|
|
- ~> %slog.[2 (crip "wallet: {meg}")]
|
|
|
+ ~> %slog.[2 (cat 3 'wallet: debug: ' (crip meg))]
|
|
|
+<
|
|
|
::
|
|
|
++ moat (keep state)
|
|
|
@@ -1024,6 +1025,7 @@
|
|
|
%update-balance (do-update-balance cause)
|
|
|
%update-block (do-update-block cause)
|
|
|
%import-keys (do-import-keys cause)
|
|
|
+ %export-keys (do-export-keys cause)
|
|
|
%import-master-pubkey (do-import-master-pubkey cause)
|
|
|
%gen-master-privkey (do-gen-master-privkey cause)
|
|
|
%gen-master-pubkey (do-gen-master-pubkey cause)
|
|
|
@@ -1068,19 +1070,23 @@
|
|
|
(~(del by peek-requests.state) pid)
|
|
|
?~ softed
|
|
|
%- (debug "handle-npc: %balance: could not soft result")
|
|
|
- `state
|
|
|
+ [[%exit 0]~ state]
|
|
|
=/ balance-result=(unit (unit _balance.state)) u.softed
|
|
|
?~ balance-result
|
|
|
%- (warn "%update-balance did not return a result: bad path")
|
|
|
- `state
|
|
|
+ [[%exit 0]~ state]
|
|
|
?~ u.balance-result
|
|
|
%- (warn "%update-balance did not return a result: nothing")
|
|
|
- `state
|
|
|
+ [[%exit 0]~ state]
|
|
|
?~ u.u.balance-result
|
|
|
%- (warn "%update-balance did not return a result: empty result")
|
|
|
- `state
|
|
|
+ [[%exit 0]~ state]
|
|
|
=. balance.state u.u.balance-result
|
|
|
%- (debug "balance state updated!")
|
|
|
+ :: count the number of notes in the balance
|
|
|
+ =/ note-count=@ud
|
|
|
+ (lent ~(tap z-by:zo balance.state))
|
|
|
+ %- (debug "note count: {<note-count>}")
|
|
|
=. name-to-hash.state
|
|
|
%- ~(run z-by:zo balance.state)
|
|
|
|= not=nnote:transact
|
|
|
@@ -1116,19 +1122,19 @@
|
|
|
(~(del by peek-requests.state) pid)
|
|
|
?~ softed
|
|
|
%- (warn "handle-npc: %block: could not soft result")
|
|
|
- `state
|
|
|
+ [[%exit 0]~ state]
|
|
|
=/ block-result u.softed
|
|
|
%- (debug "handle-npc: %block: {<block-result>}")
|
|
|
%- (debug "handle-npc: %block: {<peek-requests.state>}")
|
|
|
?~ block-result
|
|
|
%- (warn "handle-npc: %block: bad path")
|
|
|
- `state
|
|
|
+ [[%exit 0]~ state]
|
|
|
?~ u.block-result
|
|
|
%- (warn "handle-npc: %block: nothing")
|
|
|
- `state
|
|
|
+ [[%exit 0]~ state]
|
|
|
?~ u.u.block-result
|
|
|
%- (warn "handle-npc: %block: empty result")
|
|
|
- `state
|
|
|
+ [[%exit 0]~ state]
|
|
|
%- (debug "handle-npc: %block: found block")
|
|
|
%- (debug "handle-npc: {<(to-b58:block-id:transact (need u.u.block-result))>}")
|
|
|
%- (debug "handle-npc: hash: {<(to-b58:hash:transact (need u.u.block-result))>}")
|
|
|
@@ -1252,11 +1258,58 @@
|
|
|
?> ?=(%import-keys -.cause)
|
|
|
=/ new-keys=_keys.state
|
|
|
%+ roll keys.cause
|
|
|
- |= [[=trek =coil] acc=_keys.state]
|
|
|
- (~(put of acc) trek coil)
|
|
|
- `state(keys new-keys)
|
|
|
+ |= [[=trek =meta] acc=_keys.state]
|
|
|
+ (~(put of acc) trek meta)
|
|
|
+ =/ master-key=coil
|
|
|
+ %- head
|
|
|
+ %+ murn ~(tap of new-keys)
|
|
|
+ |= [t=trek m=meta]
|
|
|
+ ^- (unit coil)
|
|
|
+ ?: ?&
|
|
|
+ ?=(%coil -.m)
|
|
|
+ =((slag 2 t) /pub/m)
|
|
|
+ ==
|
|
|
+ `m
|
|
|
+ ~
|
|
|
+ =/ key-list=(list tape)
|
|
|
+ %+ murn ~(tap of new-keys)
|
|
|
+ |= [t=trek m=meta]
|
|
|
+ ^- (unit tape)
|
|
|
+ ?: ?=(%coil -.m)
|
|
|
+ `(en:base58:wrap p.key.m)
|
|
|
+ ~
|
|
|
+ =. master.state `master-key
|
|
|
+ :_ state(keys new-keys)
|
|
|
+ :~ :- %markdown
|
|
|
+ %- crip
|
|
|
+ """
|
|
|
+ ## imported keys
|
|
|
+
|
|
|
+ {<key-list>}
|
|
|
+ """
|
|
|
+ [%exit 0]
|
|
|
+ ==
|
|
|
+ ::
|
|
|
+ ++ do-export-keys
|
|
|
+ |= =cause
|
|
|
+ ?> ?=(%export-keys -.cause)
|
|
|
+ =/ keys-list=(list [trek meta])
|
|
|
+ ~(tap of keys.state)
|
|
|
+ =/ dat-jam (jam keys-list)
|
|
|
+ =/ path=@t 'keys.export'
|
|
|
+ =/ =effect [%file %write path dat-jam]
|
|
|
+ :_ state
|
|
|
+ :~ effect
|
|
|
+ :- %markdown
|
|
|
+ %- crip
|
|
|
+ """
|
|
|
+ ## exported keys
|
|
|
+
|
|
|
+ - path: {<path>}
|
|
|
+ """
|
|
|
+ [%exit 0]
|
|
|
+ ==
|
|
|
::
|
|
|
- ::>) TODO: update state.master as well
|
|
|
++ do-import-master-pubkey
|
|
|
|= =cause
|
|
|
?> ?=(%import-master-pubkey -.cause)
|
|
|
@@ -1268,7 +1321,16 @@
|
|
|
=/ label `(crip "master-public-{<(end [3 4] public-key:cor)>}")
|
|
|
%- (debug "Imported master public key: {<public-key:cor>}")
|
|
|
=. keys.state (key:put:v master-pubkey-coil ~ label)
|
|
|
- `state
|
|
|
+ :_ state
|
|
|
+ :~ :- %markdown
|
|
|
+ %- crip
|
|
|
+ """
|
|
|
+ ## master public key
|
|
|
+
|
|
|
+ {<public-key:cor>}
|
|
|
+ """
|
|
|
+ [%exit 0]
|
|
|
+ ==
|
|
|
::
|
|
|
++ do-gen-master-privkey
|
|
|
|= =cause
|
|
|
@@ -1301,18 +1363,27 @@
|
|
|
=. keys.state (key:put:v master-privkey-coil ~ private-label)
|
|
|
=. keys.state (key:put:v master-pubkey-coil ~ public-label)
|
|
|
%- (debug "master.state: {<master.state>}")
|
|
|
- `state
|
|
|
+ :_ state
|
|
|
+ :~ :- %markdown
|
|
|
+ %- crip
|
|
|
+ """
|
|
|
+ ## master public key
|
|
|
+
|
|
|
+ {<public-key:cor>}
|
|
|
+ """
|
|
|
+ [%exit 0]
|
|
|
+ ==
|
|
|
::
|
|
|
++ do-make-tx
|
|
|
|= =cause
|
|
|
?> ?=(%make-tx -.cause)
|
|
|
- %- (debug "make-tx: {<dat.cause>}")
|
|
|
+ %- (debug "make-tx: creating raw-tx")
|
|
|
:: note that new:raw-tx calls +validate already
|
|
|
=/ raw=raw-tx:transact (new:raw-tx:transact p.dat.cause)
|
|
|
=/ tx-id id.raw
|
|
|
=/ nock-cause=$>(%fact cause:dumb)
|
|
|
[%fact %0 %heard-tx raw]
|
|
|
- %- (debug "make-tx: new-tx {<tx-id>}")
|
|
|
+ %- (debug "make-tx: made raw-tx, poking over npc")
|
|
|
:_ state
|
|
|
:~
|
|
|
[%npc 0 %poke nock-cause]
|
|
|
@@ -1329,9 +1400,16 @@
|
|
|
=/ pubkey=schnorr-pubkey:transact pub:(from-public:s10 [p.key cc]:coil)
|
|
|
%- trip
|
|
|
(to-b58:schnorr-pubkey:transact pubkey)
|
|
|
- %- (debug "base58-keys: {<base58-keys>}")
|
|
|
- :- [%exit 0]~
|
|
|
- state
|
|
|
+ :_ state
|
|
|
+ :~ :- %markdown
|
|
|
+ %- crip
|
|
|
+ """
|
|
|
+ ## pubkeys
|
|
|
+
|
|
|
+ {<base58-keys>}
|
|
|
+ """
|
|
|
+ [%exit 0]
|
|
|
+ ==
|
|
|
::
|
|
|
++ do-show-seedphrase
|
|
|
|= =cause
|
|
|
@@ -1469,7 +1547,7 @@
|
|
|
==
|
|
|
==
|
|
|
:_ state
|
|
|
- ~[(make-markdown-effect nodes)]
|
|
|
+ ~[(make-markdown-effect nodes) [%exit 0]]
|
|
|
::
|
|
|
++ do-list-notes
|
|
|
|= =cause
|
|
|
@@ -1645,10 +1723,8 @@
|
|
|
=/ master-public-coil [%coil [%pub public-key] chain-code]:cor
|
|
|
=/ master-private-coil [%coil [%prv private-key] chain-code]:cor
|
|
|
=. master.state (some master-public-coil)
|
|
|
- %- (debug "keygen: new public key {<public-key:cor>}")
|
|
|
- %- (debug "keygen: public key: base58 {<(en:base58:wrap public-key:cor)>}")
|
|
|
- %- (debug "keygen: new private key {<private-key:cor>}")
|
|
|
- %- (debug "keygen: private key: base58 {<(en:base58:wrap private-key:cor)>}")
|
|
|
+ %- (debug "keygen: public key: {<(en:base58:wrap public-key:cor)>}")
|
|
|
+ %- (debug "keygen: private key: {<(en:base58:wrap private-key:cor)>}")
|
|
|
=/ pub-label `(crip "master-public-{<(end [3 4] public-key:cor)>}")
|
|
|
=/ prv-label `(crip "master-public-{<(end [3 4] public-key:cor)>}")
|
|
|
=. keys.state (key:put:v master-public-coil ~ pub-label)
|
|
|
@@ -1665,6 +1741,12 @@
|
|
|
|
|
|
### New Private Key
|
|
|
{<(en:base58:wrap private-key:cor)>}
|
|
|
+
|
|
|
+ ### Chain Code
|
|
|
+ {<(en:base58:wrap chain-code:cor)>}
|
|
|
+
|
|
|
+ ### Seed Phrase
|
|
|
+ {<seed-phrase>}
|
|
|
"""
|
|
|
[%exit 0]
|
|
|
==
|