Skip to content

Commit 84108f3

Browse files
committed
Make script::hash() return null_hash for invalid/default script.
1 parent 9ee09d3 commit 84108f3

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/chain/script.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ const operations& script::ops() const NOEXCEPT
471471
// Consensus (witness::extract_script) and Electrum server payments key.
472472
hash_digest script::hash() const NOEXCEPT
473473
{
474+
// A failed parse or default initialized script will hash to null_hash.
475+
if (!is_valid())
476+
return {};
477+
474478
hash_digest hash{};
475479
stream::out::fast stream{ hash };
476480
hash::sha256::fast sink(stream);

0 commit comments

Comments
 (0)