tiddlybit icon indicating copy to clipboard operation
tiddlybit copied to clipboard

Can't push INT to stack

Open Siko91 opened this issue 5 years ago • 6 comments

I am having problems when trying to push int to the stack. OpCode.byCode(integer) is undefined

image

Siko91 avatar Sep 22 '20 21:09 Siko91

Yes I don't think tiddlybit supports adding integers to the stack just by passing it as a number. Instead it attempts to get the relevant OPcode from the given number. This approach is what bsv.js@v1 did, although not sure if v2 does things differently.

As I understand it, integers are pushed on the stack using a varint encoding method, so for now you need to handle that encoding yourself and pass the buffer to the stack.

libitx avatar Oct 01 '20 13:10 libitx

Cool. But it's still a bug that the lookup of opcodes doesn't actually work. The method being called is undefined.

Siko91 avatar Oct 02 '20 20:10 Siko91

Oh right. I thought it was returning undefined because you were passing a number that wasn't an opcode byte number. I see now. Let me look in to that.

libitx avatar Oct 06 '20 18:10 libitx

What version are you on? I think this might be fixed in 0.0.6

libitx avatar Oct 06 '20 19:10 libitx

0.0.6 I just installed whatever was latest.

Is the problem not reproducible on your side?

Siko91 avatar Oct 06 '20 19:10 Siko91

Ah I see the issue now. The function OpCode.byCode() was renamed to OpCode.byByte(). The reason for my confusion is a I remember this came up before and was fixed, but I can see now that the function is used twice so I only fixed it in one of those places 😅

Apologies for the confusion - I'll sort this out over the weekend.

libitx avatar Oct 09 '20 15:10 libitx