diff --git a/src/providers/abstract-provider.ts b/src/providers/abstract-provider.ts index 85947b33..8b8d4ecd 100644 --- a/src/providers/abstract-provider.ts +++ b/src/providers/abstract-provider.ts @@ -1484,16 +1484,15 @@ export class AbstractProvider implements Provider { } async getOutpointsByAddress(address: AddressLike): Promise { - const outpoints: OutpointResponseParams[] = await this.#getAccountValue( + const outpointsObj: Record = await this.#getAccountValue( { method: 'getOutpointsByAddress' }, address, 'latest', ); - const outpointsArray = Array.isArray(outpoints) ? outpoints : []; - - return outpointsArray.map((outpoint: OutpointResponseParams) => ({ - txhash: outpoint.Txhash, + // Convert the object to an array of Outpoint objects + return Object.values(outpointsObj).map((outpoint: OutpointResponseParams) => ({ + txhash: outpoint.TxHash, index: outpoint.Index, denomination: outpoint.Denomination, })); diff --git a/src/providers/formatting.ts b/src/providers/formatting.ts index 02490c1b..f26c8c16 100644 --- a/src/providers/formatting.ts +++ b/src/providers/formatting.ts @@ -531,7 +531,7 @@ export interface QiTransactionResponseParams { } export interface OutpointResponseParams { - Txhash: string; + TxHash: string; Index: number; Denomination: number; } diff --git a/src/wallet/qi-hdwallet.ts b/src/wallet/qi-hdwallet.ts index 679dfa0f..077559e2 100644 --- a/src/wallet/qi-hdwallet.ts +++ b/src/wallet/qi-hdwallet.ts @@ -482,11 +482,7 @@ export class QiHDWallet extends AbstractHDWallet { */ private async getOutpointsByAddress(address: string): Promise { try { - const outpointsMap = await this.provider!.getOutpointsByAddress(address); - if (!outpointsMap) { - return []; - } - return Object.values(outpointsMap) as Outpoint[]; + return await this.provider!.getOutpointsByAddress(address); } catch (error) { throw new Error(`Failed to get outpoints for address: ${address} - error: ${error}`); }