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

feat: Fidelity Bonds #307

Merged
108 commits merged into from
Jun 15, 2022
Merged

feat: Fidelity Bonds #307

108 commits merged into from
Jun 15, 2022

Conversation

theborakompanioni
Copy link
Collaborator

@theborakompanioni theborakompanioni commented Jun 6, 2022

First draft of Fidelity Bonds.
It currently looks nothing like the great designs by @editwentyone, but some building blocks are be present and hopefully it can be easily adjusted step by step from now on.

This PR has all previously implemented coin control features removed (moved to branch fidelity-bonds-coin-control-backup in case they are needed later)
This means that all available funds in a jar will be used to create the fidelity bond.
Thanks @dnlggr for your valuable feedback – it should now be much more easily reviewable.
Maybe some coin control features from #241 can be used and make it more configurable for users.

Some questions are still unanswered or need to be addressed:

  • How to communicate errors to the user and what to do if something fails
    • e.g no collaborative transactions preconditions are checked (>=5 confs; enough retries; utxos that are not at least 20% of the tx size)
  • How to choose the number of counterparties for the collaborative transaction?~
    • Currently, minimum_makers is used – which is not optimal
    • Should the user be responsible for choosing a value, e.g. like in the Send screen?

Internationalization (i18n) is not addressed as the UI will be reworked in subsequent PRs and it would be obsolete very quickly.

@theborakompanioni theborakompanioni added enhancement New feature or request concept Wild idea, or too many details unknown yet WIP Work in Progress labels Jun 6, 2022
@theborakompanioni theborakompanioni self-assigned this Jun 6, 2022
@theborakompanioni theborakompanioni added the blocked Merging this pull request is blocked until another issue is resolved label Jun 6, 2022
@theborakompanioni theborakompanioni force-pushed the fidelity-bonds-simple branch 2 times, most recently from af67373 to acb041e Compare June 7, 2022 12:13
theborakompanioni and others added 2 commits June 14, 2022 15:29
Co-authored-by: Gigi <109058+dergigi@users.noreply.github.com>
Co-authored-by: Gigi <109058+dergigi@users.noreply.github.com>
@ghost
Copy link

ghost commented Jun 15, 2022

Ok let's merge this now and work do any updates in separate PRs. Unless you're still reviewing @dergigi? 🤔

Imo I'd be nice to then:

  • move the whole thing to the Earn screen as per Figma; and
  • make the collaborative transaction magic in the background more transparent to the user

Copy link
Contributor

@dergigi dergigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Good job on all the tests, and on getting the first iteration through the door! 👏 Also: thank you @dnlggr for all the work on this in terms of sparring and review.

Tested locally on regtest, similarly to @theborakompanioni's demo in Call 17.

I only have nits, thus this can be merged I think. Looks good to me ✅

calculatedTotalBalanceInSats: accountTotalCalculated,
calculatedFrozenOrLockedBalanceInSats: accountFrozenOrLockedCalculated,
calculatedAvailableBalanceInSats: accountAvailableCalculated,
accountIndex: parseInt(account, 10),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Any reason for the explicit 10 in all the parseInt calls? 2nd param could be removed, 10 is default afaik.

Copy link
Collaborator Author

@theborakompanioni theborakompanioni Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over the years, I have made a habit of always specifying the radix to get reliable results.

Be careful—this does not default to 10!

See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

JavaScript is strange.

Edit: In this case, it would probably be fine, as we should not expect "malformed" inputs from JM.. nonetheless.. I guess I'll sleep better with the radix included. Is that okay for you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScript is strange.

Ain't that the truth! 😅

src/libs/JmWalletApi.ts Show resolved Hide resolved
// This is useful in simple mode - when it should be prevented that users
// lock up their coins for an awful amount of time by accident.
// In "advanced" mode, this can be dropped or increased substantially.
export const DEFAULT_MAX_TIMELOCK_YEARS = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 years is quite a lot 😅 -- that being said, I don't know what a sane maximum should be. 10 years is probably good!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.. as far as I can see most fidelity bonds are not beyond the year 2026.. should we decrease to a maximum of 5 years and wait for user feedback?

@dergigi
Copy link
Contributor

dergigi commented Jun 15, 2022

Ok let's merge this now and work do any updates in separate PRs.

Agree, also with next steps 👍 :shipit:

Copy link
Contributor

@MaxHillebrand MaxHillebrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff. Let's merge this, get feedback and improve it incrementally. 👏 👏 👏

@ghost ghost merged commit c68e4c5 into master Jun 15, 2022
@ghost ghost deleted the fidelity-bonds-simple branch June 15, 2022 13:17
@ghost ghost mentioned this pull request Jul 4, 2022
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concept Wild idea, or too many details unknown yet enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fidelity Bonds
3 participants