From 4b1b6e3adfac7b5df518426a4e692918833e068b Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sat, 29 Sep 2018 18:20:06 +0530 Subject: [PATCH] Renaming everything from FloData to txcomment --- electrum/transaction.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/electrum/transaction.py b/electrum/transaction.py index 1b7a53a5..9e55f76d 100644 --- a/electrum/transaction.py +++ b/electrum/transaction.py @@ -607,9 +607,9 @@ def deserialize(raw: str, force_full_parse=False) -> dict: parse_witness(vds, txin, full_parse=full_parse) d['lockTime'] = vds.read_uint32() if d['version'] >= 2: - d['txcomment'] = vds.read_string() + d['flodata'] = vds.read_string() else: - d['txcomment'] = "" + d['flodata'] = "" if vds.can_read_more(): raise SerializationError('extra junk at the end') return d @@ -650,7 +650,7 @@ class Transaction: self._inputs = None self._outputs = None self.locktime = 0 - self.txcomment = "" + self.flodata = "" self.version = 1 # by default we assume this is a partial txn; # 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.locktime = d['lockTime'] self.version = d['version'] - self.txcomment = d['txcomment'] + self.flodata = d['flodata'] self.is_partial_originally = d['partial'] self._segwit_ser = d['segwit_ser'] return d @classmethod - def from_io(klass, inputs, outputs, locktime=0, txcomment=""): + def from_io(klass, inputs, outputs, locktime=0, flodata=""): self = klass(None) self._inputs = inputs self._outputs = outputs self.locktime = locktime - self.txcomment = txcomment + self.flodata = flodata self.BIP69_sort() return self @@ -1008,7 +1008,7 @@ class Transaction: nVersion = int_to_hex(self.version, 4) nHashType = int_to_hex(1, 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') inputs = self.inputs() outputs = self.outputs() @@ -1024,14 +1024,14 @@ class Transaction: amount = int_to_hex(txin['value'], 8) nSequence = int_to_hex(txin.get('sequence', 0xffffffff - 1), 4) 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: preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nHashType 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)) txouts = var_int(len(outputs)) + ''.join(self.serialize_output(o) for o in outputs) if self.version >= 2: - preimage = nVersion + txins + txouts + nLocktime + nTxComment + nHashType + preimage = nVersion + txins + txouts + nLocktime + nFloData + nHashType else: preimage = nVersion + txins + txouts + nLocktime + nHashType return preimage @@ -1054,7 +1054,7 @@ class Transaction: def serialize_to_network(self, estimate_size=False, witness=True): nVersion = int_to_hex(self.version, 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') inputs = self.inputs() outputs = self.outputs() @@ -1069,12 +1069,12 @@ class Transaction: flag = '01' witness = ''.join(self.serialize_witness(x, estimate_size) for x in inputs) if self.version >= 2: - return nVersion + marker + flag + txins + txouts + witness + nLocktime + nTxComment + return nVersion + marker + flag + txins + txouts + witness + nLocktime + nFloData else: return nVersion + marker + flag + txins + txouts + witness + nLocktime else: if self.version >= 2: - return nVersion + txins + txouts + nLocktime + nTxComment + return nVersion + txins + txouts + nLocktime + nFloData else: return nVersion + txins + txouts + nLocktime