How to use the ripple-address-codec.xAddressToClassicAddress 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 / ripple-lib / src / common / index.ts View on Github external
export function ensureClassicAddress(account: string): string {
  if (isValidXAddress(account)) {
    const {classicAddress, tag} = xAddressToClassicAddress(account)

    // Except for special cases, X-addresses used for requests
    // must not have an embedded tag. In other words,
    // `tag` should be `false`.
    if (tag !== false) {
      throw new Error(
        'This command does not support the use of a tag. Use an address without a tag.'
      )
    }

    // For rippled requests that use an account, always use a classic address.
    return classicAddress
  } else {
    return account
  }
}
github ripple / ripple-lib / src / transaction / utils.ts View on Github external
function getClassicAccountAndTag(
  Account: string,
  expectedTag?: number
): ClassicAccountAndTag {
  if (isValidXAddress(Account)) {
    const classic = xAddressToClassicAddress(Account)
    if (expectedTag !== undefined && classic.tag !== expectedTag) {
      throw new ValidationError(
        'address includes a tag that does not match the tag specified in the transaction'
      )
    }
    return {
      classicAccount: classic.classicAddress,
      tag: classic.tag
    }
  } else {
    return {
      classicAccount: Account,
      tag: expectedTag
    }
  }
}