From cf3d83375b810b63d1be3928dd68bc6e8e95ff70 Mon Sep 17 00:00:00 2001 From: emergent_reasons <34025062+emergent-reasons@users.noreply.github.com> Date: Wed, 1 Nov 2023 18:24:22 +0900 Subject: [PATCH] only fetch utxos when necessary (#167) Co-authored-by: Rosco Kalis --- packages/cashscript/src/Transaction.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cashscript/src/Transaction.ts b/packages/cashscript/src/Transaction.ts index ec096b82..9c5333eb 100644 --- a/packages/cashscript/src/Transaction.ts +++ b/packages/cashscript/src/Transaction.ts @@ -282,7 +282,8 @@ export class Transaction { throw Error('Attempted to build a transaction without outputs'); } - const allUtxos = await this.provider.getUtxos(this.address); + // Fetched utxos are only used when no inputs are available, so only fetch in that case. + const allUtxos: Utxo[] = this.inputs.length === 0 ? await this.provider.getUtxos(this.address) : []; const tokenInputs = this.inputs.length > 0 ? this.inputs.filter((input) => input.token)