Skip to content

Commit ea89bed

Browse files
authored
Merge pull request #1768 from evoskuil/master
CONSENSUS: v1 subscripting ob1.
2 parents a7b8b98 + 7438280 commit ea89bed

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/chain/transaction_sighash_v1.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ namespace chain {
4141

4242
// static
4343
// Zero-based opcode position of the last executed op_codeseparator before
44-
// currently executed signature opcode (0xffffffff if none) [bip342].
44+
// currently executed signature opcode (0xffffffff if none) [bip342]. Previous
45+
// versions require the next opcode, but this requires the position. Since the
46+
// op_codeseparator implementation sets offset to next, it must be decremented.
4547
uint32_t transaction::subscript_v1(const script& script) NOEXCEPT
4648
{
4749
if (script.ops().empty())
4850
return chain::default_separators;
4951

50-
const auto start = script.ops().begin();
51-
const auto span = std::distance(start, script.offset);
52-
const auto slot = possible_narrow_and_sign_cast<uint32_t>(span);
53-
const auto none = is_zero(slot) && start->code() != opcode::codeseparator;
54-
return none ? chain::default_separators : slot;
52+
const auto next = std::distance(script.ops().begin(), script.offset);
53+
return is_zero(next) ? chain::default_separators :
54+
possible_narrow_and_sign_cast<uint32_t>(sub1(next));
5555
}
5656

5757
// ext_flags and annex flag are combined into one byte, who knows why.

0 commit comments

Comments
 (0)