output serialize
This commit is contained in:
parent
5eba8bb1c0
commit
b58a7a6de3
@ -213,6 +213,11 @@ class Output:
|
|||||||
self.value = value
|
self.value = value
|
||||||
self.pk_script = Script(script)
|
self.pk_script = Script(script)
|
||||||
|
|
||||||
|
def serialize(self):
|
||||||
|
return i.value.to_bytes(8,'little') \
|
||||||
|
+ to_var_int(len(self.pk_script.raw)) + self.pk_script.raw
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def deserialize(cls, stream):
|
def deserialize(cls, stream):
|
||||||
stream = get_stream(stream)
|
stream = get_stream(stream)
|
||||||
@ -423,17 +428,9 @@ class Transaction():
|
|||||||
def serialize(self, segwit = True, hex = False):
|
def serialize(self, segwit = True, hex = False):
|
||||||
version = self.version.to_bytes(4,'little')
|
version = self.version.to_bytes(4,'little')
|
||||||
ninputs = to_var_int(self.tx_in_count)
|
ninputs = to_var_int(self.tx_in_count)
|
||||||
inputs = []
|
inputs = [i.serialize() for i in self.tx_in]
|
||||||
for i in self.tx_in:
|
nouts = to_var_int(len(self.tx_out))
|
||||||
# input = i.outpoint[0]+i.outpoint[1].to_bytes(4,'little')
|
outputs = [o.serialize() for o in self.tx_out]
|
||||||
# input += to_var_int(len(i.sig_script.raw)) + i.sig_script.raw
|
|
||||||
# input += i.sequence.to_bytes(4,'little')
|
|
||||||
inputs.append(i.serialize())
|
|
||||||
nouts = to_var_int(self.tx_out_count)
|
|
||||||
outputs = []
|
|
||||||
for number, i in enumerate(self.tx_out):
|
|
||||||
a = i.pk_script.raw
|
|
||||||
outputs.append(i.value.to_bytes(8,'little')+to_var_int(len(a))+a)
|
|
||||||
marke_flag = b"\x00\x01" if segwit else b""
|
marke_flag = b"\x00\x01" if segwit else b""
|
||||||
witness = b""
|
witness = b""
|
||||||
if segwit:
|
if segwit:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user