How to use the ripple-address-codec.isValidAddress function in ripple-address-codec

To help you get started, we’ve selected a few ripple-address-codec 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 ripple / rippled-historical-database / api / routes / capitalization.js View on Github external
adjusted: (/true/i).test(req.query.adjusted) ? true : false,
    descending: (/true/i).test(req.query.descending) ? true : false,
    limit: req.query.limit || 200,
    marker: req.query.marker,
    format: (req.query.format || 'json').toLowerCase()
  };

  var currency = req.params.currency;

  if (currency) {
    currency = currency.split(/[\+|\.]/);  // any of +, |, or .
    options.currency = currency[0].toUpperCase();
    options.issuer = currency[1];
  }

  if (!validator.isValidAddress(options.issuer)) {
    errorResponse({error: 'invalid issuer address', code: 400});
    return;

  } else if (!options.start) {
    errorResponse({error: 'invalid start date format', code: 400});
    return;

  } else if (!options.end) {
    errorResponse({error: 'invalid end date format', code: 400});
    return;

  } else if (options.interval &&
             intervals.indexOf(options.interval) === -1) {
    errorResponse({
      error: 'invalid interval - use: '+intervals.join(', '),
      code: 400
github ripple / ripple-lib / src / core / meta.js View on Github external
}

  const accounts = [ ];

  // This code should match the behavior of the C++ method:
  // TransactionMetaSet::getAffectedAccounts
  for (let i = 0; i < this.nodes.length; i++) {
    const node = this.nodes[i];
    const fields = (node.nodeType === 'CreatedNode')
    ? node.fieldsNew
    : node.fieldsFinal;

    for (const fieldName in fields) {
      const field = fields[fieldName];

      if (this.isAccountField(fieldName) && isValidAddress(field)) {
        accounts.push(field);
      } else if (
          Meta.AMOUNT_FIELDS_AFFECTING_ISSUER.indexOf(fieldName) !== -1) {
        const amount = Amount.from_json(field);
        const issuer = amount.issuer();
        if (isValidAddress(issuer) && issuer !== ACCOUNT_ZERO) {
          accounts.push(issuer);
        }
      }
    }
  }

  this._affectedAccounts = utils.arrayUnique(accounts);

  return this._affectedAccounts;
};
github N3TC4T / xrp-telegram-bot / handlers / scenes / withdraw.js View on Github external
Composer.privateChat(ctx => {
                const message = ctx.update.message.text;
                if (!address_codec.isValidAddress(message)) {
                    return ctx.replyWithHTML('⚠️ Please enter a correct XRP address.', CANCEL_MENU);
                }

                if (message === process.env.WALLET_ADDRESS) {
                    return ctx.replyWithHTML(
                        '⚠️ This address cannot be used, please enter another address.',
                        CANCEL_MENU,
                    );
                }

                // set withdraw address
                ctx.scene.session.state.address = message;

                ctx.wizard.next();
                return ctx.wizard.steps[ctx.wizard.cursor](ctx);
            }),
github ripple / rippled-historical-database / api / routes / accountBalances.js View on Github external
ledger_hash: req.query.ledger_hash,
    closeTime: req.query.close_time || req.query.date,
    account: req.params.address,
    format: (req.query.format || 'json').toLowerCase(),
    limit: req.query.limit || 200,
    ip: req.headers['fastly-client-ip'] || req.headers['x-forwarded-for'] || 'not_provided'
  };

  if (!options.account) {
    errorResponse({
      error: 'account is required.',
      code: 400
    });
    return;

  } else if (!rippleAddress.isValidAddress(options.account)) {
    errorResponse({
      error: 'invalid ripple address',
      code: 400
    });
    return;
  }

  if (options.ledger_index) {
    options.ledger_index = Number(options.ledger_index);
  }

  // validate and fomat close time
  if (options.closeTime) {
    options.closeTime = smoment(options.closeTime);
    if (options.closeTime) {
      options.closeTime = options.closeTime.format();
github ripple / ripple-lib / src / core / transaction.js View on Github external
Transaction.prototype.addMultiSigner = function(signer) {
  assert(isValidAddress(signer.Account), 'Signer must have a valid Account');

  if (_.isUndefined(this.tx_json.Signers)) {
    this.tx_json.Signers = [];
  }

  this.tx_json.Signers.push({Signer: signer});

  this.tx_json.Signers.sort((a, b) => {
    return (new Buffer(decodeAddress(a.Signer.Account))).compare(
      new Buffer(decodeAddress(b.Signer.Account)));
  });

  return this;
};
github ripple / rippled-historical-database / api / routes / gateways.js View on Github external
function getGateway(identifier) {
  var gateway;
  var name;
  var address;
  var normalized;

  if (validator.isValidAddress(identifier)) {
    address = identifier;
  } else {
    name = normalize(identifier);
  }

  for (var i = 0; i < gatewayList.length; i++) {
    gateway = gatewayList[i];

    for (var j = 0; j < gateway.accounts.length; j++) {
      if (address && gateway.accounts[j].address === address) {
        return gateway;

      } else if (name) {
        normalized = normalize(gateway.name);

        if (name === normalized) {
github ripple / ripple-lib / src / core / transaction.js View on Github external
const options = _.merge({no_native: false}, options_);
  const parsedAmount = Amount.from_json(amount);

  if (parsedAmount.is_negative()) {
    throw new Error(name + ' value must be non-negative');
  }

  const isNative = parsedAmount.currency().is_native();

  if (isNative && options.no_native) {
    throw new Error(name + ' must be a non-native amount');
  }
  if (!(isNative || parsedAmount.currency().is_valid())) {
    throw new Error(name + ' must have a valid currency');
  }
  if (!(isNative || isValidAddress(parsedAmount.issuer()))) {
    throw new Error(name + ' must have a valid issuer');
  }

  this.tx_json[name] = parsedAmount.to_json();

  return this;
};
github ripple / ripple-lib / src / core / transaction.js View on Github external
Transaction.prototype._setAccount = function(name, value) {
  if (!isValidAddress(value)) {
    throw new Error(name + ' must be a valid account');
  }
  this.tx_json[name] = value;
  return this;
};
github ripple / ripple-lib / src / core / meta.js View on Github external
for (let i = 0; i < this.nodes.length; i++) {
    const node = this.nodes[i];
    const fields = (node.nodeType === 'CreatedNode')
    ? node.fieldsNew
    : node.fieldsFinal;

    for (const fieldName in fields) {
      const field = fields[fieldName];

      if (this.isAccountField(fieldName) && isValidAddress(field)) {
        accounts.push(field);
      } else if (
          Meta.AMOUNT_FIELDS_AFFECTING_ISSUER.indexOf(fieldName) !== -1) {
        const amount = Amount.from_json(field);
        const issuer = amount.issuer();
        if (isValidAddress(issuer) && issuer !== ACCOUNT_ZERO) {
          accounts.push(issuer);
        }
      }
    }
  }

  this._affectedAccounts = utils.arrayUnique(accounts);

  return this._affectedAccounts;
};
github alphapoint / coinslot / src / validators / RippleValidator.js View on Github external
validate(address, currency) {
    return rippleAddressApi.isValidAddress(address);
  }
}