MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / __coerce_instance

Method __coerce_instance

bitcoin/core/script.py:514–527  ·  view source on GitHub ↗
(cls, other)

Source from the content-addressed store, hash-verified

512 """
513 @classmethod
514 def __coerce_instance(cls, other):
515 # Coerce other into bytes
516 if isinstance(other, CScriptOp):
517 other = bytes([other])
518 elif isinstance(other, int):
519 if 0 <= other <= 16:
520 other = bytes([CScriptOp.encode_op_n(other)])
521 elif other == -1:
522 other = bytes([OP_1NEGATE])
523 else:
524 other = CScriptOp.encode_op_pushdata(bitcoin.core._bignum.bn2vch(other))
525 elif isinstance(other, (bytes, bytearray)):
526 other = CScriptOp.encode_op_pushdata(other)
527 return other
528
529 def __add__(self, other):
530 # Do the coercion outside of the try block so that errors in it are

Callers 2

__add__Method · 0.95
coerce_iterableMethod · 0.80

Calls 2

encode_op_nMethod · 0.80
encode_op_pushdataMethod · 0.80

Tested by

no test coverage detected