How to use the ripple-keypairs.deriveKeypair function in ripple-keypairs

To help you get started, we’ve selected a few ripple-keypairs 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 interledgerjs / moneyd-uplink-xrp / index.js View on Github external
if (testnet && !res.secret) {
    console.log('acquiring testnet account...')
    const resp = await fetch('https://faucet.altnet.rippletest.net/accounts', { method: 'POST' })
    const json = await resp.json()

    res.address = json.account.address
    res.secret = json.account.secret
    console.log('got testnet address "' + res.address + '"')
    console.log('waiting for testnet API to fund address...')
    await new Promise(resolve => setTimeout(resolve, 10000))
  } else {
    res.address = (await inquirer.prompt({
      type: 'input',
      name: 'address',
      message: 'XRP address:',
      default: deriveAddress(deriveKeypair(res.secret).publicKey),
      validate: (address) => isValidAccountID(address)
    })).address
    // Ensure that the given account exists and has enough XRP to create a channel.
    await validateAddress(res.xrpServer, res.address).catch((err) => {
      console.error('Error configuring uplink: ' + err.message)
      process.exit(1)
    })
  }
  const btpName = res.name || ''
  const btpSecret = hmac(hmac(parentBtpHmacKey, res.parent + btpName), res.secret).toString('hex')
  const btpServer = 'btp+wss://' + btpName + ':' + btpSecret + '@' + res.parent
  return {
    relation: 'parent',
    plugin: require.resolve('ilp-plugin-xrp-asym-client'),
    assetCode: 'XRP',
    assetScale: 9,
github ninjadotorg / handshake-app / src / services / Wallets / Ripple.js View on Github external
createAddressPrivatekey() {
        try {
          const t0 = performance.now();
          const seed = bip39.mnemonicToSeed(this.mnemonic); // creates seed buffer

          console.log('mnemonic: ' + this.mnemonic);

          var entropy = new Buffer(seed, 'hex');
          console.log("entropy", entropy);
          var secret = keypairs.generateSeed({entropy: entropy});
          var keypair = keypairs.deriveKeypair(secret);
          var publicKey = keypair.publicKey;
          var address = keypairs.deriveAddress(publicKey);
          var privateKey = keypair.privateKey;

          this.address = address;
          this.privateKey = privateKey;
          this.publicKey = publicKey;
          this.secret = secret;

          const t1 = performance.now();
          console.log(`Call to createAddressPrivatekey for each Ripple (${address}) took ${t1 - t0} milliseconds.`);
        } catch (e) {
          console.error(e);
        }
    }
github ripple / ripple-lib / src / transaction / sign.ts View on Github external
function sign(
  this: RippleAPI,
  txJSON: string,
  secret?: any,
  options?: SignOptions,
  keypair?: KeyPair
): {signedTransaction: string; id: string} {
  if (typeof secret === 'string') {
    // we can't validate that the secret matches the account because
    // the secret could correspond to the regular key
    validate.sign({txJSON, secret})
    return signWithKeypair(
      this,
      txJSON,
      keypairs.deriveKeypair(secret),
      options
    )
  } else {
    if (!keypair && !secret) {
      // Clearer message than 'ValidationError: instance is not exactly one from [subschema 0],[subschema 1]'
      throw new utils.common.errors.ValidationError(
        'sign: Missing secret or keypair.'
      )
    }
    return signWithKeypair(this, txJSON, keypair ? keypair : secret, options)
  }
}
github filidorwiese / ripple-wallet / scripts / generate.js View on Github external
'use strict'
const chalk = require('chalk')
const RippleKeypairs = require('ripple-keypairs')
const config = require('./config.json')

console.log(chalk.green('-----------------------------------------------'))
console.log(chalk.green('Ripple Wallet'), chalk.yellow('Generate Wallet'))
console.log(chalk.green('-----------------------------------------------'), '\n')

const seed = RippleKeypairs.generateSeed()
const keypair = RippleKeypairs.deriveKeypair(seed)
const address = RippleKeypairs.deriveAddress(keypair.publicKey)

console.log('  Public address:', chalk.yellow(address))
console.log('  Wallet secret:', chalk.yellow(seed), '\n')

console.log(chalk.red('  Print this wallet and make sure to store it somewhere safe!'), '\n')
console.log(`  Note: You need to put at least ${config.baseReserve} ${config.currency} on this key for it to be an active account\n`)
github filidorwiese / ripple-wallet / scripts / pay.js View on Github external
validate: (value) => {
      try {
        RippleKeypairs.deriveKeypair(value)
        return true
      } catch (e) {
        return 'Invalid secret'
      }
    }
  }
github ripple / ripple-lib / src / offline / generate-address.ts View on Github external
function generateAddressAPI(options: GenerateAddressOptions): GeneratedAddress {
  validate.generateAddress({options})
  try {
    const secret = keypairs.generateSeed(options)
    const keypair = keypairs.deriveKeypair(secret)
    const classicAddress = keypairs.deriveAddress(keypair.publicKey)
    const returnValue: any = {
      xAddress: classicAddressToXAddress(
        classicAddress,
        false,
        options && options.test
      ),
      secret
    }
    if (options.includeClassicAddress) {
      returnValue.classicAddress = classicAddress
      returnValue.address = classicAddress
    }
    return returnValue
  } catch (error) {
    throw new errors.UnexpectedError(error.message)
github ripple / ripple-lib / src / core / transaction.js View on Github external
Transaction.prototype.multiSign = function(account, secret) {
  const signingData = this.multiSigningData(account);
  const keypair = deriveKeypair(secret);

  const signer = {
    Account: account,
    TxnSignature: sign(new Buffer(signingData, 'hex'), keypair.privateKey),
    SigningPubKey: keypair.publicKey
  };

  return signer;
};
github ripple / ripple-lib / src / core / transaction.js View on Github external
Transaction.prototype.getSigningPubKey = function(secret) {
  return deriveKeypair(secret || this._secret).publicKey;
};
github filidorwiese / ripple-wallet / scripts / pay.js View on Github external
inquirer.prompt(questions).then((answers) => {
  const keypair = RippleKeypairs.deriveKeypair(answers.sourceSecret)
  const sourceAddress = RippleKeypairs.deriveAddress(keypair.publicKey)

  const instructions = {
    maxLedgerVersionOffset: 5,
    maxFee
  }

  const payment = {
    source: {
      address: sourceAddress,
      maxAmount: {
        value: answers.amount.toString(),
        currency
      }
    },
    destination: {
github ripple / ripple-lib / src / common / utils.ts View on Github external
function isValidSecret(secret: string): boolean {
  try {
    deriveKeypair(secret)
    return true
  } catch (err) {
    return false
  }
}