diff --git a/src/descriptors.ts b/src/descriptors.ts index 01f0485..c362c18 100644 --- a/src/descriptors.ts +++ b/src/descriptors.ts @@ -562,7 +562,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) { signersPubKeys }: { /** - * The descriptor string in ASCII format. It may include a "*" to denote an arbitrary index. + * The descriptor string in ASCII format. It may include a "*" to denote an arbitrary index (aka ranged descriptors). */ descriptor: string; @@ -572,7 +572,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) { index?: number; /** - * A flag indicating whether the descriptor is required to include a checksum. + * An optional flag indicating whether the descriptor is required to include a checksum. * @defaultValue false */ checksumRequired?: boolean; @@ -607,6 +607,8 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) { * the public keys involved in the descriptor will sign the transaction. * In the latter case, the satisfier will automatically choose the most * optimal spending path (if more than one is available). + * For more details on using this parameter, refer to [this Stack Exchange + * answer](https://bitcoin.stackexchange.com/a/118036/89665). */ signersPubKeys?: Buffer[]; }) { @@ -910,7 +912,10 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) { validate = true }: { psbt: Psbt; - /** @default true */ + /** Runs further test on the validity of the signatures. + * It speeds down the finalization process but makes sure the psbt will + * be valid. + * @default true */ validate?: boolean | undefined; }) => this.finalizePsbtInput({ index, psbt, validate }); return finalizer; @@ -1003,7 +1008,10 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) { }: { index: number; psbt: Psbt; - /** @default true */ + /** Runs further test on the validity of the signatures. + * It speeds down the finalization process but makes sure the psbt will + * be valid. + * @default true */ validate?: boolean | undefined; }): void { if ( diff --git a/src/ledger.ts b/src/ledger.ts index 3f0a5cd..aeb652f 100644 --- a/src/ledger.ts +++ b/src/ledger.ts @@ -98,14 +98,33 @@ async function ledgerAppInfo(transport: any) { return { name, version, flags, format }; } +/** + * Verifies if the Ledger device is connected, if the required Bitcoin App is opened, + * and if the version of the app meets the minimum requirements. + * + * @throws Will throw an error if the Ledger device is not connected, the required + * Bitcoin App is not opened, or if the version is below the required number. + * + * @returns Promise - A promise that resolves if all assertions pass, or throws otherwise. + */ export async function assertLedgerApp({ transport, name, minVersion }: { + /** + * Connection transport with the Ledger device. + * One of these: https://github.com/LedgerHQ/ledger-live#libs---libraries + */ // eslint-disable-next-line @typescript-eslint/no-explicit-any transport: any; + /** + * The name of the Bitcoin App. "Bitcoin" for mainnet or "Bitcoin Test" for testnet. + */ name: string; + /** + * The minimum acceptable version of the Bitcoin App in semver format (major.minor.patch). + */ minVersion: string; }): Promise { const { name: openName, version } = await ledgerAppInfo(transport);