import { Observable } from 'rxjs' import { ECPointOnCurveT, HDPathRadixT, PublicKeyT, SignatureT } from '@crypto' import { BuiltTransactionReadyToSign, Network } from '@primitives' import { ResultAsync } from 'neverthrow' // Semantic versioning, e.g. 1.0.5 export type SemVerT = Readonly<{ major: number minor: number patch: number equals: (other: SemVerT) => boolean // '{major}.{minor}.{patch}' toString: () => string }> export type AtPath = Readonly<{ // defaults to: `m/44'/1022'/0'/0/0` path?: HDPathRadixT }> export type GetPublicKeyInput = AtPath & Readonly<{ display?: boolean /// Only relevant if `display` is true, this skips showing BIP32 Path on display. verifyAddressOnly?: boolean }> export type SignTXOutput = Readonly<{ signature: SignatureT signatureV: number hashCalculatedByLedger: Buffer }> export type SignHashInput = GetPublicKeyInput & Readonly<{ hashToSign: Buffer }> export type KeyExchangeInput = AtPath & Readonly<{ publicKeyOfOtherParty: PublicKeyT display?: 'encrypt' | 'decrypt' }> export type HardwareSigningKeyT = Readonly<{ keyExchange: ( publicKeyOfOtherParty: PublicKeyT, display?: 'encrypt' | 'decrypt', ) => Observable publicKey: PublicKeyT // Like property `publicKey` but a function and omits BIP32 path on HW display getPublicKeyDisplayOnlyAddress: () => Observable signHash: (hashedMessage: Buffer) => Observable sign: ( tx: BuiltTransactionReadyToSign, nonXrdHRP?: string, ) => ResultAsync }> export type SignTransactionInput = Readonly<{ tx: BuiltTransactionReadyToSign path: HDPathRadixT nonXrdHRP?: string }> export type HardwareWalletT = Readonly<{ getVersion: () => Observable getPublicKey: (input: GetPublicKeyInput) => Observable signHash: (input: SignHashInput) => Observable signTransaction: ( input: SignTransactionInput, ) => ResultAsync keyExchange: (input: KeyExchangeInput) => Observable makeSigningKey: ( path: HDPathRadixT, verificationPrompt?: boolean, ) => Observable }>