Skip to content

Commit

Permalink
only fetch utxos when necessary (#167)
Browse files Browse the repository at this point in the history
Co-authored-by: Rosco Kalis <[email protected]>
  • Loading branch information
emergent-reasons and rkalis committed Nov 1, 2023
1 parent 839d87a commit cf3d833
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/cashscript/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

1 comment on commit cf3d833

@vercel
Copy link

@vercel vercel bot commented on cf3d833 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.