Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coin selection (Cancel) #6

Open
darosior opened this issue May 10, 2021 · 2 comments
Open

Coin selection (Cancel) #6

darosior opened this issue May 10, 2021 · 2 comments

Comments

@darosior
Copy link
Member

darosior commented May 10, 2021

  • Given a nice UTXO pool, how do we effectively choose the best UTXOs to consume?
  • If no pool, how do we peel the big UTXO and create the change output?
  • If a mix, how to do both?
    EDITed: we went with a pool.
@darosior
Copy link
Member Author

If we go for a pool, the coin selection algorithm should probably be biased toward spending small UTXOs first. This way if the average value needed for a fee bump is increasing, we don't have to re-create new utxos out of the "deprecated" ones: they would be used before they are completely deprecated.

@darosior
Copy link
Member Author

Given:

  • a minimum feerate f and absolute fee F that we need to feebump a tx to
  • a nicely laid-out pool of UTXOs (with 8 coins registered for this tx)

Fee bump coin selection algorithm

Without a dedicated consolidation mechanism

  1. Strip tx of all fee bumping inputs (spending some of the 8 coins) it could have
  2. Considering all the 8 now-available coins, select the set of the smallest coins such as appended to tx inputs they make its feerate go above f and its absolute fee above F.

FIXME: we could give this a bias. If the feerate is not crazy, do that, if it is, just take the most optimal ones, if it is mildly crazy do an in-between.

With a dedicated consolidation mechanism

If we have a process to swipe the low-value coins during low-fee periods, we can afford to go for the most optimal strategy. [0]

  1. Strip tx of all fee bumping inputs (spending some of the 8 coins) it could have
  2. Considering all the 8 now-available coins, select the set of the largest coins such as appended to tx inputs they make its feerate go above f and its absolute fee above F.

If the reserve isn't enough

In the unlikely case that we need to feebump (because the timelock is about to expire) and the block space price is higher than our reserve, we could use the unregistered coins as an emergency measure. What is the preferable solution?

No-brain rush

Just use up the unregistered coins if it can provide us with a high-enough feerate. This assumes that we won't have to immediately Cancel another vault for a higher value.

Strategic

Allocate unregistered coins to highest-value vaults under watch if we detect that our reserve isn't enough anymore. This gives some more leeway to these vaults should they need to be canceled, and we can still apply the above policy afterward since any left unregistered coin is an excess that can be used up by any vault. Obviously stop accepting new vaults and urge for a refill.


[0] Note that even if we don't, one could argue that they can still be re-purposed. But the assumption is that the average feerate will increase over time and therefore the low-value coins would be harder -if at all possible- to re-assign and eventually need to be sweeped.

@darosior darosior assigned JSwambo and unassigned darosior Jun 16, 2021
@darosior darosior pinned this issue Nov 10, 2021
@darosior darosior changed the title Coin selection for fee-bumping purpose Coin selection (Cancel) Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants