Files
xahau.js/src/utils/derive.ts
Nathan Nichols 633032ddd8 Lint utils directory (#1563)
* Lint the utils directory

* Modify computeLedgerHash to take new Ledger format.
2021-10-04 14:10:12 -04:00

22 lines
643 B
TypeScript

import { classicAddressToXAddress } from 'ripple-address-codec'
import { deriveKeypair, deriveAddress } from 'ripple-keypairs'
interface DeriveOptions {
publicKey: string
tag: number | false
test: boolean
}
/**
* Derive an X-Address from a public key and a destination tag.
*
* @param options - Public key and destination tag to encode as an X-Address.
* @returns X-Address.
*/
function deriveXAddress(options: DeriveOptions): string {
const classicAddress = deriveAddress(options.publicKey)
return classicAddressToXAddress(classicAddress, options.tag, options.test)
}
export { deriveKeypair, deriveAddress, deriveXAddress }