Skip to content

Commit

Permalink
[ALL] Update GUI to v0.3.0
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
sumoprojects committed Nov 18, 2019
1 parent 47d2af0 commit 19089ff
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 91 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
42 changes: 17 additions & 25 deletions app/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.<br><br>Are you sure you want to proceed?", \
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -432,19 +427,18 @@ def send_tx(self, amount, address, payment_id, priority, mixin, tx_desc, save_ad
msg += "- Transaction ID: %s <br> - Amount: %s <br> - Fee: %s <br><br>" % (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"]
}
Expand All @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class AppSettings():
"block_sync_size": 20,
"limit_rate_up": 2048,
"limit_rate_down": 8192,
"use_boostrap_daemon": True,
},

"blockchain": {
Expand Down Expand Up @@ -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:
Expand Down
76 changes: 24 additions & 52 deletions html/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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');
}
Expand All @@ -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();
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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 = "<ul>";
for(var i=0; i<errors.length;i++){
Expand All @@ -944,16 +923,10 @@
var tx_desc = $('#send_tx_desc').val().trim();
var priority = $('#send_priority').val();
var mixin = $('#send_mixins').val();
var ring_size = $('#send_ring_size').val();
btn_send_tx.disable(true);
app_hub.send_tx(amount, address, payment_id, priority, mixin, tx_desc, $('#checkbox_save_address').is(":checked"), sweep_all);
return false;
}
function generate_payment_id(){
show_progress("Generating payment ID, integrated address...");
app_hub.generate_payment_id(16);
app_hub.send_tx(amount, address, priority, ring_size, tx_desc, $('#checkbox_save_address').is(":checked"), sweep_all);
return false;
}
Expand Down Expand Up @@ -1178,6 +1151,10 @@
$('#down_speed_limit_select').on('change', function(e) {
app_hub.change_limit_rate_down(this.value);
});
$("#use_boostrap_daemon_chk").change(function() {
app_hub.change_use_boostrap_daemon(this.checked);
});
});
</script>
</head>
Expand Down Expand Up @@ -1316,14 +1293,6 @@
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<label for="send_payment_id" class="col-xs-2 control-label">Payment ID</label>
<div class="col-xs-10">
<input id="send_payment_id" type="text" class="form-control" placeholder="Paste payment ID here (Ctrl+V, optional)..." maxlength="64"/>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<label for="send_tx_desc" class="col-xs-2 control-label">Description</label>
Expand All @@ -1334,13 +1303,13 @@
</div>
<div class="form-group">
<div class="col-sm-6">
<label for="send_mixins" class="col-xs-4 control-label">Ringsize <sup>1</sup></label>
<label for="send_ring_size" class="col-xs-4 control-label">Ringsize <sup>1</sup></label>
<div class="col-xs-8">
<select id="send_mixins" class="form-control">
<option value="48" selected>49 (default)</option>
<option value="60">61</option>
<option value="72">73</option>
<option value="96">97</option>
<select id="send_ring_size" class="form-control">
<option value="49" selected>49 (default)</option>
<option value="61">61</option>
<option value="73">73</option>
<option value="97">97</option>
</select>
</div>
</div>
Expand All @@ -1362,7 +1331,7 @@
<div class="col-sm-12">
<label class="col-xs-2 control-label sr-only">&nbsp;</label>
<div class="col-xs-10">
<input id="checkbox_save_address" type="checkbox" /> <label for="checkbox_save_address">Save address (with payment id) to address book</label>
<input id="checkbox_save_address" type="checkbox" /> <label for="checkbox_save_address">Save address to Address Book</label>
<label style="color:#999; font-size: 95%">1. Larger ringsize means higher transaction cost, using default ringsize (49) is highly recommended</label>
<label style="color:#999; font-size: 95%">2. Only choose higher priority when there are many transactions in tx pool or "Normal" works just fine</label>
</div>
Expand Down Expand Up @@ -1524,6 +1493,9 @@
<option value="16384">16384</option>
</select>
</div>
<div class="col-xs-12" style="margin-top: 20px; margin-bottom: 10px;">
<input id="use_boostrap_daemon_chk" type="checkbox" value="" checked="checked"> <label class="control-label" for="use_boostrap_daemon_chk">Use boostrap daemon (auto)</label>
</div>
</div>
</form>
</div>
Expand All @@ -1535,13 +1507,13 @@
</div>
<hr style="margin-top:10px;margin-bottom:0px;">
<div class="row">
<div class="col-sm-12 form-group" style="margin-bottom: 0px; margin-top: 20px; text-align: center">
<input id="minimize_to_tray_chk" type="checkbox" value="" checked="checked"> <label class="control-label" for="minimize_to_tray_chk">Close wallet to notification area (system tray)</label>
</div>
</div>
<div class="row">
<div class="col-sm-12" style="margin-top: 10px;text-align: center">
<button id="btn_about" type="button" class="btn btn-primary" onclick="about_app()"><i class="fa fa-user"></i> About...</button>
<div class="col-lg-12">
<div class="col-sm-6 form-group" style="margin-bottom: 0px; margin-top: 20px;">
<input id="minimize_to_tray_chk" type="checkbox" value="" checked="checked"> <label class="control-label" for="minimize_to_tray_chk">Close wallet to notification area (system tray)</label>
</div>
<div class="col-sm-6" style="margin-top: 10px;text-align: right">
<button id="btn_about" type="button" class="btn btn-primary" onclick="about_app()"><i class="fa fa-user"></i> About...</button>
</div>
</div>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion manager/ProcessManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ def is_proc_running(self):


class SumokoindManager(ProcessManager):
def __init__(self, resources_path, log_level=1, block_sync_size=20, limit_rate_up=2048, limit_rate_down=8192):
def __init__(self, resources_path, log_level=1, block_sync_size=20, limit_rate_up=2048, limit_rate_down=8192, use_bootstrap_daemon=True):
exec_path = u'%s/bin/sumokoind' % resources_path
proc_args = u'--log-level=%d --block-sync-size=%d --limit-rate-up=%d --limit-rate-down=%d' % (log_level, block_sync_size, limit_rate_up, limit_rate_down)
if use_bootstrap_daemon:
proc_args += u' --bootstrap-daemon-address=auto'
super(SumokoindManager, self).__init__(exec_path, proc_args, "sumokoind")

def run(self):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PySide>=1.2,<2.0
requests
psutil
sumokoin-python
16 changes: 5 additions & 11 deletions rpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,24 @@ def rescan_bc(self):
rpc_input = {"method": "rescan_blockchain"}
return self.send_request(rpc_input)

def transfer_split(self, amount, address, payment_id, priority, mixin):
def transfer_split(self, amount, address, priority, ring_size):
rpc_input = {"method": "transfer_split"}
params = {"destinations": [{"amount" : amount, "address": address}],
"priority": priority,
"mixin": mixin}
if payment_id:
params["payment_id"] = payment_id
"ring_size": ring_size}

rpc_input["params"] = params
return self.send_request(rpc_input)

def transfer_all(self, address, payment_id, priority, mixin, account_index=0, subaddr_indices=[0]):
def sweep_all(self, address, priority, ring_size, account_index=0, subaddr_indices=[0]):
rpc_input = {"method": "sweep_all"}
params = {
"address": address,
"account_index": account_index,
"subaddr_indices": subaddr_indices,
"priority": priority,
"mixin": mixin
"ring_size": ring_size
}
if payment_id:
params["payment_id"] = payment_id

rpc_input["params"] = params
return self.send_request(rpc_input)
Expand All @@ -243,11 +239,9 @@ def get_address_book(self):
rpc_input = {"method": "get_address_book"}
return self.send_request(rpc_input)

def add_address_book(self, address, payment_id, desc):
def add_address_book(self, address, desc):
rpc_input = {"method": "add_address_book"}
params = {"address": address}
if payment_id:
params["payment_id"] = payment_id
if desc:
params["description"] = desc
rpc_input["params"] = params
Expand Down
2 changes: 1 addition & 1 deletion settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from utils.common import getHomeDir, makeDir

VERSION = [0, 2, 2]
VERSION = [0, 3, 0]
APP_NAME = "Sumo GUI Wallet"
USER_AGENT = '%s v%s' % (APP_NAME, '.'.join(str(v) for v in VERSION))

Expand Down
Loading

0 comments on commit 19089ff

Please sign in to comment.