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

Method sendCoins

src/qt/walletmodel.cpp:276–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &transaction, wallet::BlindDetails *blind_details)
277{
278 QByteArray transaction_array; /* store serialized transaction */
279
280 {
281 std::vector<std::pair<std::string, std::string>> vOrderForm;
282 for (const SendCoinsRecipient &rcp : transaction.getRecipients())
283 {
284 if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example)
285 vOrderForm.emplace_back("Message", rcp.message.toStdString());
286 }
287
288 auto& newTx = transaction.getWtx();
289 wallet().commitTransaction(newTx, {} /* mapValue */, std::move(vOrderForm), blind_details);
290
291 CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
292 ssTx << *newTx;
293 transaction_array.append((const char*)ssTx.data(), ssTx.size());
294 }
295
296 // Add addresses / update labels that we've sent to the address book,
297 // and emit coinsSent signal for each recipient
298 for (const SendCoinsRecipient &rcp : transaction.getRecipients())
299 {
300 {
301 std::string strAddress = rcp.address.toStdString();
302 CTxDestination dest = DecodeDestination(strAddress);
303 std::string strLabel = rcp.label.toStdString();
304 {
305 // Check if we have a new address or an updated label
306 std::string name;
307 if (!m_wallet->getAddress(
308 dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr))
309 {
310 m_wallet->setAddressBook(dest, strLabel, "send");
311 }
312 else if (name != strLabel)
313 {
314 m_wallet->setAddressBook(dest, strLabel, ""); // "" means don't change purpose
315 }
316 }
317 }
318 Q_EMIT coinsSent(this, rcp, transaction_array);
319 }
320
321 checkBalanceChanged(m_wallet->getBalances()); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits
322
323 return SendCoinsReturn(OK);
324}
325
326OptionsModel *WalletModel::getOptionsModel()
327{

Callers 1

sendButtonClickedMethod · 0.80

Calls 10

DecodeDestinationFunction · 0.85
SendCoinsReturnClass · 0.85
getRecipientsMethod · 0.80
emplace_backMethod · 0.80
commitTransactionMethod · 0.80
setAddressBookMethod · 0.80
getBalancesMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
getAddressMethod · 0.45

Tested by

no test coverage detected