Former-commit-id: fbbee2e268
This commit is contained in:
Roman Volosovskyi 2016-09-19 14:24:24 +03:00
parent 8b77fa8870
commit a560493eb7
2 changed files with 18 additions and 7 deletions

View File

@ -4,17 +4,21 @@
[status-im.utils.types :refer [json->clj]]
[status-im.utils.identicon :refer [identicon]]
[taoensso.timbre :as log]
[clojure.string :as str]))
[clojure.string :as str]
[status-im.protocol.core :as protocol]))
(defn account-recovered [result password]
(let [_ (log/debug result)
data (json->clj result)
public-key (:pubkey data)
address (:address data)
account {:public-key public-key
:address address
:name address
:photo-path (identicon public-key)}]
{:keys [public private]} (protocol/new-keypair!)
account {:public-key public-key
:address address
:name address
:photo-path (identicon public-key)
:updates-public-key public
:updates-private-key private}]
(log/debug "account-recovered")
(when (not (str/blank? public-key))
(do

View File

@ -3,18 +3,25 @@
[status-im.protocol.ack :as ack]
[status-im.protocol.web3.utils :as u]
[status-im.protocol.encryption :as e]
[taoensso.timbre :refer-macros [debug]]))
[taoensso.timbre :refer-macros [debug] :as log]))
(defn- parse-payload [payload]
(debug :parse-payload)
(r/read-string (u/to-utf8 payload)))
(defn- decrypt [key content]
(try
(r/read-string (e/decrypt key content))
(catch :default err
(log/warn :decrypt-error err)
nil)))
(defn- parse-content [key {:keys [content]} was-encrypted?]
(debug :parse-content
"Key exitsts:" (not (nil? key))
"Content exists:" (not (nil? content)))
(if (and (not was-encrypted?) key content)
(r/read-string (e/decrypt key content))
(decrypt key content)
content))
(defn message-listener