MCPcopy Create free account
hub / github.com/ElementsProject/elements / addRow

Method addRow

src/qt/addresstablemodel.cpp:343–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343QString AddressTableModel::addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type)
344{
345 std::string strLabel = label.toStdString();
346 std::string strAddress = address.toStdString();
347
348 editStatus = OK;
349
350 if(type == Send)
351 {
352 if(!walletModel->validateAddress(address))
353 {
354 editStatus = INVALID_ADDRESS;
355 return QString();
356 }
357 // Check for duplicate addresses
358 {
359 if (walletModel->wallet().getAddress(
360 DecodeDestination(strAddress), /* name= */ nullptr, /* is_mine= */ nullptr, /* purpose= */ nullptr))
361 {
362 editStatus = DUPLICATE_ADDRESS;
363 return QString();
364 }
365 }
366
367 // Add entry
368 walletModel->wallet().setAddressBook(DecodeDestination(strAddress), strLabel, "send");
369 }
370 else if(type == Receive)
371 {
372 // Generate a new address to associate with given label
373 CTxDestination dest;
374 if(!walletModel->wallet().getNewDestination(address_type, strLabel, dest, true))
375 {
376 WalletModel::UnlockContext ctx(walletModel->requestUnlock());
377 if(!ctx.isValid())
378 {
379 // Unlock wallet failed or was cancelled
380 editStatus = WALLET_UNLOCK_FAILURE;
381 return QString();
382 }
383 if(!walletModel->wallet().getNewDestination(address_type, strLabel, dest, true))
384 {
385 editStatus = KEY_GENERATION_FAILURE;
386 return QString();
387 }
388 }
389 strAddress = EncodeDestination(dest);
390 }
391 else
392 {
393 return QString();
394 }
395 return QString::fromStdString(strAddress);
396}
397
398bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent)
399{

Callers 2

saveCurrentRowMethod · 0.80

Calls 9

DecodeDestinationFunction · 0.85
EncodeDestinationFunction · 0.85
validateAddressMethod · 0.80
setAddressBookMethod · 0.80
getNewDestinationMethod · 0.80
requestUnlockMethod · 0.80
getAddressMethod · 0.45
walletMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected