Refactor address lookups
This commit is contained in:
@@ -1082,7 +1082,7 @@ void MainWindow::setupBalancesTab() {
|
||||
fnDoSendFrom(addr);
|
||||
});
|
||||
|
||||
if (addr.startsWith("t")) {
|
||||
if (Settings::isTAddress(addr)) {
|
||||
auto defaultSapling = rpc->getDefaultSaplingAddress();
|
||||
if (!defaultSapling.isEmpty()) {
|
||||
menu.addAction(tr("Shield balance to Sapling"), [=] () {
|
||||
@@ -1402,7 +1402,7 @@ void MainWindow::updateTAddrCombo(bool checked) {
|
||||
|
||||
std::for_each(utxos->begin(), utxos->end(), [=](auto& utxo) {
|
||||
auto addr = utxo.address;
|
||||
if (addr.startsWith("t") && ui->listRecieveAddresses->findText(addr) < 0) {
|
||||
if (Settings::isTAddress(addr) && ui->listRecieveAddresses->findText(addr) < 0) {
|
||||
auto bal = rpc->getAllBalances()->value(addr);
|
||||
ui->listRecieveAddresses->addItem(addr, bal);
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ void RPC::fillTxJsonParams(json& params, Tx tx) {
|
||||
// Force it through string for rounding. Without this, decimal points beyond 8 places
|
||||
// will appear, causing an "invalid amount" error
|
||||
rec["amount"] = Settings::getDecimalString(toAddr.amount).toStdString(); //.toDouble();
|
||||
if (toAddr.addr.startsWith("z") && !toAddr.encodedMemo.trimmed().isEmpty())
|
||||
if (Settings::isZAddress(toAddr.addr) && !toAddr.encodedMemo.trimmed().isEmpty())
|
||||
rec["memo"] = toAddr.encodedMemo.toStdString();
|
||||
|
||||
allRecepients.push_back(rec);
|
||||
|
||||
@@ -292,7 +292,7 @@ void MainWindow::addAddressSection() {
|
||||
|
||||
void MainWindow::addressChanged(int itemNumber, const QString& text) {
|
||||
auto addr = AddressBook::addressFromAddressLabel(text);
|
||||
setMemoEnabled(itemNumber, addr.startsWith("z"));
|
||||
setMemoEnabled(itemNumber, Settings::isZAddress(addr));
|
||||
}
|
||||
|
||||
void MainWindow::amountChanged(int item, const QString& text) {
|
||||
@@ -314,7 +314,7 @@ void MainWindow::setMemoEnabled(int number, bool enabled) {
|
||||
void MainWindow::memoButtonClicked(int number, bool includeReplyTo) {
|
||||
// Memos can only be used with zAddrs. So check that first
|
||||
auto addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") + QString::number(number));
|
||||
if (!AddressBook::addressFromAddressLabel(addr->text()).startsWith("z")) {
|
||||
if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
|
||||
QMessageBox msg(QMessageBox::Critical, tr("Memos can only be used with z-addresses"),
|
||||
tr("The memo field can only be used with a z-address.\n") + addr->text() + tr("\ndoesn't look like a z-address"),
|
||||
QMessageBox::Ok, this);
|
||||
@@ -500,7 +500,7 @@ Tx MainWindow::createTxFromSendPage() {
|
||||
|
||||
bool MainWindow::confirmTx(Tx tx) {
|
||||
auto fnSplitAddressForWrap = [=] (const QString& a) -> QString {
|
||||
if (!a.startsWith("z")) return a;
|
||||
if (! Settings::isZAddress(a)) return a;
|
||||
|
||||
auto half = a.length() / 2;
|
||||
auto splitted = a.left(half) + "\n" + a.right(a.length() - half);
|
||||
@@ -566,7 +566,7 @@ bool MainWindow::confirmTx(Tx tx) {
|
||||
confirm.gridLayout->addWidget(AmtUSD, row, 2, 1, 1);
|
||||
|
||||
// Memo
|
||||
if (toAddr.addr.startsWith("z") && !toAddr.txtMemo.isEmpty()) {
|
||||
if (Settings::isZAddress(toAddr.addr) && !toAddr.txtMemo.isEmpty()) {
|
||||
row++;
|
||||
auto Memo = new QLabel(confirm.sendToAddrs);
|
||||
Memo->setObjectName(QStringLiteral("Memo") % QString::number(i + 1));
|
||||
|
||||
@@ -57,7 +57,7 @@ void SentTxStore::addToSentTx(Tx tx, QString txid) {
|
||||
|
||||
// Also, only store outgoing txs where the from address is a z-Addr. Else, regular zcashd
|
||||
// stores it just fine
|
||||
if (!tx.fromAddr.startsWith("z"))
|
||||
if (! Settings::isZAddress(tx.fromAddr))
|
||||
return;
|
||||
|
||||
QFile data(writeableFile());
|
||||
|
||||
Reference in New Issue
Block a user