MCPcopy Create free account
hub / github.com/ElementsProject/elements / encode

Method encode

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

Source from the content-addressed store, hash-verified

477
478 @staticmethod
479 def encode(obj):
480 val = obj.value
481 r = bytearray(0)
482 if val == 0:
483 return bytes(r)
484 neg = val < 0
485 absvalue = -val if neg else val
486 while (absvalue):
487 r.append(absvalue & 0xff)
488 absvalue >>= 8
489 if r[-1] & 0x80:
490 r.append(0x80 if neg else 0)
491 elif neg:
492 r[-1] |= 0x80
493 return bytes([len(r)]) + r
494
495 @staticmethod
496 def decode(vch):

Callers 15

hex_switchEndianFunction · 0.45
__init__Method · 0.45
hex_switchEndianFunction · 0.45
base58.pyFile · 0.45
tree_sha512sumFunction · 0.45
__init__Method · 0.45
__call__Method · 0.45
_batchMethod · 0.45
run_testMethod · 0.45
run_testMethod · 0.45
run_testMethod · 0.45

Calls

no outgoing calls

Tested by 2