avalanchego icon indicating copy to clipboard operation
avalanchego copied to clipboard

X-chain - Repack tx builder

Open abi87 opened this issue 10 months ago • 0 comments

Why this should be merged

Dynamic fees will radically chance the way we build transactions. Fees won't be known ahead of time, but will be iterativelly calculated as inputs and outputs are added to the tx. On top of this we have at least three ways to build transactions currently:

  • Using wallet's builder
  • With ad-hoc functions in X-chain APIs (deprecated and soon to be removed in favour of wallet)
  • Manually laying out txs in unit tests

This code duplication is a maintenance nightmare as we introduce dynamic fees. This PR simplify the maintenance burned in two ways:

  • Pulls out of X-chain APIs, txs builders
  • Makes txs builders use wallet builders to create transaction

In a coming PR, unit tests are update to make use of the txs builders instead of manually laying out txs, so to have a unified and maintainable way to build X-chain txs

How this works

  • Pull out of X-chain APIs, txs builders
  • Make txs builders use wallet builders to create transaction
  • Drop most of utxo.Spend methods (since wallet is used instead)

How this was tested

CI

abi87 avatar Apr 26 '24 11:04 abi87