From 19089ffd383928c3b4e7634a867b1e68a54b7f22 Mon Sep 17 00:00:00 2001 From: Sumoshi Tanaka Date: Mon, 18 Nov 2019 17:33:13 +0700 Subject: [PATCH] [ALL] Update GUI to v0.3.0 - Update binaries to Sumokoin Sendai v0.6.0.1 - Fix API compatibility with latest wallet RPC - Add bootstrap daemon option - Remove long payment id option when sending tx - (Initial) use of `sumokoin-python` lib for integrated address construction (when loaded from Address Book) --- README.md | 2 ++ app/hub.py | 42 +++++++++------------- classes/__init__.py | 6 ++++ html/index.py | 76 +++++++++++++-------------------------- manager/ProcessManager.py | 4 ++- requirements.txt | 1 + rpc/__init__.py | 16 +++------ settings/__init__.py | 2 +- webui/__init__.py | 3 +- 9 files changed, 61 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index 4d0c9a5..f5b5cc9 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Copyright (c) 2017-2019, Sumokoin Project (www.sumokoin.org) sudo apt install python-pyside + * `sumokoin-python` lib from [sumokoin-python](https://github.com/sumoprojects/sumokoin-python) repo + 3. Build/download Sumokoin binaries from [Sumokoin repo](https://github.com/sumoprojects/sumokoin) and put it to `Resources/bin` sub-directory. diff --git a/app/hub.py b/app/hub.py index 63adebc..2e1c543 100644 --- a/app/hub.py +++ b/app/hub.py @@ -20,6 +20,8 @@ QInputDialog, QLineEdit from PySide.QtCore import QObject, Slot, Signal +from sumokoin.address import Address + from utils.common import print_money, print_money2 from settings import APP_NAME, VERSION, DATA_DIR, COIN, makeDir, seed_languages @@ -360,15 +362,8 @@ def rescan_bc(self): self.on_wallet_rescan_bc_completed_event.emit() - @Slot(float, str, str, int, int, str, bool, bool) - def send_tx(self, amount, address, payment_id, priority, mixin, tx_desc, save_address, sweep_all): - if not payment_id and not address.startswith("Sumi"): - result = QMessageBox.question(self.ui, "Sending Coins Without Payment ID?", \ - "Are you sure to send coins without Payment ID?", \ - QMessageBox.Yes | QMessageBox.No, defaultButton=QMessageBox.No) - if result == QMessageBox.No: - return - + @Slot(float, str, int, int, str, bool, bool) + def send_tx(self, amount, address, priority, ring_size, tx_desc, save_address, sweep_all): if sweep_all: result = QMessageBox.question(self.ui, "Sending all your coins?", \ "This will send all your coins to target address.

Are you sure you want to proceed?", \ @@ -396,10 +391,10 @@ def send_tx(self, amount, address, payment_id, priority, mixin, tx_desc, save_ad for s in per_subaddress: if s['unlocked_balance'] > 0: subaddr_indices.append(s['address_index']) - ret = self.ui.wallet_rpc_manager.rpc_request.transfer_all(address, payment_id, priority, mixin, 0, subaddr_indices) + ret = self.ui.wallet_rpc_manager.rpc_request.sweep_all(address, priority, ring_size, 0, subaddr_indices) else: ret = self.ui.wallet_rpc_manager.rpc_request.transfer_split(amount, \ - address, payment_id, priority, mixin) + address, priority, ring_size) if ret['status'] == "ERROR": self.on_wallet_send_tx_completed_event.emit(json.dumps(ret)); @@ -432,19 +427,18 @@ def send_tx(self, amount, address, payment_id, priority, mixin, tx_desc, save_ad msg += "- Transaction ID: %s
- Amount: %s
- Fee: %s

" % (ret['tx_hash_list'][i], \ print_money2(ret['amount_list'][i]), \ print_money2(ret['fee_list'][i])) - QMessageBox.information(self.ui, 'Coins Sent', msg) + QMessageBox.information(self.ui, 'Transaction Complete', msg) self.ui.update_wallet_info() if save_address: desc, _ = self._custom_input_dialog(self.ui, \ 'Saving Address...', \ "Address description/note (optional):") - ret = self.ui.wallet_rpc_manager.rpc_request.add_address_book(address, \ - payment_id, desc) + ret = self.ui.wallet_rpc_manager.rpc_request.add_address_book(address, desc) if ret['status'] == "OK": if self.ui.wallet_info.wallet_address_book: address_entry = {"address": address, - "payment_id": payment_id, + "payment_id": "", "description": desc[0:200], "index": ret["index"] } @@ -453,14 +447,6 @@ def send_tx(self, amount, address, payment_id, priority, mixin, tx_desc, save_ad QMessageBox.information(self.ui, "Address Saved", \ "Address (and payment ID) saved to address book.") - - @Slot(int) - def generate_payment_id(self, hex_length=16): - payment_id = binascii.b2a_hex(os.urandom(hex_length/2)) - integrated_address = self.ui.wallet_rpc_manager.rpc_request.make_integrated_address(payment_id)["integrated_address"] - self.on_generate_payment_id_event.emit(payment_id, integrated_address); - - @Slot(str) def copy_text(self, text): QApplication.clipboard().setText(text) @@ -476,7 +462,9 @@ def load_address_book(self): for a in address_book: if a['payment_id'][16:] == "000000000000000000000000000000000000000000000000": # convert short payment id into integrated address - a['address'] = self.ui.wallet_rpc_manager.rpc_request.make_integrated_address(a['address'], a['payment_id'][:16])["integrated_address"] + addr = Address(a['address']) + ia = addr.with_payment_id(a['payment_id'][:16]) + a['address'] = str(ia) a['payment_id'] = "0000000000000000" self.ui.wallet_info.wallet_address_book = address_book @@ -907,6 +895,11 @@ def change_limit_rate_down(self, limit_rate_down): self.ui.app_settings.settings['daemon']['limit_rate_down'] = limit_rate_down self.ui.app_settings.save() + @Slot(bool) + def change_use_boostrap_daemon(self, status): + self.ui.app_settings.settings['daemon']['use_boostrap_daemon'] = status + self.ui.app_settings.save() + def update_daemon_status(self, status): self.on_daemon_update_status_event.emit(status) @@ -972,7 +965,6 @@ def show_wallet_info(self): on_wallet_rescan_spent_completed_event = Signal() on_wallet_rescan_bc_completed_event = Signal() on_wallet_send_tx_completed_event = Signal(str) - on_generate_payment_id_event = Signal(str, str) on_load_address_book_completed_event = Signal(str) on_tx_detail_found_event = Signal(str) on_load_tx_history_completed_event = Signal(str) diff --git a/classes/__init__.py b/classes/__init__.py index 8518041..dca75e4 100644 --- a/classes/__init__.py +++ b/classes/__init__.py @@ -94,6 +94,7 @@ class AppSettings(): "block_sync_size": 20, "limit_rate_up": 2048, "limit_rate_down": 8192, + "use_boostrap_daemon": True, }, "blockchain": { @@ -138,6 +139,11 @@ def load(self): if self.settings["daemon"]["limit_rate_down"] not in self.limit_rate_downs: self.settings["daemon"]["limit_rate_down"] = self.default_settings["daemon"]["limit_rate_down"] + try: + self.settings["daemon"]["use_boostrap_daemon"] = bool(self.settings["daemon"]["use_boostrap_daemon"]) + except: + self.settings["daemon"]["use_boostrap_daemon"] = self.default_settings["daemon"]["use_boostrap_daemon"] + try: self.settings["blockchain"]["height"] = abs(int(self.settings["blockchain"]["height"])) except: diff --git a/html/index.py b/html/index.py index e981c38..a6e0731 100644 --- a/html/index.py +++ b/html/index.py @@ -408,6 +408,7 @@ $('#up_speed_limit_select').val(app_settings['daemon']['limit_rate_up']); $('#down_speed_limit_select').val(app_settings['daemon']['limit_rate_down']); + $('#use_boostrap_daemon_chk').prop('checked', app_settings['daemon']['use_boostrap_daemon']); }); app_hub.on_main_wallet_ui_reset_event.connect(reset_wallet_ui); @@ -438,9 +439,6 @@ if(status['message'].search("Invalid address format") >= 0){ $('#send_address').parent().addClass('has-error'); } - else if(status['message'].search("Payment id has invalid format") >= 0){ - $('#send_payment_id').parent().addClass('has-error'); - } else if(status['message'].search("not enough money") >= 0){ $('#send_amount').parent().addClass('has-error'); } @@ -450,15 +448,6 @@ hide_progress(); }); - app_hub.on_generate_payment_id_event.connect(function(payment_id, integrated_address){ - $('#receive_payment_id').val(payment_id); - receive_integrated_address.val(integrated_address); - $('#receive_address_qrcode').html(""); - $('#receive_address_qrcode').qrcode({width: 220,height: 220, text: integrated_address}); - $('#btn_copy_integrated_address').disable(false); - hide_progress(); - }); - app_hub.on_load_address_book_completed_event.connect(function(address_book){ address_book = $.parseJSON(address_book); hide_progress(); @@ -501,7 +490,6 @@ $(".address-book-row").click(function() { $("#send_address").val( $(this).data("address") ); - $("#send_payment_id").val( $(this).data("payment-id") ); hide_app_dialog(); return false; }); @@ -923,15 +911,6 @@ $('#send_address').parent().removeClass('has-error'); } - var payment_id = $('#send_payment_id').val().trim(); - if(payment_id && !(payment_id.length == 16 || payment_id.length == 64)){ - errors.push("Payment ID must be a 16 or 64 hexadecimal-characters string!"); - $('#send_payment_id').parent().addClass('has-error'); - } - else{ - $('#send_payment_id').parent().removeClass('has-error'); - } - if(errors.length > 0){ var msg = "