Merge #17371: Refactor: Require scriptPubKey to get wallet SigningProvider

d0dab897af Refactor: Require scriptPubKey to get wallet SigningProvider (Andrew Chow)
4b0c718f8f Accumulate result UniValue in SignTransaction (Andrew Chow)

Pull request description:

  Easier to review ignoring whitespace:

      git log -p -n1 -w

  This commit does not change behavior. It passes new CScript arguments to
  signing functions, but the arguments aren't currently used.

  Split from #17261

ACKs for top commit:
  instagibbs:
    utACK d0dab897af
  ryanofsky:
    Code review ACK d0dab897af. Thanks for the SignTransaction update. No other changes since last review
  Sjors:
    Code review ACK d0dab897af
  promag:
    Code review ACK d0dab897af.
  meshcollider:
    Code review ACK d0dab897af

Tree-SHA512: c3f52df20fd9d6b3b5aa65562cf5f7dce7b7f44c148b0f988f8b578fce2a28e9b7bf010f5f04bb5bf60f5272b2899f1dbbfb8aee81579c21c9cba559d1d2bb70
This commit is contained in:
Samuel Dobson
2019-11-23 08:33:38 +13:00
11 changed files with 137 additions and 57 deletions

View File

@@ -116,8 +116,22 @@ public:
std::string error;
return m_wallet->GetNewDestination(type, label, dest, error);
}
bool getPubKey(const CKeyID& address, CPubKey& pub_key) override { return m_wallet->GetLegacyScriptPubKeyMan()->GetPubKey(address, pub_key); }
bool getPrivKey(const CKeyID& address, CKey& key) override { return m_wallet->GetLegacyScriptPubKeyMan()->GetKey(address, key); }
bool getPubKey(const CScript& script, const CKeyID& address, CPubKey& pub_key) override
{
const SigningProvider* provider = m_wallet->GetSigningProvider(script);
if (provider) {
return provider->GetPubKey(address, pub_key);
}
return false;
}
bool getPrivKey(const CScript& script, const CKeyID& address, CKey& key) override
{
const SigningProvider* provider = m_wallet->GetSigningProvider(script);
if (provider) {
return provider->GetKey(address, key);
}
return false;
}
bool isSpendable(const CTxDestination& dest) override { return m_wallet->IsMine(dest) & ISMINE_SPENDABLE; }
bool haveWatchOnly() override
{

View File

@@ -81,10 +81,10 @@ public:
virtual bool getNewDestination(const OutputType type, const std::string label, CTxDestination& dest) = 0;
//! Get public key.
virtual bool getPubKey(const CKeyID& address, CPubKey& pub_key) = 0;
virtual bool getPubKey(const CScript& script, const CKeyID& address, CPubKey& pub_key) = 0;
//! Get private key.
virtual bool getPrivKey(const CKeyID& address, CKey& key) = 0;
virtual bool getPrivKey(const CScript& script, const CKeyID& address, CKey& key) = 0;
//! Return whether wallet has private key.
virtual bool isSpendable(const CTxDestination& dest) = 0;