Merge pull request #239 from status-im/bug/#237
Fix error after account recovery
Former-commit-id: c06b1249e8
This commit is contained in:
commit
9f99dba7bd
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue