Exemplo n.º 1
0
 def pop_short_channel_id(byte_string):
     if not len(byte_string) >= 8:
         return None, None, "underrun while popping short_channel_id"
     block_height = b2i(byte_string[:3])
     tx_index = b2i(byte_string[3:6])
     output_index = b2i(byte_string[6:8])
     formatted = "%dx%dx%d" % (block_height, tx_index, output_index)
     return formatted, byte_string[8:], None
Exemplo n.º 2
0
 def peek_64(byte_string):
     if len(byte_string) < 8:
         return None, "underrun while peeking a uint64"
     val = b2i(byte_string[0:8])
     if val < 0x100000000:
         return None, "not a minimally encoded uint64"
     return val, None
Exemplo n.º 3
0
 def peek_32(byte_string):
     if len(byte_string) < 4:
         return None, "underrun while peeking a uint32"
     val = b2i(byte_string[0:4])
     if val < 0x10000:
         return None, "not a minimally encoded uint32"
     return val, None
Exemplo n.º 4
0
 def peek_16(byte_string):
     if len(byte_string) < 2:
         return None, "underrun while peeking a uint16"
     val = b2i(byte_string[0:2])
     if val < 0xfd:
         return None, "not a minimally encoded unit16"
     return val, None
Exemplo n.º 5
0
 def pop_tu64(n_bytes, byte_string):
     if n_bytes > 8:
         return None, None, "cannot pop more than 8 bytes for a tu64"
     if len(byte_string) < n_bytes:
         return None, None, "underrun while popping tu62"
     if n_bytes == 0:
         return 0, byte_string, None
     val = b2i(byte_string[:n_bytes])
     if n_bytes != Namespace.minimal_tu_bytes(val):
         return None, None, "not minimal encoding for value"
     return val, byte_string[n_bytes:], None
Exemplo n.º 6
0
 def pop_u64(byte_string):
     if len(byte_string) < 8:
         return None, None, "underrun while popping a u64"
     return b2i(byte_string[:8]), byte_string[8:], None
Exemplo n.º 7
0
 def pop_u32(byte_string):
     if len(byte_string) < 4:
         return None, None, "underrun while popping a u32"
     return b2i(byte_string[:4]), byte_string[4:], None
Exemplo n.º 8
0
 def pop_u16(byte_string):
     if len(byte_string) < 2:
         return None, None, "underrun while popping a u16"
     return b2i(byte_string[:2]), byte_string[2:], None
Exemplo n.º 9
0
 def pop_u8(byte_string):
     if len(byte_string) < 1:
         return None, None, "underrun while popping a u8"
     return b2i(byte_string[:1]), byte_string[1:], None
Exemplo n.º 10
0
 def peek_8(byte_string):
     if len(byte_string) < 1:
         return None, "underrun while peeking a uint8"
     return b2i(byte_string[0:1]), None