Add validator public key to accounts and lock transaction

parent 64c445e5
Pipeline #28983486 passed with stages
in 1 minute and 53 seconds
......@@ -5,7 +5,7 @@
(s/def ::account (s/keys :req [::address]
:opt [::private-key ::label ::valid-until ::locked-until ::balance]))
:opt [::private-key ::label ::valid-until ::locked-until ::validator-address ::balance]))
(defn nacl-keypair->keypair [nacl-keypair]
(let [nacl-privkey (aget nacl-keypair "secretKey")
......@@ -36,5 +36,7 @@
(uint/vec->uint (subvec account-bin 0 4)))
::locked-until (when (>= (count account-bin) 16)
(uint/vec->uint (subvec account-bin 12 16)))
::validator-address (when (>= (count account-bin) 16)
(subvec account-bin 16 48))
::balance (when (not (empty? account-bin))
(uint/vec->uint (subvec account-bin 4 12)))})
......@@ -53,7 +53,13 @@
(defn account-row [account]
(let [editing (r/atom false)]
(fn [{:keys [::a/label ::a/address ::a/private-key ::a/balance ::a/valid-until ::a/locked-until] :as account}]
(fn [{:keys [::a/label
::a/validator-address] :as account}]
{:on-double-click #(reset! editing true)
......@@ -77,6 +83,8 @@
[:td balance]
[:td valid-until]
[:td locked-until]
[:code (uint/vec->base58 validator-address)]]
[:input {:type :button
:value "Remove"
......@@ -97,6 +105,7 @@
[:th "Balance"]
[:th "Valid until"]
[:th "Locked until"]
[:th "Validator address"]
[:th "Operations"]
......@@ -215,6 +224,7 @@
(defn lock-tx-form []
(let [locked-until (r/atom nil)
account (r/atom nil)
validator (r/atom nil)
tx (r/atom nil)]
(fn []
......@@ -224,9 +234,10 @@
:value @locked-until
:on-change #(reset! locked-until (-> % .-target .-value js/parseInt))}]]
(account-select "Account" account)
(account-select "Validator" validator)
[:input {:type :button
:on-click #(reset! tx (tx/lock-tx @locked-until @account))
:on-click #(reset! tx (tx/lock-tx @locked-until @account @validator))
:value "Generate"}]]
[generated-tx tx]])))
......@@ -35,11 +35,12 @@
(::a/address to))]
(sign to-sign from)))
(defn lock-tx [locked-until account]
(defn lock-tx [locked-until account validator]
(let [to-sign (concat
(uint/uint->vec locked-until 4)
(::a/address account))]
(::a/address account)
(::a/address validator))]
(sign to-sign account)))
(defn genesis-tx [from locked-until validator]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment