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

Various improvements of Taproot signing example #34

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

Kixunil
Copy link
Contributor

@Kixunil Kixunil commented Aug 19, 2024

The Taproot signing example had some parts that were unidiomatic, weirdly worded or just plain wrong. This change fixes some of them though not all. There's still things missing such as using witness_mut method on SighashCache and possibly things I missed because I was only looking for obvious things.

The Taproot signing example had some parts that were unidiomatic, weirdly worded or just plain wrong. This change fixes some of them though not all. There's still things missing such as using `witness_mut` method on `SighashCache` and possibly things I missed because I was only looking for obvious things.
Copy link
Contributor

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

Thanks! Great work!
ACK 30563ea

One minor comment/question

@@ -157,7 +151,7 @@ Now we are ready for our main function that will sign a transaction that spends
# }
#
# fn receivers_address() -> Address {
# Address::from_str("bc1p0dq0tzg2r780hldthn5mrznmpxsxc0jux5f20fwj0z3wqxxk6fpqm7q0va")
# "bc1p0dq0tzg2r780hldthn5mrznmpxsxc0jux5f20fwj0z3wqxxk6fpqm7q0va".parse::<Address<_>>()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to do a straight parse::<Address<Network::Bitcoin>>? That would be less code and more ergonomic in my opinion.

Copy link
Member

@tcharding tcharding Aug 19, 2024

Choose a reason for hiding this comment

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

Address isn't paramatized by the network but rather by NetworkValidation. (The underscore here is inferred to be NetworkUnchecked.)

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

One tiny change suggestion.

I'm not sure about the grammar of a variable "has a type" vs "is a type", however the original text has a bunch on 'a' vs 'an' mistakes so this PR is objectively better.

Note that `bc1p0dq0tzg2r780hldthn5mrznmpxsxc0jux5f20fwj0z3wqxxk6fpqm7q0va` is a [Bech32](https://bitcoinops.org/en/topics/bech32/) address.
This is an arbitrary, however valid, Bitcoin mainnet address.
Hence we use the `require_network` method to ensure that the address is valid for mainnet.
Bitcoin applications are usually configured with specific Bitcoin network at the start and use that.
To prevent mistakes related to people sending satoshis to a wrong network we need to call the `require_network` method to ensure that the address is valid for the network, in our case mainnet.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To prevent mistakes related to people sending satoshis to a wrong network we need to call the `require_network` method to ensure that the address is valid for the network, in our case mainnet.
To prevent mistakes related to people sending satoshis to the wrong network we need to call the `require_network` method to ensure that the address is valid for the network, in our case mainnet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe my version is correct. There are more networks than 2 so if one is correct in the context then there are multiple incorrect ones and you're only sending to one of them and it's not known which of them you're sending to so "a" makes sense. "the" would imply there's a specific wrong network but there isn't.

Copy link
Member

Choose a reason for hiding this comment

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

Technically I think Kix is right, but I think both articles are acceptable in idiomatic English. (When learning mathematics native English speakers have to explicitly learn that "the" is an explicit claim of uniqueness and has a bunch of semantic content.)

Copy link
Member

Choose a reason for hiding this comment

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

"a wrong network" does actually sound a little weird. I don't know if there's a clear rule for when it "sounds weird" to use an indefinite article, but it is what it is.

But Kix's text is correct so we should keep it.

Copy link
Member

@tcharding tcharding Aug 21, 2024

Choose a reason for hiding this comment

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

Thanks, you've convinced me its correct as is.

@apoelstra
Copy link
Member

As for "has the X type" vs "is a X", I think either one is fine. Types are (approximately) sets so the relationship is that objects are members of a type. But the existing "is a X type" is definitely wrong.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 30563ea

@Kixunil
Copy link
Contributor Author

Kixunil commented Aug 20, 2024

But the existing "is a X type" is definitely wrong.

Yes, my reasoning is that 42 is not an integer type, it's an integer value. So deleting the word type would be an alternative correct fix. I was under the impression that whoever wrote it used the word "type" to make it clear the things referenced are types (but accidentally caused different confusion).

@tcharding
Copy link
Member

All good to merge @apoelstra!

@apoelstra
Copy link
Member

Not sure what the ACK policy on this repo is, but FWIW @tcharding's doesn't count because he didn't provide any commit ID. But @storopoli did so I'll take his instead (and Tobin's soft "go ahead and merge" and Kix's implicit "I am the author" ACK).

@apoelstra apoelstra merged commit d62ce10 into rust-bitcoin:master Aug 21, 2024
3 checks passed
@apoelstra
Copy link
Member

I also don't know if there's some publish step that we're supposed to take after merging stuff here.

@Kixunil Kixunil deleted the patch-1 branch August 21, 2024 20:49
@tcharding
Copy link
Member

Oh woops, I could have just merged myself (after ack'ed correctly). In my mind at least its a one ack policy here.

@tcharding
Copy link
Member

I also don't know if there's some publish step that we're supposed to take after merging stuff here.

We have auto publish magic in this repo :)

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.

4 participants