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

PSBT key path cleanups #13723

Merged
merged 11 commits into from Aug 28, 2018

Conversation

Projects
None yet
8 participants
@sipa
Copy link
Member

commented Jul 20, 2018

This PR adds "key origin" (master fingeprint + key path) information to what is exposed from SigningProviders, allowing this information to be used by the generic PSBT code instead of having the RPC pull it directly from the wallet.

This is also a preparation to having PSBT interact with output descriptors, which can then directly expose key origin information for the scripts they generate.

@sipa sipa force-pushed the sipa:201807_key_origin_provider branch Jul 20, 2018

@practicalswift

This comment has been minimized.

Copy link
Member

commented Jul 20, 2018

Concept ACK

Thanks for taking another look at this code

@promag
Copy link
Member

left a comment

Partial utACK. Nice refactors that improve code readability. Some nits regarding code style.

src/script/sign.cpp Outdated
@@ -624,3 +624,8 @@ bool PublicOnlySigningProvider::GetPubKey(const CKeyID &address, CPubKey& pubkey
{
return m_provider->GetPubKey(address, pubkey);
}

bool PublicOnlySigningProvider::GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo& info) const

This comment has been minimized.

Copy link
@promag

promag Jul 20, 2018

Member

Commit "Make SigningProvider expose key origin information"

nit CKeyID& keyid.

This comment has been minimized.

Copy link
@sipa

sipa Jul 20, 2018

Author Member

done

src/wallet/wallet.cpp Outdated
@@ -4378,4 +4378,3 @@ void CWallet::LearnAllRelatedScripts(const CPubKey& key)
// OutputType::P2SH_SEGWIT always adds all necessary scripts for all types.
LearnRelatedScripts(key, OutputType::P2SH_SEGWIT);
}

This comment has been minimized.

Copy link
@promag

promag Jul 20, 2018

Member

Commit "Make SigningProvider expose key origin information"

nit, remove.

This comment has been minimized.

Copy link
@sipa

sipa Jul 20, 2018

Author Member

done

src/script/sign.h Outdated
@@ -47,6 +48,7 @@ class PublicOnlySigningProvider : public SigningProvider
PublicOnlySigningProvider(const SigningProvider* provider) : m_provider(provider) {}
bool GetCScript(const CScriptID &scriptid, CScript& script) const;
bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const;
bool GetKeyOrigin(const CKeyID &address, KeyOriginInfo& info) const;

This comment has been minimized.

Copy link
@promag

promag Jul 20, 2018

Member

Commit "Make SigningProvider expose key origin information"

nit, CKeyID& address.

This comment has been minimized.

Copy link
@sipa

sipa Jul 20, 2018

Author Member

done

src/script/sign.cpp Outdated
return m_provider->GetKey(keyid, key);
}

bool HidingSigningProvider::GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo& info) const

This comment has been minimized.

Copy link
@promag

promag Jul 20, 2018

Member

Commit "Generalize PublicOnlySigningProvider into HidingSigningProvider"

nit, CKeyID& keyid.

This comment has been minimized.

Copy link
@sipa

sipa Jul 20, 2018

Author Member

done

src/script/sign.h Outdated
bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const;
bool GetKeyOrigin(const CKeyID &address, KeyOriginInfo& info) const;
HidingSigningProvider(const SigningProvider* provider, bool hide_secret, bool hide_origin) : m_hide_secret(hide_secret), m_hide_origin(hide_origin), m_provider(provider) {}
bool GetCScript(const CScriptID &scriptid, CScript& script) const override;

This comment has been minimized.

Copy link
@promag

promag Jul 20, 2018

Member

Commit "Generalize PublicOnlySigningProvider into HidingSigningProvider"

nit, CScriptID& scriptid and some more below.

This comment has been minimized.

Copy link
@sipa

sipa Jul 20, 2018

Author Member

done

@sipa sipa force-pushed the sipa:201807_key_origin_provider branch 5 times, most recently Jul 20, 2018

@achow101
Copy link
Member

left a comment

Concept ACK

src/wallet/rpcwallet.cpp Outdated
@@ -4461,21 +4461,14 @@ bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, const C
}

SignatureData sigdata;
complete &= SignPSBTInput(HidingSigningProvider(pwallet, !sign, false), *psbtx.tx, input, sigdata, i, sighash_type);
complete &= SignPSBTInput(HidingSigningProvider(pwallet, !sign, !bip32derivs), *psbtx.tx, input, sigdata, i, sighash_type);

This comment has been minimized.

Copy link
@achow101

achow101 Jul 20, 2018

Member

Shouldn't this change be part of the earlier " Generalize PublicOnlySigningProvider into HidingSigningProvider" commit?

This comment has been minimized.

Copy link
@sipa

sipa Jul 20, 2018

Author Member

It could be, but doesn't matter. There is no bip32 information in SignatureData until this commit.

@sipa sipa force-pushed the sipa:201807_key_origin_provider branch Jul 20, 2018

src/script/sign.cpp Outdated
@@ -620,7 +620,12 @@ bool PublicOnlySigningProvider::GetCScript(const CScriptID &scriptid, CScript& s
return m_provider->GetCScript(scriptid, script);
}

bool PublicOnlySigningProvider::GetPubKey(const CKeyID &address, CPubKey& pubkey) const
bool PublicOnlySigningProvider::GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const
{
return m_provider->GetPubKey(address, pubkey);

This comment has been minimized.

Copy link
@achow101

achow101 Jul 20, 2018

Member

In commit "Make SigningProvider expose key origin information"

You should change address to keyid in this commit instead of "Generalize PublicOnlySigningProvider into HidingSigningProvider"

This comment has been minimized.

Copy link
@sipa

sipa Jul 20, 2018

Author Member

Done.

@sipa sipa force-pushed the sipa:201807_key_origin_provider branch Jul 20, 2018

@DrahtBot

This comment has been minimized.

Copy link
Contributor

commented Jul 22, 2018

Note to reviewers: This pull request conflicts with the following ones:
  • #14021 (Import key origin data through importmulti by achow101)
  • #13932 (Additional utility RPCs for PSBT by achow101)
  • #13815 (util: Add [[nodiscard]] to all {Decode,Parse}... functions returning bool by practicalswift)
  • #13671 (Remove the boost/algorithm/string/case_conv.hpp dependency by 251Labs)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@laanwj

This comment has been minimized.

Copy link
Member

commented Jul 23, 2018

utACK f6ba1ca1e51d044b6fc8398edfa4dd03061572c4
verified that [MOVEONLY] Move ParseHDKeypair is move-only

@sipa sipa force-pushed the sipa:201807_key_origin_provider branch Jul 24, 2018

@sipa

This comment has been minimized.

Copy link
Member Author

commented Jul 24, 2018

Rebased.

@MarcoFalke

This comment has been minimized.

Copy link
Member

commented Aug 7, 2018

Should be fixed by deleting the travis cache and resetting that particular job.

@achow101

This comment has been minimized.

Copy link
Member

commented Aug 9, 2018

utACK 9c28a0c0ddfb09dcd4d5c0ca83ce5cdae9bc1fa2

@sipa sipa force-pushed the sipa:201807_key_origin_provider branch Aug 10, 2018

@sipa

This comment has been minimized.

Copy link
Member Author

commented Aug 10, 2018

Rebased on top of #13917, which has far higher priority.

@sipa sipa force-pushed the sipa:201807_key_origin_provider branch to 917353c Aug 13, 2018

@DrahtBot DrahtBot removed the Needs rebase label Aug 13, 2018

@laanwj laanwj added this to Blockers in High-priority for review Aug 16, 2018

}

void AddKeypathToMap(const CWallet* pwallet, const CKeyID& keyID, std::map<CPubKey, std::vector<uint32_t>>& hd_keypaths)
void AddKeypathToMap(const CWallet* pwallet, const CKeyID& keyID, std::map<CPubKey, KeyOriginInfo>& hd_keypaths)

This comment has been minimized.

Copy link
@Empact

Empact Aug 20, 2018

Member

Looks like this is no longer called.

@laanwj

This comment has been minimized.

Copy link
Member

commented Aug 28, 2018

re-utACK 917353c

@laanwj laanwj merged commit 917353c into bitcoin:master Aug 28, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Aug 28, 2018

Merge #13723: PSBT key path cleanups
917353c Make SignPSBTInput operate on a private SignatureData object (Pieter Wuille)
cad5dd2 Pass HD path data through SignatureData (Pieter Wuille)
03a9958 Implement key origin lookup in CWallet (Pieter Wuille)
3b01efa [MOVEONLY] Move ParseHDKeypath to utilstrencodings (Pieter Wuille)
81e1dd5 Generalize PublicOnlySigningProvider into HidingSigningProvider (Pieter Wuille)
84f1f1b Make SigningProvider expose key origin information (Pieter Wuille)
611ab30 Introduce KeyOriginInfo for fingerprint + path (Pieter Wuille)

Pull request description:

  This PR adds "key origin" (master fingeprint + key path) information to what is exposed from `SigningProvider`s, allowing this information to be used by the generic PSBT code instead of having the RPC pull it directly from the wallet.

  This is also a preparation to having PSBT interact with output descriptors, which can then directly expose key origin information for the scripts they generate.

Tree-SHA512: c718382ba8ba2d6fc9a32c062bd4cff08b6f39b133838aa03115c39aeca0f654c7cc3ec72d87005bf8306e550824cd8eb9d60f0bd41784a3e22e17b2afcfe833

@MarcoFalke MarcoFalke removed this from Blockers in High-priority for review Aug 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.