}
-def decode_raw_tx(raw_tx_str):
- tx_input = {
- "address": "",
- "amount": 0,
- "asset_definition": {},
- "asset_id": "",
- "control_program": "",
- "input_id": "",
- "spend_output_id": "",
- "type": "",
- "witness_arguments": []
- }
- tx_output = {
- "address": "",
- "amount": 0,
- "asset_definition": {},
- "asset_id": "",
- "control_program": "",
- "id": "",
- "position": 0,
- "type": ""
- }
- tx = {
- "fee": 0,
- "inputs": [],
- "outputs": [],
- "size": 0,
- "time_range": 0,
- "tx_id": "",
- "version": 0
- }
- version = int(raw_tx_str[2:4], 16)
- time_range = int(raw_tx_str[4:6], 16)
- tx_input_amount = int(raw_tx_str[6:8], 16)
- tx_input_version = int(raw_tx_str[8:10], 16)
- tx_input_length = int(raw_tx_str[10:12], 16)
- tx_input_type = int(raw_tx_str[12:14], 16)
- tx_input_data_spend_commit_length = int(raw_tx_str[14:16], 16)
- tx_input_source_id = raw_tx_str[16:80]
- tx_input_asset_id = raw_tx_str[80:144]
+def get_uvarint(uvarint_str):
+ uvarint_bytes = bytes.fromhex(uvarint_str)
+ x, s, i = 0, 0, 0
+ while True:
+ b = uvarint_bytes[i]
+ if b < 0x80:
+ if i > 9 or i == 9 and b > 1:
+ return "overflow"
+ return x | int(b) << s, i + 1
+ x |= int(b & 0x7f) << s
+ s += 7
+ i += 1
+
+
+# def decode_raw_tx(raw_tx_str):
+# tx_input = {
+# "address": "",
+# "amount": 0,
+# "asset_definition": {},
+# "asset_id": "",
+# "control_program": "",
+# "input_id": "",
+# "spend_output_id": "",
+# "type": "",
+# "witness_arguments": []
+# }
+# tx_output = {
+# "address": "",
+# "amount": 0,
+# "asset_definition": {},
+# "asset_id": "",
+# "control_program": "",
+# "id": "",
+# "position": 0,
+# "type": ""
+# }
+# tx = {
+# "fee": 0,
+# "inputs": [],
+# "outputs": [],
+# "size": 0,
+# "time_range": 0,
+# "tx_id": "",
+# "version": 0
+# }
+# version = int(raw_tx_str[2:4], 16)
+# time_range = int(raw_tx_str[4:6], 16)
+# tx_input_amount = int(raw_tx_str[6:8], 16)
+# tx_input_version = int(raw_tx_str[8:10], 16)
+# tx_input_length = int(raw_tx_str[10:12], 16)
+# tx_input_type = int(raw_tx_str[12:14], 16)
+# tx_input_data_spend_commit_length = int(raw_tx_str[14:16], 16)
+# tx_input_source_id = raw_tx_str[16:80]
+# tx_input_asset_id = raw_tx_str[80:144]
- # for i in range(tx_input_amount):
+# # for i in range(tx_input_amount):
- return tx
+# return tx