-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: precondition for collaborative transactions (#485)
* fix: min confs of preconditions for all utxos instead of single * fix: i18n phrases of collaborative transaction preconditions * wip: use new scheduler preconditions in Jam component * fix: only report utxos without retries of no retry is left within jar * feat(regtest): set taker_utxo_retries and maker_timeout_sec config vars for improved testability * test(preconditions): add test for CoinjoinRequirements * fix: enable starting scheduler even if preconditions are not fulfilled * review: fix wording Co-authored-by: Gigi <[email protected]>
- Loading branch information
1 parent
09c1d30
commit db29235
Showing
11 changed files
with
504 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React, { forwardRef } from 'react' | ||
import * as rb from 'react-bootstrap' | ||
import { Trans, useTranslation } from 'react-i18next' | ||
import { useSettings } from '../context/SettingsContext' | ||
import { CoinjoinRequirementSummary } from '../hooks/CoinjoinRequirements' | ||
import { jarInitial } from './jars/Jar' | ||
import { shortenStringMiddle } from '../utils' | ||
import Sprite from './Sprite' | ||
import Balance from './Balance' | ||
|
||
interface CoinjoinPreconditionViolationAlertProps { | ||
summary: CoinjoinRequirementSummary | ||
i18nPrefix?: string | ||
} | ||
|
||
export const CoinjoinPreconditionViolationAlert = forwardRef( | ||
({ summary, i18nPrefix = '' }: CoinjoinPreconditionViolationAlertProps, ref: React.Ref<HTMLDivElement>) => { | ||
const { t } = useTranslation() | ||
const settings = useSettings() | ||
|
||
if (summary.isFulfilled) return <></> | ||
|
||
if (summary.numberOfMissingUtxos > 0) { | ||
return ( | ||
<rb.Alert variant="warning" ref={ref}> | ||
{t(`${i18nPrefix}hint_missing_utxos`, { | ||
minConfirmations: summary.options.minConfirmations, | ||
})} | ||
</rb.Alert> | ||
) | ||
} | ||
|
||
if (summary.numberOfMissingConfirmations > 0) { | ||
return ( | ||
<rb.Alert variant="warning" ref={ref}> | ||
{t(`${i18nPrefix}hint_missing_confirmations`, { | ||
minConfirmations: summary.options.minConfirmations, | ||
amountOfMissingConfirmations: summary.numberOfMissingConfirmations, | ||
})} | ||
</rb.Alert> | ||
) | ||
} | ||
|
||
const utxosViolatingRetriesLeft = summary.violations | ||
.map((it) => it.utxosViolatingRetriesLeft) | ||
.reduce((acc, utxos) => acc.concat(utxos), []) | ||
|
||
if (utxosViolatingRetriesLeft.length > 0) { | ||
return ( | ||
<rb.Alert variant="warning" ref={ref}> | ||
<> | ||
<Trans i18nKey={`${i18nPrefix}hint_missing_retries`}> | ||
You tried too many times. See | ||
<a | ||
href="https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/v0.9.7/docs/SOURCING-COMMITMENTS.md" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
the docs | ||
</a>{' '} | ||
for more info. | ||
</Trans> | ||
<br /> | ||
<br /> | ||
<Trans i18nKey={`${i18nPrefix}hint_missing_retries_detail`} count={utxosViolatingRetriesLeft.length}> | ||
Following utxos have been used unsuccessfully too many times: | ||
<ul className="mt-2 mb-0 ps-2"> | ||
{utxosViolatingRetriesLeft.map((utxo, index) => ( | ||
<li key={index} className="mb-2 slashed-zeroes small" style={{ display: 'inline-flex' }}> | ||
<span className="pe-1" style={{ display: 'inline-flex' }}> | ||
<Sprite symbol="jar-closed-fill-50" width="20" height="20" /> | ||
<span className="slashed-zeroes"> | ||
<strong>{jarInitial(utxo.mixdepth)}</strong> | ||
</span> | ||
: | ||
</span> | ||
<div> | ||
<span>{utxo.address}</span> | ||
( | ||
<Balance | ||
valueString={`${utxo.value}`} | ||
convertToUnit={settings.unit} | ||
showBalance={settings.showBalance} | ||
/> | ||
) | ||
<br /> | ||
<small>{shortenStringMiddle(utxo.utxo, 32)}</small> | ||
</div> | ||
</li> | ||
))} | ||
</ul> | ||
</Trans> | ||
</> | ||
</rb.Alert> | ||
) | ||
} | ||
|
||
return <></> | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.