Page MenuHomePhabricator

[Chronik] Add `Script::iter_ops` and `ScriptOpIter`
ClosedPublic

Authored by tobias_ruck on Apr 26 2023, 14:38.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC007abbfe3a93: [Chronik] Add `Script::iter_ops` and `ScriptOpIter`
Summary

Iterates over the operations in a Script. This can either be a single opcode, or an opcode which pushes some data following it in the bytecode.

This is important for parsing scripts, e.g. for SLP.

Test Plan

ninja check-crates

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

chronik/bitcoinsuite-core/src/script/iter.rs
36 ↗(On Diff #39975)

You probably should return an error here. AFAICT this could occur of parsing a push with not enough data remaining, in which case you get a truncated result and it's invalid anyway

make ScriptOpIter::next code more readable

This revision is now accepted and ready to land.Apr 28 2023, 12:16