Merge pull request #3 from ranchimall/txcomment

Updating further changes to master branch
This commit is contained in:
Vivek Teega 2018-09-11 00:14:45 +05:30 committed by GitHub
commit 278a6bcb4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 19 deletions

View File

@ -66,8 +66,8 @@ class AddressSynchronizer(PrintError):
# Verified transactions. txid -> VerifiedTxInfo. Access with self.lock.
verified_tx = storage.get('verified_tx3', {})
self.verified_tx = {}
for txid, (height, timestamp, txpos, header_hash) in verified_tx.items():
self.verified_tx[txid] = VerifiedTxInfo(height, timestamp, txpos, header_hash)
for txid, (height, timestamp, txpos, header_hash, tx_comment) in verified_tx.items():
self.verified_tx[txid] = VerifiedTxInfo(height, timestamp, txpos, header_hash, tx_comment)
# Transactions pending verification. txid -> tx_height. Access with self.lock.
self.unverified_tx = defaultdict(int)
# true when synchronized
@ -596,6 +596,23 @@ class AddressSynchronizer(PrintError):
# local transaction
return TxMinedStatus(TX_HEIGHT_LOCAL, 0, None, None)
def get_tx_comment(self, tx_hash: str):
""" Given a transaction, returns txcomment/floData """
with self.lock:
if tx_hash in self.verified_tx:
info = self.verified_tx[tx_hash]
tx_comment = info[4]
return tx_comment
elif tx_hash in self.unverified_tx:
tx = self.transactions.get(tx_hash)
tx_comment = tx.txcomment[5:]
return tx_comment
else:
# local transaction
tx = self.transactions.get(tx_hash)
tx_comment = tx.txcomment[5:]
return tx_comment
def set_up_to_date(self, up_to_date):
with self.lock:
self.up_to_date = up_to_date

View File

@ -1067,12 +1067,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.message_e = MyLineEdit()
grid.addWidget(self.message_e, 2, 1, 1, -1)
msg = _('This is where you write the FLO Data for the transaction')
txcomment_label = HelpLabel(_('FLO Data'), msg)
grid.addWidget(txcomment_label, 7, 0)
self.message_tx = MyLineEdit()
grid.addWidget(self.message_tx, 7, 1, 1, -1)
self.from_label = QLabel(_('From'))
grid.addWidget(self.from_label, 3, 0)
self.from_list = MyTreeWidget(self, self.from_list_menu, ['',''])
@ -1103,7 +1097,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
hbox.addStretch(1)
grid.addLayout(hbox, 4, 4)
msg = _('Bitcoin transactions are in general not free. A transaction fee is paid by the sender of the funds.') + '\n\n'\
msg = _('FLO transactions are in general not free. A transaction fee is paid by the sender of the funds.') + '\n\n'\
+ _('The amount of fee can be decided freely by the sender. However, transactions with low fees take more time to be processed.') + '\n\n'\
+ _('A suggested fee is automatically added to this field. You may override it. The suggested fee increases with the size of the transaction.')
self.fee_e_label = HelpLabel(_('Fee'), msg)
@ -1202,6 +1196,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
if not self.config.get('show_fee', False):
self.fee_adv_controls.setVisible(False)
msg = _('This is where you write the FLO Data for the transaction')
txcomment_label = HelpLabel(_('FLO Data'), msg)
grid.addWidget(txcomment_label, 6, 0)
self.message_tx = MyLineEdit()
grid.addWidget(self.message_tx, 6, 1, 1, -1)
self.preview_button = EnterButton(_("Preview"), self.do_preview)
self.preview_button.setToolTip(_('Display the details of your transaction before signing it.'))
self.send_button = EnterButton(_("Send"), self.do_send)
@ -1211,7 +1211,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
buttons.addWidget(self.clear_button)
buttons.addWidget(self.preview_button)
buttons.addWidget(self.send_button)
grid.addLayout(buttons, 6, 1, 1, 3)
grid.addLayout(buttons, 7, 1, 1, 3)
self.amount_e.shortcut.connect(self.spend_max)
self.payto_e.textChanged.connect(self.update_fee)

View File

@ -1063,8 +1063,6 @@ class Transaction:
return nVersion + marker + flag + txins + txouts + witness + nLocktime
else:
if self.version >= 2:
print("Before serialize to network ")
print(nVersion + txins + txouts + nLocktime + nTxComment)
return nVersion + txins + txouts + nLocktime + nTxComment
else:
return nVersion + txins + txouts + nLocktime

View File

@ -905,4 +905,5 @@ TxMinedStatus = NamedTuple("TxMinedStatus", [("height", int),
VerifiedTxInfo = NamedTuple("VerifiedTxInfo", [("height", int),
("timestamp", int),
("txpos", int),
("header_hash", str)])
("header_hash", str),
("tx_comment", str)])

View File

@ -110,7 +110,8 @@ class SPV(ThreadJob):
except KeyError: pass
self.print_error("verified %s" % tx_hash)
header_hash = hash_header(header)
vtx_info = VerifiedTxInfo(tx_height, header.get('timestamp'), pos, header_hash)
tx_comment = self.wallet.get_tx_comment(tx_hash)
vtx_info = VerifiedTxInfo(tx_height, header.get('timestamp'), pos, header_hash, tx_comment)
self.wallet.add_verified_tx(tx_hash, vtx_info)
if self.is_up_to_date() and self.wallet.is_up_to_date():
self.wallet.save_verified_tx(write=True)

View File

@ -401,7 +401,7 @@ class Abstract_Wallet(AddressSynchronizer):
'value': Satoshis(value),
'balance': Satoshis(balance),
'date': timestamp_to_datetime(timestamp),
'label': self.get_label(tx_hash),
'label': self.get_label(tx_hash)
}
if show_addresses:
tx = self.transactions.get(tx_hash)
@ -486,10 +486,6 @@ class Abstract_Wallet(AddressSynchronizer):
return ', '.join(labels)
return ''
def get_tx_comment(self, tx_hash):
tx = self.transactions.get(tx_hash)
comment = tx.txcomment[5:]
return comment
def get_tx_status(self, tx_hash, tx_mined_status):
extra = []