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

Add fees to NUT-02 #126

Merged
merged 8 commits into from
Jun 27, 2024
Merged

Add fees to NUT-02 #126

merged 8 commits into from
Jun 27, 2024

Conversation

callebtc
Copy link
Contributor

@callebtc callebtc commented May 27, 2024

Proposing to add fees to the mandatory part of the spec as I expect most public mints will require fees at some point. If the fees are not set, we should assume it as being 0.

Moved around some existing text. The new part is:

Fees (parts per thousand)

Keysets indicate the fee input_fee_ppk that is charged when a Proof of that keyset is spent as an input to a transaction. The fee is given in parts per thousand (ppk) per input measured in the unit of the keyset and the sum is rounded up to the next larger integer.

As an example, we construct a transaction spending 3 inputs (Proofs) from a keyset with unit sat and input_fee_ppk of 100. A fee of 100 ppk means 0.1 sat per input. The sum of the fees would be 300 ppk for this transaction and the mint would charge 1 sat in fees (ceil(0.3) == 1). The fees for spending 1-10 inputs is 1 sat, 11-20 inputs is 2 sat and so on.

...

Wallet input and output construction

When constructing a transaction with ecash inputs (example: /v1/swap or /v1/melt), wallets MUST add fees to the inputs (or subtract from the outputs) if they spent ecash from a keyset with fees. The mint checks the following equation:

sum(inputs) - sum(fees) == sum(outputs)

The fees are calculated for each input individually (by summing the fee from the keyset they are from) and then rounded up to the next integer.

Tracking progress

Mints:

  • nutshell PR
  • CDK PR
  • gonuts PR
  • nutmix PR
  • chamberlain

Wallets

  • nutshell PR
  • cashu-ts
  • Minibits
  • eNuts
  • Cashu.me
  • ...

02.md Show resolved Hide resolved
@Semisol
Copy link
Contributor

Semisol commented May 30, 2024

unintended side effect: this has a negative effect on privacy measures and offline spending

@elnosh elnosh mentioned this pull request Jun 3, 2024
02.md Outdated Show resolved Hide resolved
02.md Outdated Show resolved Hide resolved
callebtc added a commit to cashubtc/nutshell that referenced this pull request Jun 16, 2024
Co-authored-by: gandlafbtc <[email protected]>
callebtc added a commit to cashubtc/nutshell that referenced this pull request Jun 16, 2024
@callebtc callebtc added breaking change This issue/PR entails breaking changes ready Ready to merge labels Jun 17, 2024
def fees(inputs: List[Proof]) -> int:
sum_fees = 0
for proof in inputs:
sum_fees += keysets[proof.id].input_fee_ppk

Choose a reason for hiding this comment

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

Still missing proof.amount here:

Suggested change
sum_fees += keysets[proof.id].input_fee_ppk
sum_fees += proof.amount * keysets[proof.id].input_fee_ppk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still missing proof.amount here:

The fees are not amount-dependent.

@callebtc callebtc merged commit 40771dc into main Jun 27, 2024
@callebtc callebtc deleted the input-fees branch June 27, 2024 17:30
@thesimplekid thesimplekid mentioned this pull request Jun 27, 2024
@thesimplekid thesimplekid mentioned this pull request Jul 8, 2024
2 tasks
@elnosh elnosh mentioned this pull request Jul 15, 2024
@lescuer97
Copy link

merged in nutmix.
lescuer97/nutmix#74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This issue/PR entails breaking changes ready Ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants