Skip to content

Conversation

achow101
Copy link
Member

@achow101 achow101 commented Nov 4, 2019

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

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 4, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #17369 (Refactor: Move encryption code between KeyMan and Wallet by achow101)
  • #17283 (rpc: improve getaddressinfo test coverage, help, code docs by jonatack)
  • #17211 (Allow fundrawtransaction and walletcreatefundedpsbt to take external inputs by achow101)
  • #12911 (wallet: Show fee in results for signrawtransaction* for segwit inputs by kallewoof)

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.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK f7510c1. Pretty straightforward to verify this doesn't change behavior.

@@ -550,7 +550,11 @@ static UniValue signmessage(const JSONRPCRequest& request)
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
}

const SigningProvider* provider = pwallet->GetSigningProvider();
CScript script_pub_key = GetScriptForDestination(*pkhash);
Copy link
Contributor

Choose a reason for hiding this comment

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

In commit "Refactor: Require scriptPubKey to get wallet SigningProvider" (f7510c1)

It would seem more direct to replace *pkhash with dest here and call GetScriptForDestination(dest)

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it really matters as we still need pkhash since signmessage is supposed to only work on p2pkh addresses.

Copy link
Member

Choose a reason for hiding this comment

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

we still need pkhash since signmessage is supposed to only work on p2pkh addresses

That will change in https://github.com/bitcoin/bitcoin/pull/16440/files#diff-df7d84ff2f53fcb2a0dc15a3a51e55ceR559

SignTransaction will be called multiple times in the future. Pass
it a result UniValue so that it can accumulate the results of multiple
SignTransaction passes.
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.
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK d0dab89. Thanks for the SignTransaction update. No other changes since last review

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

Code review ACK d0dab89

@@ -550,7 +550,11 @@ static UniValue signmessage(const JSONRPCRequest& request)
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
}

const SigningProvider* provider = pwallet->GetSigningProvider();
CScript script_pub_key = GetScriptForDestination(*pkhash);
Copy link
Member

Choose a reason for hiding this comment

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

we still need pkhash since signmessage is supposed to only work on p2pkh addresses

That will change in https://github.com/bitcoin/bitcoin/pull/16440/files#diff-df7d84ff2f53fcb2a0dc15a3a51e55ceR559

@ryanofsky
Copy link
Contributor

@instagibbs and @meshcollider, you may be interested to review this. This is code you previously acked when it was part of #16341

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Code review ACK d0dab89.

*/
UniValue SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType);
void SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType, UniValue& result);
Copy link
Contributor

Choose a reason for hiding this comment

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

4b0c718

An overload could be added, like

UniValue SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType)
{
    UniValue result(UniValue::VOBJ);
    SignTransaction(mtx, &keystore, coins, hashType, result);
    return result;
}

But I see that in the next commit this refactor is handy in signrawtransactionwithwallet RPC.

@@ -117,8 +117,22 @@ class WalletImpl : public Wallet
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
Copy link
Member

Choose a reason for hiding this comment

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

note for future work(TM): address is a horrible name for this argument

@@ -2096,7 +2100,7 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<
continue;
}

const SigningProvider* provider = GetSigningProvider();
const SigningProvider* provider = GetSigningProvider(wtx.tx->vout[i].scriptPubKey);
Copy link
Member

@instagibbs instagibbs Nov 22, 2019

Choose a reason for hiding this comment

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

do we need to check for knowledge of provider here?

Copy link
Member

Choose a reason for hiding this comment

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

oh i cannot read.

providers.insert(std::move(provider));
}
}
if (providers.size() == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

non-blocking-nit: .empty()

Copy link
Member Author

Choose a reason for hiding this comment

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

Not fixing to avoid invalidating ACKs.

@instagibbs
Copy link
Member

utACK d0dab89

@instagibbs
Copy link
Member

ready for merge? @meshcollider

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

Code review ACK d0dab89

{
const SigningProvider* provider = m_wallet->GetSigningProvider(script);
if (provider) {
return provider->GetPubKey(address, pub_key);
Copy link
Contributor

Choose a reason for hiding this comment

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

Its kinda not that nice that there is no check the script and address have anything to do with each other. You could end up requesting the wrong SPKM for an address quite easily. Maybe move some of the ExtractDestination stuff inside here instead?

const SigningProvider* provider = GetSigningProvider();
const SigningProvider* provider = GetSigningProvider(scriptPubKey);
if (!provider) {
// We don't know about this scriptpbuKey;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo (same below)

@@ -2971,8 +2977,11 @@ static UniValue listunspent(const JSONRPCRequest& request)
entry.pushKV("spendable", out.fSpendable);
entry.pushKV("solvable", out.fSolvable);
if (out.fSolvable) {
auto descriptor = InferDescriptor(scriptPubKey, *pwallet->GetLegacyScriptPubKeyMan());
entry.pushKV("desc", descriptor->ToString());
const SigningProvider* provider = pwallet->GetSigningProvider(scriptPubKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

This can probably be combined with above to simplify

meshcollider added a commit that referenced this pull request Nov 22, 2019
…vider

d0dab89 Refactor: Require scriptPubKey to get wallet SigningProvider (Andrew Chow)
4b0c718 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 d0dab89
  ryanofsky:
    Code review ACK d0dab89. Thanks for the SignTransaction update. No other changes since last review
  Sjors:
    Code review ACK d0dab89
  promag:
    Code review ACK d0dab89.
  meshcollider:
    Code review ACK d0dab89

Tree-SHA512: c3f52df20fd9d6b3b5aa65562cf5f7dce7b7f44c148b0f988f8b578fce2a28e9b7bf010f5f04bb5bf60f5272b2899f1dbbfb8aee81579c21c9cba559d1d2bb70
@meshcollider meshcollider merged commit d0dab89 into bitcoin:master Nov 22, 2019
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 22, 2019
…ningProvider

d0dab89 Refactor: Require scriptPubKey to get wallet SigningProvider (Andrew Chow)
4b0c718 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 bitcoin#17261

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

Tree-SHA512: c3f52df20fd9d6b3b5aa65562cf5f7dce7b7f44c148b0f988f8b578fce2a28e9b7bf010f5f04bb5bf60f5272b2899f1dbbfb8aee81579c21c9cba559d1d2bb70
laanwj added a commit that referenced this pull request Feb 10, 2020
… within bounds

f5fb7fc psbt: check output index is within bounds before accessing (Andrew Chow)
1cf77a2 Don't calculate tx fees for PSBTs with invalid money values (Andrew Chow)

Pull request description:

  Backport of #17156, non-trivial due to crossing the refactor in #17371

ACKs for top commit:
  laanwj:
    ACK f5fb7fc

Tree-SHA512: 7aabf9a6b8a8e287a26dfbf73a437a3bc55177bef8fc5149d822ef81b8ef2458e1d718c3a19c73532c5cef0f9bd8144574c7fad90ca89f13a08b44edf3a2656d
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 30, 2020
Summary:
SignTransaction will be called multiple times in the future. Pass
it a result UniValue so that it can accumulate the results of multiple
SignTransaction passes.

---

bitcoin/bitcoin@4b0c718

Partial backport of Core [[bitcoin/bitcoin#17371 | PR17371]]

Test Plan:
  ninja check check-functional

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D7686
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 30, 2020
…ningProvider

Summary:
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.

---

bitcoin/bitcoin@d0dab89

Depends on D7686

Concludes backport of Core [[bitcoin/bitcoin#17371 | PR17371]]

Test Plan:
  ninja check check-functional

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D7687
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
…ningProvider

d0dab89 Refactor: Require scriptPubKey to get wallet SigningProvider (Andrew Chow)
4b0c718 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 bitcoin#17261

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

Tree-SHA512: c3f52df20fd9d6b3b5aa65562cf5f7dce7b7f44c148b0f988f8b578fce2a28e9b7bf010f5f04bb5bf60f5272b2899f1dbbfb8aee81579c21c9cba559d1d2bb70
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Dec 9, 2021
…nts are within bounds

f5fb7fc psbt: check output index is within bounds before accessing (Andrew Chow)
1cf77a2 Don't calculate tx fees for PSBTs with invalid money values (Andrew Chow)

Pull request description:

  Backport of bitcoin#17156, non-trivial due to crossing the refactor in bitcoin#17371

ACKs for top commit:
  laanwj:
    ACK f5fb7fc

Tree-SHA512: 7aabf9a6b8a8e287a26dfbf73a437a3bc55177bef8fc5149d822ef81b8ef2458e1d718c3a19c73532c5cef0f9bd8144574c7fad90ca89f13a08b44edf3a2656d
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Dec 9, 2021
…nts are within bounds

f5fb7fc psbt: check output index is within bounds before accessing (Andrew Chow)
1cf77a2 Don't calculate tx fees for PSBTs with invalid money values (Andrew Chow)

Pull request description:

  Backport of bitcoin#17156, non-trivial due to crossing the refactor in bitcoin#17371

ACKs for top commit:
  laanwj:
    ACK f5fb7fc

Tree-SHA512: 7aabf9a6b8a8e287a26dfbf73a437a3bc55177bef8fc5149d822ef81b8ef2458e1d718c3a19c73532c5cef0f9bd8144574c7fad90ca89f13a08b44edf3a2656d
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Dec 9, 2021
…nts are within bounds

f5fb7fc psbt: check output index is within bounds before accessing (Andrew Chow)
1cf77a2 Don't calculate tx fees for PSBTs with invalid money values (Andrew Chow)

Pull request description:

  Backport of bitcoin#17156, non-trivial due to crossing the refactor in bitcoin#17371

ACKs for top commit:
  laanwj:
    ACK f5fb7fc

Tree-SHA512: 7aabf9a6b8a8e287a26dfbf73a437a3bc55177bef8fc5149d822ef81b8ef2458e1d718c3a19c73532c5cef0f9bd8144574c7fad90ca89f13a08b44edf3a2656d
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Dec 9, 2021
…nts are within bounds

f5fb7fc psbt: check output index is within bounds before accessing (Andrew Chow)
1cf77a2 Don't calculate tx fees for PSBTs with invalid money values (Andrew Chow)

Pull request description:

  Backport of bitcoin#17156, non-trivial due to crossing the refactor in bitcoin#17371

ACKs for top commit:
  laanwj:
    ACK f5fb7fc

Tree-SHA512: 7aabf9a6b8a8e287a26dfbf73a437a3bc55177bef8fc5149d822ef81b8ef2458e1d718c3a19c73532c5cef0f9bd8144574c7fad90ca89f13a08b44edf3a2656d
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Dec 9, 2021
…and amounts are within bounds

f5fb7fc psbt: check output index is within bounds before accessing (Andrew Chow)
1cf77a2 Don't calculate tx fees for PSBTs with invalid money values (Andrew Chow)

Pull request description:

  Backport of bitcoin#17156, non-trivial due to crossing the refactor in bitcoin#17371

ACKs for top commit:
  laanwj:
    ACK f5fb7fc

Tree-SHA512: 7aabf9a6b8a8e287a26dfbf73a437a3bc55177bef8fc5149d822ef81b8ef2458e1d718c3a19c73532c5cef0f9bd8144574c7fad90ca89f13a08b44edf3a2656d
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Dec 9, 2021
…and amounts are within bounds

f5fb7fc psbt: check output index is within bounds before accessing (Andrew Chow)
1cf77a2 Don't calculate tx fees for PSBTs with invalid money values (Andrew Chow)

Pull request description:

  Backport of bitcoin#17156, non-trivial due to crossing the refactor in bitcoin#17371

ACKs for top commit:
  laanwj:
    ACK f5fb7fc

Tree-SHA512: 7aabf9a6b8a8e287a26dfbf73a437a3bc55177bef8fc5149d822ef81b8ef2458e1d718c3a19c73532c5cef0f9bd8144574c7fad90ca89f13a08b44edf3a2656d
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants