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

[r2r] hotfix: disallow withdraw to taproot addresses #1503

Merged
merged 8 commits into from
Oct 18, 2022
Merged

Conversation

shamardy
Copy link
Collaborator

No description provided.

@shamardy shamardy changed the title [wip] hotfix: disallow withdraw to taproot addresses [r2r] hotfix: disallow withdraw to taproot addresses Oct 17, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

Thanks for the fast fix! I have one note.

if payload.is_empty() {
return Err(Error::EmptyBech32Payload);
}
if variant == bech32::Variant::Bech32m {
Copy link
Member

Choose a reason for hiding this comment

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

If the new variant is added, it will pass this check and the address will be parsed incorrectly. Please add an explicit match statement here without _ placeholder. We should get a compiler error when a new variant appears.

@smk762
Copy link

smk762 commented Oct 17, 2022

Tested in GUI for both BTC and tBTC, appears to be functioning as expected 👍 Thanks for the quick fix!
image
image
image

caglaryucekaya
caglaryucekaya previously approved these changes Oct 17, 2022
@shamardy shamardy changed the title [r2r] hotfix: disallow withdraw to taproot addresses [wip] hotfix: disallow withdraw to taproot addresses Oct 17, 2022
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Great hotfix!
The only one question.

mm2src/mm2_bitcoin/keys/src/segwitaddress.rs Show resolved Hide resolved
@shamardy shamardy changed the title [wip] hotfix: disallow withdraw to taproot addresses [r2r] hotfix: disallow withdraw to taproot addresses Oct 17, 2022
@shamardy
Copy link
Collaborator Author

@artemii235 @caglaryucekaya @sergeyboyko0791 this is ready for another review round.
I tried to cover everything in these 3 BIPs
https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki
https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki
If you have time to check if I missed something that would be great :) , you can give more attention to the test vectors to see that all the cases are covered.

@sergeyboyko0791
Copy link

Unstable ETH tests have been fixed in dev branch, but they are still unstable in mm2.1. How about ignoring them for a while? @shamardy @artemii235

@artemii235
Copy link
Member

Unstable ETH tests have been fixed in dev branch, but they are still unstable in mm2.1. How about ignoring them for a while?

@sergeyboyko0791, yes, I think it's worth doing it. @shamardy

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

One more note.

mm2src/mm2_bitcoin/keys/src/segwitaddress.rs Show resolved Hide resolved
@shamardy shamardy changed the title [r2r] hotfix: disallow withdraw to taproot addresses [wip] hotfix: disallow withdraw to taproot addresses Oct 17, 2022
Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

Thanks!

@shamardy shamardy changed the title [wip] hotfix: disallow withdraw to taproot addresses [r2r] hotfix: disallow withdraw to taproot addresses Oct 17, 2022

#[test]
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#test-vectors
fn test_invalid_segwit_addresses() {

Choose a reason for hiding this comment

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

You skipped the first test, Invalid human-readable part

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's covered here https://github.com/KomodoPlatform/atomicDEX-API/blob/d950555d2d78a42e40c3e59a4deb3963894dd91d/mm2src/mm2_main/src/mm2_tests.rs#L1688 We check the hrp against the hrp from coin config outside the from_str function since the hrp from config can't be passed to from_str
So this address tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty from the test vectors when converted to SegwitAddress using from_str will be valid

Copy link
Collaborator Author

@shamardy shamardy Oct 17, 2022

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Great, thought you forgot it

@artemii235 artemii235 merged commit 2665257 into mm2.1 Oct 18, 2022
@artemii235 artemii235 deleted the disable-bech32m branch October 18, 2022 11:24
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.

5 participants