Skip to content

Implement UTXO Consolidation Helpers (for base assets) #3645

@arboleya

Description

@arboleya

Problem

  1. Users may have a lot of dust coins
  2. A transaction can't have more than N inputs
  3. When funding a transaction, it may require more than N coins
  4. Users have no way to consolidate their coins
  5. As a result, they might get stuck

Actionable Items

We need to think about two phases:

  1. Exporting method utilities for UTXO split and consolidation
  2. Provide an automated flow to consolidate coins on the fly during transaction funding/submission
    • This may be done later, expand the collapsible below for more info.

Automatic UTXO Consolidation

Because UTXO consolidation will use gas, it's tricky to enable it by default.

However, we could..

..offer an extra submission method or add parameters to the existing one.

The idea is to have the flow available, but it should be opt-in.

Here's a first sketch:

---
title: Automatic UTXO Consolidation
theme: dark
---

%%{
  init: {
    'theme': 'dark'
  }
}%%

flowchart TB
  Start(Start) --> GetCoins{GetCoins}
  GetCoins --> IsEnough[[Is it enough?]]
  IsEnough --> Yes(Yes)
  IsEnough --> No(No)
  Yes --> Submit{Submit}
  Submit --> End(End)

  No --> HasFreeInputs[[Max Inputs Reached?]]
  HasFreeInputs --> FreeYes(Yes)
  HasFreeInputs --> FreeNo(No)
  FreeNo --> Error(ERROR<br/>Insuf. Balance)

  FreeYes --> AutoConsolidate[[Auto consolidate?]]
  AutoConsolidate --> AutoNo(No)
  AutoConsolidate --> AutoYes(Yes)

  AutoYes --> Transfer{Transfer}
  Transfer --> GetCoins;
  AutoNo --> Error

style Error stroke:#570f43, fill:#570f43, color:#ffffff;

classDef StartEnd stroke:#333, fill:#fff, color:#000;
class Start StartEnd;
class End StartEnd;

classDef Actions stroke:#10375b, fill:#10375b, color:#ffffff;
class Consolidate Actions;
class Submit Actions;
class GetCoins Actions;
class Transfer Actions;
Loading

Metadata

Metadata

Assignees

Labels

featIssue is a feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions