jam icon indicating copy to clipboard operation
jam copied to clipboard

Verify and fix preconditions for collaborative transactions

Open theborakompanioni opened this issue 2 years ago • 1 comments

The current preconditions for collaborative transactions are flawed.

As of v0.0.9, CoinjoinPreconditions are as follows:

const COINJOIN_PRECONDITIONS = {
  MIN_NUMBER_OF_UTXOS: 1, // min amount of utxos available
  // https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/v0.9.6/docs/SOURCING-COMMITMENTS.md#wait-for-at-least-5-confirmations
  MIN_CONFIRMATIONS_OF_SINGLE_UTXO: 5, // at least one utxo needs X confirmations
  MIN_OVERALL_REMAINING_RETRIES: 1, // amount of overall retries available
}

This is not representing reality in jm, as can be seen in the logs below. e.g. from the logs it seems that more than one utxos need at least 5 confirmations, whereas Jam incorrectly states it needs at least one utxo with 5 confirmations. <- this statement needs verification - the approach might still be valid "per mixdepth"!

There might be other conditions that are not yet represented correctly and must be investigated.

The following log stems from starting the Scheduler (Jam page) with two confirmed utxos (>5 confs) and one unconfirmed utxo in Jar#0 and a single unconfirmed utxo in Jar #4:

2022-07-19 12:51:32,118 [INFO]  INFO:Failed to source a commitment; this debugging information may help:

1: Utxos that passed age and size limits, but have been used too many times (see taker_utxo_retries in the config):
None
2: Utxos that have less than 5 confirmations:
7c9c7341aea0306d0c20e50d416bcf1a8ebda74d241c7cce5a6a115e7d08eefb:2
3: Utxos that were not at least 20% of the size of the coinjoin amount 123119103
None
***
Utxos that appeared in item 1 cannot be used again.
Utxos only in item 2 can be used by waiting for more confirmations, (set by the value of taker_utxo_age).
Utxos only in item 3 are not big enough for this coinjoin transaction, set by the value of taker_utxo_amtpercent.
If you cannot source a utxo from your spending mixdepth according to these rules, use the tool add-utxo.py to source a utxo from another mixdepth or a utxo external to your joinmarket wallet. Read the help with 'python add-utxo.py --help'

***
For reference, here are the utxos in your wallet:

mixdepth 0:
    c2d9725bef8450b3fd3effbbee3b6b74222767c23f5588448fb7b11fd4494587:0 - path: m/84'/1'/0'/0/0, address: bcrt1q05c2hcn8jrl0l2mymegj5zwgzcjzway73ght2n, value: 5000000000
    2f510976e4ebf0bd3cb0c11b6bc5b6c969e351e26894a0ab44490651dd62558c:0 - path: m/84'/1'/0'/0/0, address: bcrt1q05c2hcn8jrl0l2mymegj5zwgzcjzway73ght2n, value: 5000000000
    7c9c7341aea0306d0c20e50d416bcf1a8ebda74d241c7cce5a6a115e7d08eefb:0 - path: m/84'/1'/0'/1/0, address: bcrt1qenkhn0nk5pzsa6aca4eyzwuz3z8pu8nlheevd2, value: 4876873907
mixdepth 4:
    7c9c7341aea0306d0c20e50d416bcf1a8ebda74d241c7cce5a6a115e7d08eefb:2 - path: m/84'/1'/4'/0/0, address: bcrt1qvzzhwmvzchghrtka2ghrky3kksh3hn2j0w0j56, value: 123123123

theborakompanioni avatar Aug 01 '22 12:08 theborakompanioni

This just got a higher priority now, as https://github.com/JoinMarket-Org/joinmarket-clientserver/pull/1324 has been merged to master, which adds the ability to start the scheduler with funds in any Jar. The current preconditions still need funds in Jar #0 which needlessly keeps users from starting the scheduler successfully.

theborakompanioni avatar Aug 11 '22 13:08 theborakompanioni