Skip to content
Snippets Groups Projects
Commit 03035fca authored by inso's avatar inso
Browse files

Send back a transaction now save the comment too

parent bc3e23a4
Branches
Tags
No related merge requests found
...@@ -28,12 +28,13 @@ class Transfer(object): ...@@ -28,12 +28,13 @@ class Transfer(object):
self.metadata = metadata self.metadata = metadata
@classmethod @classmethod
def initiate(cls, txdoc, block, time, amount, issuer, receiver): def initiate(cls, block, time, amount, issuer, receiver, comment):
return cls(txdoc, Transfer.TO_SEND, {'block': block, return cls(None, Transfer.TO_SEND, {'block': block,
'time': time, 'time': time,
'amount': amount, 'amount': amount,
'issuer': issuer, 'issuer': issuer,
'receiver': receiver}) 'receiver': receiver,
'comment': comment})
@classmethod @classmethod
def create_validated(cls, txdoc, metadata): def create_validated(cls, txdoc, metadata):
...@@ -56,8 +57,9 @@ class Transfer(object): ...@@ -56,8 +57,9 @@ class Transfer(object):
'state': self.state, 'state': self.state,
'metadata': self.metadata} 'metadata': self.metadata}
def send(self, community): def send(self, txdoc, community):
try: try:
self.txdoc = txdoc
community.broadcast(bma.tx.Process, community.broadcast(bma.tx.Process,
post_args={'transaction': self.txdoc.signed_raw()}) post_args={'transaction': self.txdoc.signed_raw()})
self.state = Transfer.AWAITING self.state = Transfer.AWAITING
......
...@@ -238,6 +238,7 @@ class Wallet(object): ...@@ -238,6 +238,7 @@ class Wallet(object):
def send_money(self, salt, password, community, def send_money(self, salt, password, community,
recipient, amount, message): recipient, amount, message):
time = community.get_block().time time = community.get_block().time
block_number = community.current_blockid()['number'] block_number = community.current_blockid()['number']
key = None key = None
...@@ -248,7 +249,10 @@ class Wallet(object): ...@@ -248,7 +249,10 @@ class Wallet(object):
key = SigningKey("{0}{1}".format(salt, self.walletid), password) key = SigningKey("{0}{1}".format(salt, self.walletid), password)
logging.debug("Sender pubkey:{0}".format(key.pubkey)) logging.debug("Sender pubkey:{0}".format(key.pubkey))
try: transfer = Transfer.initiate(block_number, time, amount,
key.pubkey, recipient, message)
self.caches[community.currency]._transfers.append(transfer)
result = self.tx_inputs(int(amount), community) result = self.tx_inputs(int(amount), community)
inputs = result[0] inputs = result[0]
self.caches[community.currency].available_sources = result[1] self.caches[community.currency].available_sources = result[1]
...@@ -263,16 +267,7 @@ class Wallet(object): ...@@ -263,16 +267,7 @@ class Wallet(object):
tx.sign([key]) tx.sign([key])
logging.debug("Transaction : {0}".format(tx.signed_raw())) logging.debug("Transaction : {0}".format(tx.signed_raw()))
transfer.send(tx, community)
transfer = Transfer.initiate(tx, block_number, time, amount,
key.pubkey, recipient)
transfer.send(community)
self.caches[community.currency]._transfers.append(transfer)
except NotEnoughMoneyError:
transfer = Transfer.initiate(None, block_number, time, amount,
key.pubkey, recipient)
self.caches[community.currency]._transfers.append(transfer)
raise
def sources(self, community): def sources(self, community):
data = community.request(bma.tx.Sources, data = community.request(bma.tx.Sources,
......
...@@ -254,6 +254,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): ...@@ -254,6 +254,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
dialog.combo_community.setCurrentText(self.community.name()) dialog.combo_community.setCurrentText(self.community.name())
dialog.spinbox_amount.setValue(transfer.metadata['amount']) dialog.spinbox_amount.setValue(transfer.metadata['amount'])
dialog.radio_pubkey.setChecked(True) dialog.radio_pubkey.setChecked(True)
dialog.edit_message.setText(transfer.metadata['comment'])
result = dialog.exec_() result = dialog.exec_()
if result == QDialog.Accepted: if result == QDialog.Accepted:
transfer.drop() transfer.drop()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment