HomePhabricator

[64-bit ints] Change `CScriptNum::getint` to return `int64_t`

Description

[64-bit ints] Change CScriptNum::getint to return int64_t

Summary:
As part of the effort to upgrade Script integers to 64-bits, we upgrade the code to handle CScriptNum::getint to return int64_t.

There's only a few usages of that function anyway:

  • In core_write.cpp, to write script assembly, and tinyformat can handle int64_t for %d
  • In interpreter.cpp, to convert to integers (e.g. for OP_ROLL). Here we're just careful to avoid overflows.
  • In scriptnum_tests.cpp, to compare to ScriptNum10. This test is now remarkably outdated (almost 9 years, looking at the copyright?), and doesn't really test something we worry about anymore. Instead, we remove CScriptNum10 and change the tests to actually test the behavior of CScriptNum.

(NB: BCH added getint32 and getint64 for the same change, but this is unnecessary and it's cleaner to just stick to one function)

Depends on D17290.

Test Plan: ninja check

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

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

Details

Provenance
tobias_ruckAuthored on Wed, Dec 4, 23:00
tobias_ruckPushed on Thu, Dec 5, 23:56
Reviewer
Restricted Project
Differential Revision
D16996: [64-bit ints] Change `CScriptNum::getint` to return `int64_t`
Parents
rABCf67fd8dd5fd8: [64-bit ints] Add script_tests for `getint` coverage
Branches
Unknown
Tags
Unknown