diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -220,6 +220,9 @@ // Return whether HD enabled. virtual bool hdEnabled() = 0; + // Get default address type. + virtual OutputType getDefaultAddressType() = 0; + //! Register handler for show progress messages. using ShowProgressFn = std::function; diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -381,6 +381,7 @@ return result; } bool hdEnabled() override { return m_wallet.IsHDEnabled(); } + OutputType getDefaultAddressType() override { return g_address_type; } std::unique_ptr handleShowProgress(ShowProgressFn fn) override { return MakeHandler(m_wallet.ShowProgress.connect(fn)); diff --git a/src/qt/addresstablemodel.h b/src/qt/addresstablemodel.h --- a/src/qt/addresstablemodel.h +++ b/src/qt/addresstablemodel.h @@ -8,6 +8,8 @@ #include #include +enum class OutputType; + class AddressTablePriv; class WalletModel; @@ -79,7 +81,7 @@ Returns the added address on success, and an empty string otherwise. */ QString addRow(const QString &type, const QString &label, - const QString &address); + const QString &address, const OutputType address_type); /* Look up label for address in address book, if not found return empty * string. diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -317,7 +317,8 @@ } QString AddressTableModel::addRow(const QString &type, const QString &label, - const QString &address) { + const QString &address, + const OutputType address_type) { std::string strLabel = label.toStdString(); std::string strAddress = address.toStdString(); @@ -351,10 +352,9 @@ return QString(); } } - walletModel->wallet().learnRelatedScripts(newKey, g_address_type); - strAddress = - EncodeCashAddr(GetDestinationForKey(newKey, g_address_type), - walletModel->getChainParams()); + walletModel->wallet().learnRelatedScripts(newKey, address_type); + strAddress = EncodeCashAddr(GetDestinationForKey(newKey, address_type), + walletModel->getChainParams()); } else { return QString(); } diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp --- a/src/qt/editaddressdialog.cpp +++ b/src/qt/editaddressdialog.cpp @@ -11,6 +11,8 @@ #include #include +extern OutputType g_address_type; + EditAddressDialog::EditAddressDialog(Mode _mode, QWidget *parent) : QDialog(parent), ui(new Ui::EditAddressDialog), mapper(0), mode(_mode), model(0) { @@ -69,7 +71,7 @@ address = model->addRow( mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive, - ui->labelEdit->text(), ui->addressEdit->text()); + ui->labelEdit->text(), ui->addressEdit->text(), g_address_type); break; case EditReceivingAddress: case EditSendingAddress: diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -2,6 +2,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include + #include #include @@ -138,8 +140,9 @@ QString address; QString label = ui->reqLabel->text(); /* Generate new receiving address */ + OutputType address_type = model->wallet().getDefaultAddressType(); address = model->getAddressTableModel()->addRow(AddressTableModel::Receive, - label, ""); + label, "", address_type); SendCoinsRecipient info(address, label, ui->reqAmount->value(), ui->reqMessage->text()); ReceiveRequestDialog *dialog = new ReceiveRequestDialog(this);