MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / decode

Method decode

test/functional/test_framework/script.py:412–425  ·  view source on GitHub ↗
(vch)

Source from the content-addressed store, hash-verified

410
411 @staticmethod
412 def decode(vch):
413 result = 0
414 # We assume valid push_size and minimal encoding
415 value = vch[1:]
416 if len(value) == 0:
417 return result
418 for i, byte in enumerate(value):
419 result |= int(byte) << 8 * i
420 if value[-1] >= 0x80:
421 # Mask for all but the highest result bit
422 num_mask = (2**(len(value) * 8) - 1) >> 1
423 result &= num_mask
424 result *= -1
425 return result
426
427
428class CScript(bytes):

Callers 15

set_hostFunction · 0.45
test_rest_requestMethod · 0.45
run_testMethod · 0.45
get_block_partMethod · 0.45
test_oversized_msgMethod · 0.45
removed_testMethod · 0.45
rejected_testMethod · 0.45
get_tracepointsMethod · 0.45

Calls 1

enumerateFunction · 0.50