Skip to content
Snippets Groups Projects
Commit 93efc5c2 authored by Mahdi Yari's avatar Mahdi Yari
Browse files

Merge branch 'memo-helper' into 'master'

Memo helper function - get public keys

See merge request !11
parents 7fdbd10e 800021dc
No related branches found
No related tags found
1 merge request!11Memo helper function - get public keys
{ {
"name": "@hiveio/hive-js", "name": "@hiveio/hive-js",
"version": "0.8.4", "version": "0.8.5",
"description": "Hive.js the JavaScript API for Hive blockchain", "description": "Hive.js the JavaScript API for Hive blockchain",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
......
...@@ -83,6 +83,23 @@ export function encode(private_key, public_key, memo, testNonce) { ...@@ -83,6 +83,23 @@ export function encode(private_key, public_key, memo, testNonce) {
return '#' + base58.encode(new Buffer(memo, 'binary')) 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 let encodeTest = undefined
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment