-
Notifications
You must be signed in to change notification settings - Fork 38.1k
rpc: addmultisigaddress should fallback to OutputType::LEGACY when uncompressed public keys are provided #16012
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
Conversation
…compressed public keys are provided #16011
|
I just noticed that the function |
|
Be reminded that bugfixes must be accompanied by a test that fails before the change and passes after it |
|
Thank you for the reminder @MarcoFalke , I'll add a test soon. I'm just trying to figure out if my current fix is enough or there are any other broken parts in the process, because there's a comment here saying that the use of uncompressed keys should be managed, but apparently it's not |
|
@MarcoFalke so, you would prefer we close this fix of a potentially money losing bug if no one felt like adding a test case for trivial functionality? I couldn't more strongly disagree. |
|
So you would prefer to not have a test, so that we can regress on this in the future and cause money loss for users? |
|
Nothing prevents fixing the bug, and the separately adding a test. I certainly agree we should have tests for issues discovered in the past, but that doesn't mean there is a strong requirement to have one in the same PR, by the same author. |
|
@MarcoFalke Perhaps I misunderstood you. It sounded to me like you were expressing the view that a fix wouldn't be accepted if it was submitted without an automated test, if so I believe that isn't a position that we should take. If instead you were just expressing doubt that there was actually a bug here to fix, then I agree. But coming with an automated test is not the bar for determining if a bug exists or not. I also think it's great to ask contributors if they'd be willing to automate their test, but we should probably lean towards "I'll help you figure out how to do it" especially for new contributors, rather than "you must be this tall to ride, good luck". And our urgency should be modulated somewhat by how easy it would be to accidentally regress: If someone finds a spelling error in a help message we're not exactly going to insist on adding a regression test which checks that help output for the misspelled word. :) Some fixes have a low probability of an accidentally regression and a targeted test which only catches that one behaviour may well not be worth its maintenance burden. Similarly, if a 'bug' were really inconsequential-- then I could support a position that including a test would be a minimum proof of work before we'd bother dealing with it, but this would be a serious bug if it were real. Which I suspect it isn't:
It's a little surprising that its silently auto-returning legacy when you give it an explicit parameter, it might be better to return an error, but before actually arguing that I'd want to go look to see if that had already been discussed. Auto-returning legacy when it must when there is no argument is at most a doc bug. |
|
This is what I'm trying to understand @gmaxwell , it doesn't happen |
|
Indeed, I just tested further. It appears to me that it only auto switches to legacy when more than the threshold of keys is uncompressed. 0_o This is absolutely a bug.
|
|
I noticed that, and also this comment only after opening the PR, so this commit now seems more like a workaround for a problem which I still don't understand. I followed the code of the function |
|
I believe this affects |
|
Maybe is unrelated and I'm missing something stupid because I don't have any experience on the bitcoin test framework, but I'm having some problems even with the test. def do_multisig_fallback_to_legacy(self):
self.log.info('Check that addmultisigaddress and createmultisig fallback to legacy when uncompressed public keys are provided')
pubkey1 = "045897fee25bd7c5692510b2f50fcae9aa20fbc4d49d59814f4c7fdb5c4bc6eb1c0ce382458f9588e922e0d509ed8d34856787380075b00418b02e0bf7c652ef9d"
pubkey2 = "02ac46c6d74d15e60f4f1035ff07ef740aca1d68d55ba0b8d336a73d7a35858831"
pubkey3 = "0224a4dc5620714a9ecf67a09583d1e4c04f5bedb8ecea99028da05bb15a2a7e07"
for self.output_type in ["legacy", "p2sh-segwit", "bech32"]:
msigw = self.nodes[0].addmultisigaddress(1, [pubkey1, pubkey2, pubkey3], None, self.output_type)
assert msigw["address"] == "3GiimyxF1R5VixfBFAbQZbuy9EesD2r6n1"But the assert fails, both with my commit and without, and if I print the 3 addresses ( Do you have any idea on what's wrong here? The same call with |
|
@ps1dr3x I haven't dived into this but I noticed that your test uses a "3..." prefix for the address, but the address encoding for regtest/testnet (which is what we use in our test framework) is different than mainnet, so P2SH addresses will start with a "2". |
|
Oh yeah you're right, I didn't thought about that! Thank you @sdaftuar 👍 |
|
It is fine if you don't add a test case if it is too hard to get one. I thought this would be a single line added with an assert, but I guess it turned out more involved? |
|
Yes, and at this point maybe that test will not even fit for the real causes @MarcoFalke . I asked mainly because I was experimenting but I'll not commit that, at least before the real causes are discovered :) Anyway, meanwhile that @achow101 cannot work on this, I'll continue to try getting more information (or hopefully finding possible fixes) on this |
|
This was simpler than expected. I've opened a PR: #16022 |
…ys returns a legacy address a495034 Make and get the multisig redeemscript and destination in one function instead of two (Andrew Chow) Pull request description: `CreateMultisigRedeemscript()` is changed to `AddAndGetMultisigDestination()` so that the process of constructing the redeemScript and then getting the `CTxDestination` are done in the same function. This allows that function to see what the keys in the multisig are so that the correct address type is returned from `AddAndGetDestinationForScript()`. This only effects the `createmultisig` and `addmultisigaddress` RPCs and does not change signing logic as #16022 does. Alternative to #16022 and #16012 Fixes #16011 ACKs for commit a49503: Tree-SHA512: 5b0154a714deea3b2cc3a54beb420c95eeeacf4ca30c40ca80940d9d640f8b03611b0fc14c2f0710bfd8a79e8d27ad7d9ae380b4b83d52b40ab201624f2a63f0
…ig always returns a legacy address a495034 Make and get the multisig redeemscript and destination in one function instead of two (Andrew Chow) Pull request description: `CreateMultisigRedeemscript()` is changed to `AddAndGetMultisigDestination()` so that the process of constructing the redeemScript and then getting the `CTxDestination` are done in the same function. This allows that function to see what the keys in the multisig are so that the correct address type is returned from `AddAndGetDestinationForScript()`. This only effects the `createmultisig` and `addmultisigaddress` RPCs and does not change signing logic as bitcoin#16022 does. Alternative to bitcoin#16022 and bitcoin#16012 Fixes bitcoin#16011 ACKs for commit a49503: Tree-SHA512: 5b0154a714deea3b2cc3a54beb420c95eeeacf4ca30c40ca80940d9d640f8b03611b0fc14c2f0710bfd8a79e8d27ad7d9ae380b4b83d52b40ab201624f2a63f0
862cbf3 Add missing contributor to release notes (MeshCollider) Pull request description: The user contacted me on Twitter and pointed out that he had contributed in both the reporting of the bug #16012 as well as a number of PRs following it, so I think he deserves to be credited in the release notes (also changed to use my real name while I'm there) ACKs for top commit: laanwj: ACK 862cbf3 Tree-SHA512: 94bbe168783243fd436b29b741be182fb0dcc247a6e8f52dafcd301ebc63f21e4e035677aa038db95e2e9d2062f5811f2dda1fd6d53966649773c69babb3f61b
862cbf3 Add missing contributor to release notes (MeshCollider) Pull request description: The user contacted me on Twitter and pointed out that he had contributed in both the reporting of the bug bitcoin#16012 as well as a number of PRs following it, so I think he deserves to be credited in the release notes (also changed to use my real name while I'm there) ACKs for top commit: laanwj: ACK 862cbf3 Tree-SHA512: 94bbe168783243fd436b29b741be182fb0dcc247a6e8f52dafcd301ebc63f21e4e035677aa038db95e2e9d2062f5811f2dda1fd6d53966649773c69babb3f61b
862cbf3 Add missing contributor to release notes (MeshCollider) Pull request description: The user contacted me on Twitter and pointed out that he had contributed in both the reporting of the bug bitcoin#16012 as well as a number of PRs following it, so I think he deserves to be credited in the release notes (also changed to use my real name while I'm there) ACKs for top commit: laanwj: ACK 862cbf3 Tree-SHA512: 94bbe168783243fd436b29b741be182fb0dcc247a6e8f52dafcd301ebc63f21e4e035677aa038db95e2e9d2062f5811f2dda1fd6d53966649773c69babb3f61b
862cbf3 Add missing contributor to release notes (MeshCollider) Pull request description: The user contacted me on Twitter and pointed out that he had contributed in both the reporting of the bug bitcoin#16012 as well as a number of PRs following it, so I think he deserves to be credited in the release notes (also changed to use my real name while I'm there) ACKs for top commit: laanwj: ACK 862cbf3 Tree-SHA512: 94bbe168783243fd436b29b741be182fb0dcc247a6e8f52dafcd301ebc63f21e4e035677aa038db95e2e9d2062f5811f2dda1fd6d53966649773c69babb3f61b
862cbf3 Add missing contributor to release notes (MeshCollider) Pull request description: The user contacted me on Twitter and pointed out that he had contributed in both the reporting of the bug bitcoin#16012 as well as a number of PRs following it, so I think he deserves to be credited in the release notes (also changed to use my real name while I'm there) ACKs for top commit: laanwj: ACK 862cbf3 Tree-SHA512: 94bbe168783243fd436b29b741be182fb0dcc247a6e8f52dafcd301ebc63f21e4e035677aa038db95e2e9d2062f5811f2dda1fd6d53966649773c69babb3f61b
This is related to issue #16011
Currently, in
addmultisigaddressfunction's code the output type is always given bypwallet->m_default_address_type. (https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpcwallet.cpp#L1018)This PR adds a fallback to legacy when one or more provided public keys are uncompressed.