File tree Expand file tree Collapse file tree 5 files changed +151
-2
lines changed Expand file tree Collapse file tree 5 files changed +151
-2
lines changed Original file line number Diff line number Diff line change 1
1
import requests
2
2
import json
3
3
import time
4
+ import leb128
4
5
5
6
node_url = '127.0.0.1' #'71.198.63.116'#'199.188.192.144'#
6
7
node_port = '8332'
@@ -31,7 +32,7 @@ def tx_lookup(txhash):
31
32
c = connect ('getrawtransaction' ,[txhash ,1 ])
32
33
return c
33
34
34
- def tx_inputs (txhash ):
35
+ def tx_inputs (txhash , dest_address ):
35
36
txdata = tx_lookup (txhash )
36
37
37
38
global prevtxids
@@ -58,6 +59,7 @@ def tx_inputs(txhash):
58
59
f = {}
59
60
f ['address' ]= address
60
61
f ['amount' ]= amount
62
+ f ['txid' ]= a [0 ]
61
63
answer ['inputs' ].append (f )
62
64
else :
63
65
answer ['block' ]= prevtxids [0 ]
@@ -106,10 +108,21 @@ def op_return_in_block(n):
106
108
for tx in txhashes :
107
109
m = read_tx (tx )
108
110
if not m == - 1 :
109
- messages .append (read_tx (tx ))
111
+ messages .append ([ tx , read_tx (tx )] )
110
112
return messages
111
113
114
+ def parse_colored_tx (metadata ):
115
+ hexmetadata = metadata .encode ('hex' )
116
+ opcode = metadata [0 :2 ]
117
+ if opcode == 'OA' : #then OA
118
+ version_number = metadata [2 :4 ].encode ('hex' )
119
+ quantity_count = metadata [4 :5 ].encode ('hex' )
120
+
121
+
122
+
123
+
112
124
113
125
t = 'fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4'
114
126
tt = '38bddbe81111a6209f87eb59d6a6ac019d07a4d90dcc2f361b6a81eb1bafdb89'
115
127
mt = '3a14926cd9a77d7e11de98437743404aefc642db262e4ba4721354b1b2221bea'
128
+ q = 'f4b0784b089b766df0642e67918646df09e946f470c524817b3873a82651a02c'
Original file line number Diff line number Diff line change
1
+ def int_to_binary (n ):
2
+ r = ''
3
+ while n > 0 :
4
+ f = n % 2
5
+ r = str (f )+ r
6
+ n = n - f
7
+ n = n / 2
8
+ return r
9
+
10
+ #SEPARATE INTEGER INTO BINARY BATCHES of 7
11
+ def make_batches (n ):
12
+ b = int_to_binary (n )
13
+ g = len (b )% 7
14
+ g = 7 - g
15
+ for i in range (0 ,g ):
16
+ b = '0' + str (b )
17
+
18
+ output = []
19
+
20
+ while len (b )> 0 :
21
+ r = ''
22
+ for i in range (0 ,7 ):
23
+ r = r + b [i ]
24
+ output .append (r )
25
+ if len (b )> 7 :
26
+ b = b [7 :len (b )]
27
+ else :
28
+ b = ''
29
+
30
+ return output
31
+
32
+ #Add zeros and ones to binary batches of 7 (to make batches of 8)
33
+ def addzeros (n ):
34
+ b = make_batches (n )
35
+ output = []
36
+ a = b [0 ]
37
+ a = '0' + a
38
+ output .append (a )
39
+ g = 1
40
+ while g < len (b ):
41
+ r = b [g ]
42
+ r = '1' + r
43
+ output .append (r )
44
+ g = g + 1
45
+ return output
46
+
47
+ #integer to binary set
48
+ def encode (n ):
49
+ a = addzeros (n )
50
+ a .reverse ()
51
+ return a
52
+
53
+ #integer to hex set
54
+ def hexencode (n ):
55
+ a = encode (n )
56
+ g = ''
57
+ for x in a :
58
+ r = hex (int (x ,2 ))
59
+ if len (r )== 3 :
60
+ q = r [0 :2 ]
61
+ q = q + '0' + r [2 ]
62
+ r = q
63
+ g = g + r
64
+ return g
65
+
66
+
67
+ def decode (n ):
68
+ a = ''
69
+ for x in n :
70
+ r = x [1 :len (x )]
71
+ a = r + a
72
+ return int (a ,2 )
73
+
74
+ def hexpiecetobinary (hex ):
75
+ print hex
76
+ a = bin (int (hex ,16 ))
77
+ #a=a[2:len(a)]
78
+ g = 8 - len (a )
79
+ for i in range (0 ,g ):
80
+ a = '0' + a
81
+ return a
82
+
83
+ def hexdecode (n ):
84
+ a = []
85
+ while len (n )> 0 :
86
+ r = n [0 :4 ]
87
+ a .append (hexpiecetobinary (r ))
88
+ n = n [4 :len (n )]
89
+ #print a
90
+ return decode (a )
91
+
92
+
93
+ def hexdecodeline (n ):
94
+ r = 0
95
+ a = []
96
+ b = []
97
+ while r < len (n ):
98
+ if r % 2 == 0 and r > 0 :
99
+ a .append (b )
100
+ b = []
101
+ b .append (n [r ])
102
+ r = r + 1
103
+
104
+ d = []
105
+ for x in a :
106
+ d .append (hexpiecetobinary (x ))
107
+ return d
108
+
109
+ def hexdecodeset (n ):
110
+ a = []
111
+ global a ,b ,c ,r
112
+ r = ''
113
+ while len (n )> 0 :
114
+ go = True
115
+ while go :
116
+
117
+ r = r + n [0 ]
118
+ n = n [1 :len (n )]
119
+
120
+ r = n [0 :4 ]
121
+ a .append (hexpiecetobinary (r ))
122
+ n = n [4 :len (n )]
123
+ print a
124
+ b = []
125
+ r = []
126
+ ok = True
127
+ for x in a :
128
+ r .append (x )
129
+ if x [0 ]== '0' :
130
+ b .append (r )
131
+ r = []
132
+
133
+ c = []
134
+ for x in b :
135
+ c .append (decode (x ))
136
+ return c
You can’t perform that action at this time.
0 commit comments