diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3f448b3..0a243ca 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1397,6 +1397,9 @@ void MainWindow::updateLabels() { addZAddrsToComboList(ui->rdioZSAddr->isChecked())(true); } + // Update the Send Tab + updateFromCombo(); + // Update the autocomplete updateLabelsAutoComplete(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 0b68f9d..af267b5 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -52,6 +52,7 @@ public: void updateLabels(); void updateTAddrCombo(bool checked); + void updateFromCombo(); Ui::MainWindow* ui; diff --git a/src/rpc.cpp b/src/rpc.cpp index afd4fe0..6ae217a 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -708,21 +708,8 @@ void RPC::updateUI(bool anyUnconfirmed) { // Update balances model data, which will update the table too balancesTableModel->setNewData(allBalances, utxos); - // Add all the addresses into the inputs combo box - auto lastFromAddr = ui->inputsCombo->currentText(); - - ui->inputsCombo->clear(); - auto i = allBalances->constBegin(); - while (i != allBalances->constEnd()) { - ui->inputsCombo->addItem(i.key(), i.value()); - if (i.key() == lastFromAddr) ui->inputsCombo->setCurrentText(i.key()); - - ++i; - } - - if (lastFromAddr.isEmpty()) { - main->setDefaultPayFrom(); - } + // Update from address + main->updateFromCombo(); }; // Function to process reply of the listunspent and z_listunspent API calls, used below. diff --git a/src/sendtab.cpp b/src/sendtab.cpp index a91e800..b0ffb47 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -159,6 +159,31 @@ void MainWindow::setDefaultPayFrom() { } }; +void MainWindow::updateFromCombo() { + if (!rpc || !rpc->getAllBalances()) + return; + + auto lastFromAddr = ui->inputsCombo->currentText(); + + ui->inputsCombo->clear(); + auto i = rpc->getAllBalances()->constBegin(); + + // Add all the addresses into the inputs combo box + while (i != rpc->getAllBalances()->constEnd()) { + ui->inputsCombo->addItem(i.key(), i.value()); + if (i.key() == lastFromAddr) ui->inputsCombo->setCurrentText(i.key()); + + ++i; + } + + if (lastFromAddr.isEmpty()) { + setDefaultPayFrom(); + } + else { + ui->inputsCombo->setCurrentText(lastFromAddr); + } +} + void MainWindow::inputComboTextChanged(int index) { auto addr = ui->inputsCombo->itemText(index); auto bal = rpc->getAllBalances()->value(addr);