How to use the stellar-base.Keypair.fromSecret function in stellar-base

To help you get started, we’ve selected a few stellar-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nguyenkha / forest.network / lib / tx / index.js View on Github external
function sign(tx, secret) {
  const key = Keypair.fromSecret(secret);
  tx.account = key.publicKey();
  tx.signature = key.sign(getUnsignedHash(tx));
}
github orbitlens / stellar-notifier / util / signing.js View on Github external
const {Keypair} = require('stellar-base'),
    config = require('../models/config')

const signingKeypair = Keypair.fromSecret(config.signatureSecret)

function processSigningData(dataToSign) {
    if (!dataToSign) throw new TypeError('Invalid data')
    if (typeof dataToSign === 'object') dataToSign = JSON.stringify(dataToSign)
    if (typeof dataToSign !== 'string') throw new TypeError('Invalid data. Expected string or plain object.')
    return dataToSign
}

module.exports = {
    /**
     * Get signing public key.
     * @returns {string}
     */
    getPublicKey: function () {
        return signingKeypair.publicKey()
    },