Skip to content

Instantly share code, notes, and snippets.

@reazuliqbal
Created October 4, 2018 15:52
Show Gist options
  • Save reazuliqbal/3fb63a0bfd23e17144db10657349a831 to your computer and use it in GitHub Desktop.
Save reazuliqbal/3fb63a0bfd23e17144db10657349a831 to your computer and use it in GitHub Desktop.
const {
Client,
Signature,
cryptoUtils,
} = require('dsteem');
const client = new Client('https://api.steemit.com');
const args = process.argv.slice(2);
(async () => {
// Pulling transaction data
const trx = await client.database.getTransaction({ block_num: args[0], id: args[1] });
// New signature object from transaction signature
const sig = Signature.fromString(trx.signatures[0]);
// Recreting transaction message
const msg = {
expiration: trx.expiration,
extensions: trx.extensions,
operations: trx.operations,
ref_block_num: trx.ref_block_num,
ref_block_prefix: trx.ref_block_prefix,
};
const digest = cryptoUtils.transactionDigest(msg);
// Finding public key of the private that was used to sign
const key = (new Signature(sig.data, sig.recovery)).recover(digest);
const publicKey = key.toString();
// Finding owner of that public key
const [owner] = await client.database.call('get_key_references', [[publicKey]]);
console.log(`Public Key: ${publicKey}`);
console.log(`Owner: ${owner}`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment