xrp-codec.d.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Codec class
  3. */
  4. /// <reference types="node" />
  5. import * as baseCodec from 'base-x';
  6. declare class Codec {
  7. sha256: (bytes: Uint8Array) => Buffer;
  8. alphabet: string;
  9. codec: baseCodec.BaseConverter;
  10. base: number;
  11. constructor(options: {
  12. sha256: (bytes: Uint8Array) => Buffer;
  13. alphabet: string;
  14. });
  15. /**
  16. * Encoder.
  17. *
  18. * @param bytes - Buffer of data to encode.
  19. * @param opts - Options object including the version bytes and the expected length of the data to encode.
  20. */
  21. encode(bytes: Buffer, opts: {
  22. versions: number[];
  23. expectedLength: number;
  24. }): string;
  25. encodeVersioned(bytes: Buffer, versions: number[], expectedLength: number): string;
  26. encodeChecked(buffer: Buffer): string;
  27. encodeRaw(bytes: Buffer): string;
  28. /**
  29. * Decoder.
  30. *
  31. * @param base58string - Base58Check-encoded string to decode.
  32. * @param opts - Options object including the version byte(s) and the expected length of the data after decoding.
  33. */
  34. decode(base58string: string, opts: {
  35. versions: Array<number | number[]>;
  36. expectedLength?: number;
  37. versionTypes?: ['ed25519', 'secp256k1'];
  38. }): {
  39. version: number[];
  40. bytes: Buffer;
  41. type: string | null;
  42. };
  43. decodeChecked(base58string: string): Buffer;
  44. decodeRaw(base58string: string): Buffer;
  45. verifyCheckSum(bytes: Buffer): boolean;
  46. }
  47. export declare const codec: Codec;
  48. export declare function encodeSeed(entropy: Buffer, type: 'ed25519' | 'secp256k1'): string;
  49. export declare function decodeSeed(seed: string, opts?: {
  50. versionTypes: ['ed25519', 'secp256k1'];
  51. versions: Array<number | number[]>;
  52. expectedLength: number;
  53. }): {
  54. version: number[];
  55. bytes: Buffer;
  56. type: string | null;
  57. };
  58. export declare function encodeAccountID(bytes: Buffer): string;
  59. export declare const encodeAddress: typeof encodeAccountID;
  60. export declare function decodeAccountID(accountId: string): Buffer;
  61. export declare const decodeAddress: typeof decodeAccountID;
  62. export declare function decodeNodePublic(base58string: string): Buffer;
  63. export declare function encodeNodePublic(bytes: Buffer): string;
  64. export declare function encodeAccountPublic(bytes: Buffer): string;
  65. export declare function decodeAccountPublic(base58string: string): Buffer;
  66. export declare function isValidClassicAddress(address: string): boolean;
  67. export {};