forked from m21/mastercore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: class CScript - dust rule should not apply to unspendable txouts
-OP_RETURN value of 0 is acceptable by protocol rules
- Loading branch information
1 parent
41739bd
commit 802ea70
Showing
1 changed file
with
4 additions
and
2 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
802ea70
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.
Imho it seems more reasonable to move that check closer to the wallet/transaction creation code in
ClassB_send
(or whereOP_RETURN
transactions are going to be created).802ea70
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.
CreateTransaction is a function of the wallet, and as part of its validity checks it verifies each output passes the dust check when creating a transaction.
I thought the most accurate approach was to make the response to IsDust false, since an unspendable txout is not considered dust.
We could for example override
CreateTransaction
in wallet.cpp to not perform the dust check for OP_RETURN outputs, but that didn't seem to provide proper coverage, since transaction creation is not the only place where the question of "is this txout dust?" might apply.802ea70
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.
Ahh, sorry, I see. Let me take a look at this, even though I saw that line, I'm quite surprised actually.
802ea70
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.
Found it. I did some OP_RETURN tests earlier, but I just saw those were not created with zero amounts.
This is the full blown check:
https://github.com/zathras-crypto/mastercore/blob/0.0.9.2-Z-ClassC/src/main.cpp#L570-L589
https://github.com/zathras-crypto/mastercore/blob/0.0.9.2-Z-ClassC/src/wallet.cpp#L1265-L1269
...?
Might even make sense to remove all those checks from wallet.cpp and simply call
IsStandard(wtxNew, strFailReason)
at the end.if-else
to:GetDustLimit()
, which could be tweaked as well, we might jump ahead and adopt some (slightly adjusted) pending-to-be-merged-upstream-code and get rid ofGetDustLimit()
:https://github.com/bitcoin/bitcoin/pull/5831/files#diff-5cb8d9decaa15620a8f98b0c6c44da9bL137
Edit: some edits. ;)