-
Notifications
You must be signed in to change notification settings - Fork 4
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
Interpret fee rates in reference fee unit #21
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
e1d24ef
Introduce CValue for distinguishing amounts from values
JBetz f31e9b0
Remove random character
JBetz c757bc3
Define insertion operator for CValue
JBetz 6820fe5
Move CValue to separate module
JBetz 4ed94c3
Remove consensus changes
JBetz 5fcbcdc
Remove CValue usage for fee rates, restrict to mempool
JBetz 6f59bad
More cleanup
JBetz 4409eab
Use CValue for descendant and ancestor fee updates
JBetz 182dfb5
More mempool fixes
JBetz 61df423
Remove unused include
JBetz e5221f2
Fix variable shadowing
JBetz e14ef73
More conversions
JBetz 02f827f
Factor in fee asset when validating package fees
JBetz 70579cc
More conversions
JBetz 0ff30fa
Convert dust relay fee from RFU
JBetz ecd598b
More cleanup
JBetz 66fc881
Cleanup
JBetz 9b10788
Don't factor in asset in when calculating dust threshold
JBetz eda394a
Convert package fees
JBetz 61f3a20
Return CValue from CalculateExchangeValue
JBetz 3e354d5
Use CValue for reverse exchange rate conversion
JBetz c6f7eac
Update method documentation
JBetz 6829d00
Rename currency conversion methods
JBetz e66f4bf
Fix typo
JBetz 2e12e9a
Add justification for RFU to comments
JBetz c2a58c2
Use accessor instead of public instance variable unpacking CValue
JBetz 7177e3c
Use GetValue() in fee rate conversion
JBetz 8843a32
Only apply dust check to outputs denominated in same asset as fee
JBetz 3892304
Interpret coin selection effective feerate in RFU
JBetz 30a1539
Change GetModifiedFee() method to use RFU for summing with ancestor a…
JBetz d50341f
Add functional test for "fee_rate" parameter in fundrawtransaction RP…
JBetz 6665de7
Normalize fees to RFU during fee estimation
JBetz 9e18f3a
Lint fixes
JBetz c12707c
More linting fixes
JBetz 734d6bc
More linting
JBetz b2b32d0
Apply method renams to fee amount conversions
JBetz abbb3a0
Add any asset fee rates test to test runner
JBetz 66879ed
More amount conversion fixes
JBetz 3174b34
Add compiler switch for currency constants
JBetz 29a4841
Add new configuration flag to documentation
JBetz bcf9e69
Apply fixes to fee estimation functional test from https://github.com…
JBetz de1eed5
Add tests for paytxfee parameter
JBetz 5a747d3
Cleanup
JBetz d9d8114
Fix compiler flag
JBetz 681fd41
Add tests for blockmintxfee
JBetz 947aa98
Remove whitespace
JBetz b9d84a8
Add comments clarifying what's being demonstrated
JBetz ab3a67b
Remove nFeeValue, recompute as needed
JBetz 543522e
Revert "Remove nFeeValue, recompute as needed"
JBetz 0c95a59
Move No Coin configuration documentation to separate line
JBetz 9c67d2e
Merge branch 'dev' into value-type
JBetz 69b09d5
Add constant for full name of currency atom
JBetz a51d080
Fix constant reference
JBetz be4d954
Fix typo
JBetz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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
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,65 @@ | ||
// Copyright (c) 2009-2010 Satoshi Nakamoto | ||
// Copyright (c) 2009-2021 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_POLICY_VALUE_H | ||
#define BITCOIN_POLICY_VALUE_H | ||
|
||
#include <cstdint> | ||
|
||
/** ELEMENTS: Amount denominated in the node's RFU (reference fee unit). Used only | ||
* when con_any_asset_fees is enabled in order to distinguish from amounts in an | ||
* actual asset. RFU is needed to make amounts comparable when sorting transactions | ||
* in the mempool, as well as for fee estimation and subsequent validation of those | ||
* fees according to various limits (e.g., mintxfee, paytsxfee, blockmintxfee, | ||
* incrementalrelaytxfee, etc.). | ||
*/ | ||
struct CValue | ||
{ | ||
private: | ||
int64_t value; | ||
|
||
public: | ||
CValue(): value(0) {} | ||
CValue(const int64_t value): value(value) {} | ||
|
||
int64_t GetValue() const | ||
{ | ||
return value; | ||
} | ||
|
||
CValue operator -(const CValue& operand) | ||
{ | ||
return CValue(value - operand.value); | ||
} | ||
|
||
CValue operator -=(const CValue& operand) | ||
{ | ||
value -= operand.value; | ||
return *this; | ||
} | ||
|
||
CValue operator +(const CValue& operand) | ||
{ | ||
return CValue(value + operand.value); | ||
} | ||
|
||
CValue operator +=(const CValue& operand) | ||
{ | ||
value += operand.value; | ||
return *this; | ||
} | ||
|
||
bool operator ==(const CValue& operand) | ||
{ | ||
return value == operand.value; | ||
} | ||
|
||
bool operator !=(const CValue& operand) | ||
{ | ||
return value != operand.value; | ||
} | ||
}; | ||
|
||
#endif // BITCOIN_POLICY_VALUE_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And finally,
dustrelayfee
. Here it's used exclusively for non-fee outputs, but still needs to be converted using exchange rates to check that the output doesn't cost more in fees than it's worth.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this shouldn't be using the exchange rates at all.
If there's a transaction with an output of some asset that the node doesn't have an exchange rate for, then there's no meaningful conversion from the fee rate to an amount using exchange rates. So we should probably just treat
dustrelayfee
as a lower bound on the amount that doesn't have anything to do with the RFU.Otherwise, the node will reject non-fee outputs as dust just because it doesn't care about the asset, which is obviously wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some more investigating and realized that dust checks are currently limited to outputs that have the same asset as the fee, so there's no risk of different assets being compared.
This applies to in policy: https://github.com/ElementsProject/elements/blob/master/src/policy/policy.cpp#L149
And to wallet: https://github.com/ElementsProject/elements/blob/master/src/wallet/spend.cpp#L1143 and https://github.com/ElementsProject/elements/blob/master/src/wallet/spend.cpp#L1559