MCPcopy Create free account
hub / github.com/bitcoin-sv/bitcoin-sv / encode

Method encode

test/functional/test_framework/script.py:636–649  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

634
635 @staticmethod
636 def encode(obj):
637 r = bytearray(0)
638 if obj.value == 0:
639 return bytes(r)
640 neg = obj.value < 0
641 absvalue = -obj.value if neg else obj.value
642 while (absvalue):
643 r.append(absvalue & 0xff)
644 absvalue >>= 8
645 if r[-1] & 0x80:
646 r.append(0x80 if neg else 0)
647 elif neg:
648 r[-1] |= 0x80
649 return bytes(bchr(len(r)) + r)
650
651
652class CScript(bytes):

Callers 15

hex_switchEndianFunction · 0.80
__init__Method · 0.80
hex_switchEndianFunction · 0.80
linearize-data.pyFile · 0.80
base58.pyFile · 0.80
mainFunction · 0.80
do_POSTMethod · 0.80
__init__Method · 0.80
do_POSTMethod · 0.80
datarefToScriptMethod · 0.80

Calls 2

bchrFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected