Page MenuHomePhabricator

[bitcoin-tx]: Avoid treating overflow as OP_0
ClosedPublic

Authored by tobias_ruck on Aug 11 2025, 13:48.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCd7c68bc4c581: [bitcoin-tx]: Avoid treating overflow as OP_0
Summary

atoi and LocaleIndependentAtoi return 0 if the number couldn't be parsed. This is very unintuitive and potentially dangerous, a script like 11111111111111111111 OP_GREATERTHAN would be identical to 0 OP_GREATERTHAN.

Therefore, use ToIntegral, which returns an std::optional, which we can check for, or otherwise throw a runtime error.

Backport from core#23227.

Depends on D18472.

Test Plan

ninja check

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Aug 11 2025, 15:57