HomePhabricator

[bitcoin-tx]: Avoid treating overflow as OP_0

Description

[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

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D18473

Details

Provenance
MarcoFalke <falke.marco@gmail.com>Authored on Oct 5 2021, 11:34
tobias_ruckCommitted on Aug 11 2025, 21:12
tobias_ruckPushed on Aug 11 2025, 21:12
Reviewer
Restricted Project
Differential Revision
D18473: [bitcoin-tx]: Avoid treating overflow as OP_0
Parents
rABC8242e48b4c7e: [Cashtab] Add missing type to ChromeMessage interface
Branches
Unknown
Tags
Unknown