How to use the ripple-keypairs.deriveAddress 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 WietseWind / xrp-trustline-set-commandline / offline-with-mnemonic.js View on Github external
/**
 * SET YOUR ACCOUNT SEQUENCE
 * You can check your current sequence at
 * any XRP ledger explorer, like:
 *   https://bithomp.com/explorer/
 * Bithomp shows:
 *   "Transactions: 1234"
 * In this case your AccountSequence is 1235 (+1).
 */
let AccountSequence = 123

const seed = bip39.mnemonicToSeed(mnemonic) // Note: change the line above to: const seed = bip39.mnemonicToSeed(mnemonic, 'MyPassphrase') ... if you have a BIP39 passphrase.
const m = bip32.fromSeedBuffer(seed)
const SeedOrKeypair = m.derivePath("m/44'/144'/0'/0/0").keyPair.getKeyPairs()
const WalletAddress = ripple.deriveAddress(SeedOrKeypair.publicKey)

const Transaction = {
  TransactionType: 'TrustSet',
  Flags: 131072, // tfSetNoRipple
  Account: WalletAddress,
  LimitAmount: {
    currency : "USD",
    issuer : "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
    value : "1000000000"
  },
  Fee: 15,
  Sequence: AccountSequence
}

new RippledWsClientSign(Transaction, SeedOrKeypair).then((Transaction) => {
  console.log(`\n\nTransaction signed, and only valid for the specified Sequence
github BitGo / BitGoJS / modules / core / src / v2 / coins / xrp.ts View on Github external
return co(function *() {
      const { userKeychain, backupKeychain, bitgoKeychain } = keychains;

      const userKey = HDNode.fromBase58(userKeychain.pub).getKey();
      const userAddress = rippleKeypairs.deriveAddress(userKey.getPublicKeyBuffer().toString('hex'));

      const backupKey = HDNode.fromBase58(backupKeychain.pub).getKey();
      const backupAddress = rippleKeypairs.deriveAddress(backupKey.getPublicKeyBuffer().toString('hex'));

      const bitgoKey = HDNode.fromBase58(bitgoKeychain.pub).getKey();
      const bitgoAddress = rippleKeypairs.deriveAddress(bitgoKey.getPublicKeyBuffer().toString('hex'));

      // initially, we need to generate a random root address which has to be distinct from all three keychains
      let keyPair = ECPair.makeRandom();
      if (walletParams.rootPrivateKey) {
        const rootPrivateKey = walletParams.rootPrivateKey;
        if (typeof rootPrivateKey !== 'string' || rootPrivateKey.length !== 64) {
          throw new Error('rootPrivateKey needs to be a hexadecimal private key string');
        }
        keyPair = ECPair.fromPrivateKeyBuffer(Buffer.from(walletParams.rootPrivateKey, 'hex'));
      }
      const privateKey: Buffer = keyPair.getPrivateKeyBuffer();
      const publicKey: Buffer = keyPair.getPublicKeyBuffer();
      const rootAddress = rippleKeypairs.deriveAddress(publicKey.toString('hex'));
github BitGo / BitGoJS / modules / core / src / v2 / coins / xrp.ts View on Github external
return co(function *() {
      const { userKeychain, backupKeychain, bitgoKeychain } = keychains;

      const userKey = HDNode.fromBase58(userKeychain.pub).getKey();
      const userAddress = rippleKeypairs.deriveAddress(userKey.getPublicKeyBuffer().toString('hex'));

      const backupKey = HDNode.fromBase58(backupKeychain.pub).getKey();
      const backupAddress = rippleKeypairs.deriveAddress(backupKey.getPublicKeyBuffer().toString('hex'));

      const bitgoKey = HDNode.fromBase58(bitgoKeychain.pub).getKey();
      const bitgoAddress = rippleKeypairs.deriveAddress(bitgoKey.getPublicKeyBuffer().toString('hex'));

      // initially, we need to generate a random root address which has to be distinct from all three keychains
      let keyPair = ECPair.makeRandom();
      if (walletParams.rootPrivateKey) {
        const rootPrivateKey = walletParams.rootPrivateKey;
        if (typeof rootPrivateKey !== 'string' || rootPrivateKey.length !== 64) {
          throw new Error('rootPrivateKey needs to be a hexadecimal private key string');
        }
        keyPair = ECPair.fromPrivateKeyBuffer(Buffer.from(walletParams.rootPrivateKey, 'hex'));
      }
github BitGo / BitGoJS / modules / core / src / v2 / coins / xrp.ts View on Github external
const bitgoKey = HDNode.fromBase58(bitgoKeychain.pub).getKey();
      const bitgoAddress = rippleKeypairs.deriveAddress(bitgoKey.getPublicKeyBuffer().toString('hex'));

      // initially, we need to generate a random root address which has to be distinct from all three keychains
      let keyPair = ECPair.makeRandom();
      if (walletParams.rootPrivateKey) {
        const rootPrivateKey = walletParams.rootPrivateKey;
        if (typeof rootPrivateKey !== 'string' || rootPrivateKey.length !== 64) {
          throw new Error('rootPrivateKey needs to be a hexadecimal private key string');
        }
        keyPair = ECPair.fromPrivateKeyBuffer(Buffer.from(walletParams.rootPrivateKey, 'hex'));
      }
      const privateKey: Buffer = keyPair.getPrivateKeyBuffer();
      const publicKey: Buffer = keyPair.getPublicKeyBuffer();
      const rootAddress = rippleKeypairs.deriveAddress(publicKey.toString('hex'));

      const self = this;
      const rippleLib = ripple();

      const feeInfo = yield self.getFeeInfo();
      const openLedgerFee = new BigNumber(feeInfo.xrpOpenLedgerFee);
      const medianFee = new BigNumber(feeInfo.xrpMedianFee);
      const fee = BigNumber.max(openLedgerFee, medianFee).times(1.5).toFixed(0);

      // configure multisigners
      const multisigAssignmentTx = {
        TransactionType: 'SignerListSet',
        Account: rootAddress,
        SignerQuorum: 2,
        SignerEntries: [
          {
github interledgerjs / moneyd / bin / cleanup.js View on Github external
const inquirer = require('inquirer')
const table = require('good-table')
const chalk = require('chalk')
const { deriveAddress, deriveKeypair } = require('ripple-keypairs')
const { RippleAPI } = require('ripple-lib')
const XRP_ADDRESS = process.env.XRP_ADDRESS
const XRP_SECRET = process.env.XRP_SECRET
const server = process.env.XRP_SERVER
const infoMode = process.env.INFO_MODE

if (!XRP_SECRET) {
  console.error('xrp secret must be specified')
  process.exit(1)
}

const address = XRP_ADDRESS || deriveAddress(deriveKeypair(XRP_SECRET).publicKey)

async function run () {
  const api = new RippleAPI({ server })

  console.log('connecting api...')
  await api.connect()

  console.log('getting account...')
  const res = await api.getAccountInfo(address)
  console.log(chalk.green('balance: '), res.xrpBalance + ' XRP')
  console.log(chalk.green('account: '), address)

  const channels = await api.connection.request({
    command: 'account_channels',
    account: address
  })
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 ripple / ripple-lib / src / offline / derive.ts View on Github external
function deriveXAddress(options: {
  publicKey: string
  tag: number | false
  test: boolean
}): string {
  const classicAddress = deriveAddress(options.publicKey)
  return classicAddressToXAddress(classicAddress, options.tag, options.test)
}
github bitpay / bitcore / packages / crypto-wallet-core / src / derivation / xrp / index.ts View on Github external
derivePrivateKey(network, xPriv, addressIndex, isChange) {
    const xpriv = new BitcoreLib.HDPrivateKey(xPriv, network);
    const changeNum = isChange ? 1 : 0;
    const path = `m/${changeNum}/${addressIndex}`;
    const derivedXPriv = xpriv.derive(path);
    const privKey = derivedXPriv.toObject().privateKey.toUpperCase();
    const pubKey = derivedXPriv.hdPublicKey.toObject().publicKey.toUpperCase();
    const address = rippleKeypairs.deriveAddress(pubKey);
    return { address, privKey, pubKey };
  }
}
github sakurity / securelogin / js / index.js View on Github external
generate: function(s){
      seed = rippleKeypairs.generateSeed({entropy: s})
      keypair = rippleKeypairs.deriveKeypair(seed)
      return  rippleKeypairs.deriveAddress(keypair.publicKey)
    }
  },
github ripple / ripple-lib / src / core / account.js View on Github external
function hexToUInt160(publicKey) {
    return deriveAddress(publicKey);
  }