Skip to content

Commit

Permalink
Merge pull request libbitcoin#830 from evoskuil/master
Browse files Browse the repository at this point in the history
Fix overconstrained is_sign_script_hash_pattern.
  • Loading branch information
evoskuil authored Nov 3, 2017
2 parents 75cd642 + c7a250d commit 0387f0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/chain/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 +690,6 @@ bool script::create_endorsement(endorsement& out, const ec_secret& secret,
// Utilities (static).
//-----------------------------------------------------------------------------

inline bool endorsed(const operation& op)
{
return is_endorsement(op.data());
};

bool script::is_push_only(const operation::list& ops)
{
const auto push = [](const operation& op)
Expand Down Expand Up @@ -821,7 +816,8 @@ bool script::is_sign_multisig_pattern(const operation::list& ops)
{
return ops.size() >= 2
&& ops[0].code() == opcode::push_size_0
&& std::all_of(ops.begin() + 1, ops.end(), endorsed);
&& std::all_of(ops.begin() + 1, ops.end(), [](const operation& op)
{ return is_endorsement(op.data()); });
}

bool script::is_sign_public_key_pattern(const operation::list& ops)
Expand All @@ -837,11 +833,12 @@ bool script::is_sign_key_hash_pattern(const operation::list& ops)
&& is_public_key(ops[1].data());
}

// Ambiguous with is_sign_key_hash when second/last op is a valid public key.
// Ambiguous with is_sign_key_hash when second/last op is a public key.
// Ambiguous with is_sign_public_key_pattern when only op is an endorsement.
bool script::is_sign_script_hash_pattern(const operation::list& ops)
{
return ops.size() > 1
&& std::all_of(ops.begin(), ops.end() - 1, endorsed)
return !ops.empty()
&& is_push_only(ops)
&& !ops.back().data().empty();
}

Expand Down
2 changes: 2 additions & 0 deletions src/wallet/payment_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ payment_address::list payment_address::extract_input(

// There is no address in sign_public_key script (signature only)
// and the public key cannot be extracted from the signature.
// Given lack of context (prevout) sign_public_key is always ambiguous
// with sign_script_hash (though actual conflict seems very unlikely).
// A server can obtain by extracting from the previous output.
case script_pattern::sign_public_key:

Expand Down

0 comments on commit 0387f0e

Please sign in to comment.