I’m going to code this up to confirm ergonomics - so mistakes are likely in this post. Call them out if you see them. Here is my understanding without actually writing the code yet
If we were to continue with CScriptNum
, as my OP_INOUT_AMOUNT
implementation works currently
- Read
int64_t
representing satoshis fromBaseTransactionSignatureChecker.GetTransactionData()
- Convert the
int64_t
into a minimally encodedCScriptNum
. I don’t think this necessarily has to be done by an op code, could be done in the impl ofOP_INOUT_AMOUNT
itself - Call
CScriptNum
constructor, modifying thenMaxNumSize
parameter to support 8 bytes. - Push
CScriptNum
onto stack - Wherever the satoshi value on the stack top is consumed by another op code, we need to figure out how to allow for
nMaxNumSize
to be 8 bytes.
As an example for step 5
, lets assume we are using THE OLD (pre-64bit) numeric op codes
You see we interpret the stack top as CScriptNum
, however that CScriptNum
has a nMaxNumSize=4
rather than 8 bytes. This leads to an overflow exception being thrown by CScriptNum
. This same problem applies to any opcode (another example is OP_WITHIN
) that uses CScriptNum
to interpret the stack top.