Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
This repository was archived by the owner on May 27, 2025. It is now read-only.

Building BTC TX with an address having excessive UTXOs takes forever #173

@ShookLyngs

Description

@ShookLyngs

Issue

A transaction with specific from address can take forever to build, for example:

await sendBtc({
  from: 'tb1quqtqsh5jrlr9p5wnpu3rs883lqh4avpwc766x3',
  tos: [
    {
      address: 'tb1quqtqsh5jrlr9p5wnpu3rs883lqh4avpwc766x3',
      value: 1000,
    },
  ],
  source,
});

What happens:

  1. The construction process contains a loop to estimate the fee of the transaction
  2. In each loop, the BtcAssetsApi.getBtcUtxos() API is called to get the latest UTXO[] list
  3. Each request can take 8-15 seconds, and in each loop, more UTXOs are collected to the inputs
  4. If the inputs length increased, the estimated fee is also increased, causing another round of the loop
  5. The condition to break the loop takes a very long time to be satisfied (due to the INSUFFICIENT_UTXO error)
  6. The loop (tested by @Dawn-githup) can take 40+ minutes to fail, which is clearly abnormal

Investigation & resolvers

  • Should the BtcAssetsApi to be queried once per build to avoid long waiting time of requests?
    • The UTXO[] list can be updated during the construction, should we worry about it?
  • There's only a 1000 satoshi output in the outputs, not a huge cost at all, so why won't the loop stop?
    • Is it because some bugs remain in the pay fee process?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions