electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 370bdbe85559f3cd20808e684cd0919b9ab6a6a4
parent a03b85a5134c14fb96630e4438eda9bace77cd51
Author: ThomasV <thomasv@gitorious>
Date:   Wed,  7 May 2014 18:59:51 +0200

fix payment ack

Diffstat:
Mgui/qt/__init__.py | 1+
Mgui/qt/main_window.py | 8++++----
Mlib/paymentrequest.py | 53+++++++++++++++++++++++++++++------------------------
3 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py @@ -71,6 +71,7 @@ class ElectrumGui: self.app = QApplication(sys.argv) self.app.installEventFilter(self.efilter) init_plugins(self) + self.payment_request = None def build_tray_menu(self): diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -121,7 +121,6 @@ class ElectrumWindow(QMainWindow): set_language(config.get('language')) self.funds_error = False - self.payment_request = None self.completions = QStringListModel() self.tabs = tabs = QTabWidget(self) @@ -874,10 +873,11 @@ class ElectrumWindow(QMainWindow): return def broadcast_thread(): - if self.payment_request: + if self.gui_object.payment_request: + print "sending ack" refund_address = self.wallet.addresses()[0] - self.payment_request.send_ack(str(tx), refund_address) - self.payment_request = None + self.gui_object.payment_request.send_ack(str(tx), refund_address) + self.gui_object.payment_request = None # note: BIP 70 recommends not broadcasting the tx to the network and letting the merchant do that self.tx_broadcast_result = self.wallet.sendtx(tx) self.emit(SIGNAL('send_tx3')) diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py @@ -184,6 +184,7 @@ class PaymentRequest: if CA_match: print 'Signed By Trusted CA: ', CA_OU + print "payment url", pay_det.payment_url return True @@ -191,34 +192,38 @@ class PaymentRequest: def send_ack(self, raw_tx, refund_addr): pay_det = self.payment_details - if pay_det.payment_url: - paymnt = paymentrequest_pb2.Payment() + if not pay_det.payment_url: + return - paymnt.merchant_data = pay_det.merchant_data - paymnt.transactions.append(raw_tx) + paymnt = paymentrequest_pb2.Payment() + paymnt.merchant_data = pay_det.merchant_data + paymnt.transactions.append(raw_tx) - ref_out = paymnt.refund_to.add() - ref_out.script = transaction.Transaction.pay_script(refund_addr) - paymnt.memo = "Paid using Electrum" - pm = paymnt.SerializeToString() + ref_out = paymnt.refund_to.add() + ref_out.script = transaction.Transaction.pay_script(refund_addr) + paymnt.memo = "Paid using Electrum" + pm = paymnt.SerializeToString() - payurl = urlparse.urlparse(pay_det.payment_url) - try: - r = requests.post(payurl.geturl(), data=pm, headers=ACK_HEADERS, verify=ca_path) - except requests.exceptions.SSLError: - print "Payment Message/PaymentACK verify Failed" - try: - r = requests.post(payurl.geturl(), data=pm, headers=ACK_HEADERS, verify=False) - except Exception as e: - print "Payment Message/PaymentACK Failed" - print e - return + payurl = urlparse.urlparse(pay_det.payment_url) + try: + r = requests.post(payurl.geturl(), data=pm, headers=ACK_HEADERS, verify=ca_path) + except requests.exceptions.SSLError: + print "Payment Message/PaymentACK verify Failed" try: - paymntack = paymentrequest_pb2.PaymentACK() - paymntack.ParseFromString(r.content) - print "PaymentACK message received: %s" % paymntack.memo - except Exception: - print "PaymentACK could not be processed. Payment was sent; please manually verify that payment was received." + r = requests.post(payurl.geturl(), data=pm, headers=ACK_HEADERS, verify=False) + except Exception as e: + print "Payment Message/PaymentACK Failed" + print e + return + try: + paymntack = paymentrequest_pb2.PaymentACK() + paymntack.ParseFromString(r.content) + except Exception: + print "PaymentACK could not be processed. Payment was sent; please manually verify that payment was received." + return + + print "PaymentACK message received: %s" % paymntack.memo + return paymntack.memo