aboutsummaryrefslogtreecommitdiff
path: root/src/qt/addresstablemodel.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-06-18 15:19:13 -0400
committerAndrew Chow <achow101-github@achow101.com>2019-07-09 16:43:10 -0400
commit172213be5b174243dc501c1103ad5fe2fee67a16 (patch)
tree2f890eb657ffa7b95ff6fb7e04b58a58c4ba081f /src/qt/addresstablemodel.cpp
parent0853d8d2fd3cd19c3aea495f228222c7a8536e08 (diff)
downloadbitcoin-172213be5b174243dc501c1103ad5fe2fee67a16.tar.xz
Add GetNewDestination to CWallet to fetch new destinations
Instead of having the same multiple lines of code everywhere that new destinations are fetched, introduce GetNewDestination as a member function of CWallet which does the key fetching, label setting, script generation, and destination generation.
Diffstat (limited to 'src/qt/addresstablemodel.cpp')
-rw-r--r--src/qt/addresstablemodel.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index fa6c9c9f7a..29423db3d0 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -358,12 +358,15 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
return QString();
}
}
+
+ // Add entry
+ walletModel->wallet().setAddressBook(DecodeDestination(strAddress), strLabel, "send");
}
else if(type == Receive)
{
// Generate a new address to associate with given label
- CPubKey newKey;
- if(!walletModel->wallet().getKeyFromPool(false /* internal */, newKey))
+ CTxDestination dest;
+ if(!walletModel->wallet().getNewDestination(address_type, strLabel, dest))
{
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
if(!ctx.isValid())
@@ -372,23 +375,18 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
editStatus = WALLET_UNLOCK_FAILURE;
return QString();
}
- if(!walletModel->wallet().getKeyFromPool(false /* internal */, newKey))
+ if(!walletModel->wallet().getNewDestination(address_type, strLabel, dest))
{
editStatus = KEY_GENERATION_FAILURE;
return QString();
}
}
- walletModel->wallet().learnRelatedScripts(newKey, address_type);
- strAddress = EncodeDestination(GetDestinationForKey(newKey, address_type));
+ strAddress = EncodeDestination(dest);
}
else
{
return QString();
}
-
- // Add entry
- walletModel->wallet().setAddressBook(DecodeDestination(strAddress), strLabel,
- (type == Send ? "send" : "receive"));
return QString::fromStdString(strAddress);
}