Renaming everything from FloData to txcomment
This commit is contained in:
parent
6a2d2fbc3d
commit
4b1b6e3adf
@ -607,9 +607,9 @@ def deserialize(raw: str, force_full_parse=False) -> dict:
|
|||||||
parse_witness(vds, txin, full_parse=full_parse)
|
parse_witness(vds, txin, full_parse=full_parse)
|
||||||
d['lockTime'] = vds.read_uint32()
|
d['lockTime'] = vds.read_uint32()
|
||||||
if d['version'] >= 2:
|
if d['version'] >= 2:
|
||||||
d['txcomment'] = vds.read_string()
|
d['flodata'] = vds.read_string()
|
||||||
else:
|
else:
|
||||||
d['txcomment'] = ""
|
d['flodata'] = ""
|
||||||
if vds.can_read_more():
|
if vds.can_read_more():
|
||||||
raise SerializationError('extra junk at the end')
|
raise SerializationError('extra junk at the end')
|
||||||
return d
|
return d
|
||||||
@ -650,7 +650,7 @@ class Transaction:
|
|||||||
self._inputs = None
|
self._inputs = None
|
||||||
self._outputs = None
|
self._outputs = None
|
||||||
self.locktime = 0
|
self.locktime = 0
|
||||||
self.txcomment = ""
|
self.flodata = ""
|
||||||
self.version = 1
|
self.version = 1
|
||||||
# by default we assume this is a partial txn;
|
# by default we assume this is a partial txn;
|
||||||
# this value will get properly set when deserializing
|
# this value will get properly set when deserializing
|
||||||
@ -743,18 +743,18 @@ class Transaction:
|
|||||||
self._outputs = [TxOutput(x['type'], x['address'], x['value']) for x in d['outputs']]
|
self._outputs = [TxOutput(x['type'], x['address'], x['value']) for x in d['outputs']]
|
||||||
self.locktime = d['lockTime']
|
self.locktime = d['lockTime']
|
||||||
self.version = d['version']
|
self.version = d['version']
|
||||||
self.txcomment = d['txcomment']
|
self.flodata = d['flodata']
|
||||||
self.is_partial_originally = d['partial']
|
self.is_partial_originally = d['partial']
|
||||||
self._segwit_ser = d['segwit_ser']
|
self._segwit_ser = d['segwit_ser']
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_io(klass, inputs, outputs, locktime=0, txcomment=""):
|
def from_io(klass, inputs, outputs, locktime=0, flodata=""):
|
||||||
self = klass(None)
|
self = klass(None)
|
||||||
self._inputs = inputs
|
self._inputs = inputs
|
||||||
self._outputs = outputs
|
self._outputs = outputs
|
||||||
self.locktime = locktime
|
self.locktime = locktime
|
||||||
self.txcomment = txcomment
|
self.flodata = flodata
|
||||||
self.BIP69_sort()
|
self.BIP69_sort()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -1008,7 +1008,7 @@ class Transaction:
|
|||||||
nVersion = int_to_hex(self.version, 4)
|
nVersion = int_to_hex(self.version, 4)
|
||||||
nHashType = int_to_hex(1, 4)
|
nHashType = int_to_hex(1, 4)
|
||||||
nLocktime = int_to_hex(self.locktime, 4)
|
nLocktime = int_to_hex(self.locktime, 4)
|
||||||
nTxComment = var_int(len(self.txcomment)) + str(codecs.encode(bytes(self.txcomment, 'utf-8'), 'hex_codec'),
|
nFloData = var_int(len(self.flodata)) + str(codecs.encode(bytes(self.flodata, 'utf-8'), 'hex_codec'),
|
||||||
'utf-8')
|
'utf-8')
|
||||||
inputs = self.inputs()
|
inputs = self.inputs()
|
||||||
outputs = self.outputs()
|
outputs = self.outputs()
|
||||||
@ -1024,14 +1024,14 @@ class Transaction:
|
|||||||
amount = int_to_hex(txin['value'], 8)
|
amount = int_to_hex(txin['value'], 8)
|
||||||
nSequence = int_to_hex(txin.get('sequence', 0xffffffff - 1), 4)
|
nSequence = int_to_hex(txin.get('sequence', 0xffffffff - 1), 4)
|
||||||
if self.version >= 2:
|
if self.version >= 2:
|
||||||
preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nTxComment + nHashType
|
preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nFloData + nHashType
|
||||||
else:
|
else:
|
||||||
preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nHashType
|
preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nHashType
|
||||||
else:
|
else:
|
||||||
txins = var_int(len(inputs)) + ''.join(self.serialize_input(txin, self.get_preimage_script(txin) if i==k else '') for k, txin in enumerate(inputs))
|
txins = var_int(len(inputs)) + ''.join(self.serialize_input(txin, self.get_preimage_script(txin) if i==k else '') for k, txin in enumerate(inputs))
|
||||||
txouts = var_int(len(outputs)) + ''.join(self.serialize_output(o) for o in outputs)
|
txouts = var_int(len(outputs)) + ''.join(self.serialize_output(o) for o in outputs)
|
||||||
if self.version >= 2:
|
if self.version >= 2:
|
||||||
preimage = nVersion + txins + txouts + nLocktime + nTxComment + nHashType
|
preimage = nVersion + txins + txouts + nLocktime + nFloData + nHashType
|
||||||
else:
|
else:
|
||||||
preimage = nVersion + txins + txouts + nLocktime + nHashType
|
preimage = nVersion + txins + txouts + nLocktime + nHashType
|
||||||
return preimage
|
return preimage
|
||||||
@ -1054,7 +1054,7 @@ class Transaction:
|
|||||||
def serialize_to_network(self, estimate_size=False, witness=True):
|
def serialize_to_network(self, estimate_size=False, witness=True):
|
||||||
nVersion = int_to_hex(self.version, 4)
|
nVersion = int_to_hex(self.version, 4)
|
||||||
nLocktime = int_to_hex(self.locktime, 4)
|
nLocktime = int_to_hex(self.locktime, 4)
|
||||||
nTxComment = var_int(len(self.txcomment)) + str(codecs.encode(bytes(self.txcomment, 'utf-8'), 'hex_codec'),
|
nFloData = var_int(len(self.flodata)) + str(codecs.encode(bytes(self.flodata, 'utf-8'), 'hex_codec'),
|
||||||
'utf-8')
|
'utf-8')
|
||||||
inputs = self.inputs()
|
inputs = self.inputs()
|
||||||
outputs = self.outputs()
|
outputs = self.outputs()
|
||||||
@ -1069,12 +1069,12 @@ class Transaction:
|
|||||||
flag = '01'
|
flag = '01'
|
||||||
witness = ''.join(self.serialize_witness(x, estimate_size) for x in inputs)
|
witness = ''.join(self.serialize_witness(x, estimate_size) for x in inputs)
|
||||||
if self.version >= 2:
|
if self.version >= 2:
|
||||||
return nVersion + marker + flag + txins + txouts + witness + nLocktime + nTxComment
|
return nVersion + marker + flag + txins + txouts + witness + nLocktime + nFloData
|
||||||
else:
|
else:
|
||||||
return nVersion + marker + flag + txins + txouts + witness + nLocktime
|
return nVersion + marker + flag + txins + txouts + witness + nLocktime
|
||||||
else:
|
else:
|
||||||
if self.version >= 2:
|
if self.version >= 2:
|
||||||
return nVersion + txins + txouts + nLocktime + nTxComment
|
return nVersion + txins + txouts + nLocktime + nFloData
|
||||||
else:
|
else:
|
||||||
return nVersion + txins + txouts + nLocktime
|
return nVersion + txins + txouts + nLocktime
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user