From 6fe80f732048f06e11e8b599986b91d9f19e56be Mon Sep 17 00:00:00 2001
From: Mahdi Yari <m.yary16@gmail.com>
Date: Wed, 7 Oct 2020 18:52:08 +0330
Subject: [PATCH] Update memo.js

---
 src/auth/memo.js | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/auth/memo.js b/src/auth/memo.js
index cf46a90..225d17b 100644
--- a/src/auth/memo.js
+++ b/src/auth/memo.js
@@ -83,6 +83,23 @@ export function encode(private_key, public_key, memo, testNonce) {
     return '#' + base58.encode(new Buffer(memo, 'binary'))
 }
 
+/** Get public keys of both sender and receiver */
+export function getPubKeys(memo) {
+  assert(memo, 'memo is required')
+  assert.equal(typeof memo, 'string', 'memo')
+  if(!/^#/.test(memo)) return []
+  memo = memo.substring(1)
+
+  checkEncryption()
+
+  memo = base58.decode(memo)
+  memo = encMemo.fromBuffer(new Buffer(memo, 'binary'))
+
+  const {from, to} = memo
+
+  return [from.toString(), to.toString()]
+}
+
 let encodeTest = undefined
 
 /**
-- 
GitLab