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 Script:dust_value() to get minimum output value for a spk #566

Merged
merged 1 commit into from Feb 7, 2021

Conversation

TheBlueMatt
Copy link
Member

No description provided.

src/blockdata/script.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@sgeisler sgeisler left a comment

Choose a reason for hiding this comment

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

utACK 6622de4

/// Gets the minimum value an output with this script should have in order to be
/// broadcastable on today's bitcoin network.
pub fn dust_value(&self) -> u64 {
if self.is_op_return() {
Copy link
Contributor

Choose a reason for hiding this comment

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

When looking at core it also captures the case where a script is too big making the UTXO unspendable. But that would only make this implementation more conservative which might be ok since it's such a fringe use case and not consensus critical.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, right - are those scripts broadcastable at all or are they nonstandard?

Copy link
Member

@sanket1729 sanket1729 Feb 5, 2021

Choose a reason for hiding this comment

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

Those scripts are not possible by consensus rules all scripts(bare, p2sh, witness_v0). But post tapscript, those scripts will be broadcastable.

https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki#resource-limits

https://github.com/bitcoin/bitcoin/blob/6c6140846f37de8c132b3b6abf09f3d7940554a7/src/script/interpreter.cpp#L452

We can change the isWitnessProgram check to check only v0 programs, but this can also be done in taproot upgrade #503. But this could have easily been one of the things we forgot to add.

Copy link
Member

@sanket1729 sanket1729 Feb 5, 2021

Choose a reason for hiding this comment

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

@sgeisler Nevermind, I was wrong. This function is about scriptPubkey and not about the witness Program inside it. The witness program can be more 10,000 in Tapscript, but scriptpubkey is always 35.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I'm not even talking about if its valid (its obviously not possible to spend), but is it standard - can you broadcast a transaction with such a script in an output and have it be mined, even if the output is unspendable.

@sanket1729
Copy link
Member

utACK 6622de4

@sgeisler
Copy link
Contributor

sgeisler commented Feb 7, 2021

I don't think anything bad will come from erring on the safe side (especially with such an exotic corner case) in case of non-consensus rules, so I'll go ahead and merge. Feel free to open a follow-up issue/PR.

@sgeisler sgeisler merged commit 5bd6196 into rust-bitcoin:master Feb 7, 2021
@apoelstra
Copy link
Member

I wish that this PR, which is based on a 6-month-old version of master (which is a full major version behind and therefore cannot be tested with the current set of feature flags) and which nobody tested, had not been merged like this.

I spot checked the merge commit with a bunch of feature flags and it seems good.

@TheBlueMatt
Copy link
Member Author

TheBlueMatt commented Feb 10, 2021 via email

@sgeisler
Copy link
Contributor

Sorry, the PR seemed innocent enough and merged it 😦 putting "based off recent master" on my checklist. I guess I'll ping you more often in the future @apoelstra.

@sgeisler
Copy link
Contributor

therefore cannot be tested with the current set of feature flags

Can't you just checkout pr/566/merge instead of pr/566/head?

@apoelstra
Copy link
Member

@sgeisler yes, but my PR-testing script does not like to test things that are already descendends of master. It is also important to me that the individual commits compile ... which is not the case for this PR (without changing a bunch of cargo flags) even though it is a one-commit PR and even though the merge commit does compile.

It usually doesn't matter whether something is based off of that recent a master ... although I always do take a look and consider interactions that may be caused by having too many parallel branches being merged in ... but in this case we were a full six months behind.

@TheBlueMatt
Copy link
Member Author

TheBlueMatt commented Feb 10, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants