python-bitcoinlib icon indicating copy to clipboard operation
python-bitcoinlib copied to clipboard

OPCODES_BY_NAME missing OP_TRUE and OP_FALSE

Open kanzure opened this issue 5 years ago • 5 comments

I noticed that OP_TRUE and OP_FALSE aren't in OPCODES_BY_NAME. I am not sure if this is intentional. If it is intentional, then a comment should be added; and if it isn't, then they probably should.

OP_INVALIDOPCODE can probably stay out.

Context: I was parsing some strings like "OP_WHATEVER OP_TRUE" to convert to CScript objects, using OPCODES_BY_NAME as the lookup table.

kanzure avatar Jan 19 '20 21:01 kanzure

OP_1 and OP_0 are equivalent to OP_TRUE and OP_FALSE. This issue should be closed I believe. See https://en.bitcoin.it/wiki/Script

SachinMeier avatar Aug 11 '20 02:08 SachinMeier

Still useful for parsing scripts or converting from string to opcodes.

kanzure avatar Aug 11 '20 02:08 kanzure

Thank you. I'm writing a pull request now to add some more RPC calls. Would you recommend i add "OP_TRUE": OP_1 and likewise for OP_FALSE? Or is there more needed.

SachinMeier avatar Aug 11 '20 02:08 SachinMeier

Go ahead and add those. Sure. I seem to recall looking at a list and comparing against what's in the library, and only found these stragglers. But don't take my word for it... it's a while ago and don't have a copy in front of me.

kanzure avatar Aug 11 '20 03:08 kanzure

Just opened PR #242 which fixes this issue (among other additions)

SachinMeier avatar Aug 16 '20 07:08 SachinMeier