Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

xrp-codec.d.ts 2.2KB

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