Changeset View
Changeset View
Standalone View
Standalone View
src/qt/paymentserver.cpp
Show First 20 Lines • Show All 697 Lines • ▼ Show 20 Lines | void PaymentServer::fetchPaymentACK(CWallet *wallet, | ||||
netRequest.setRawHeader("User-Agent", CLIENT_NAME.c_str()); | netRequest.setRawHeader("User-Agent", CLIENT_NAME.c_str()); | ||||
netRequest.setRawHeader("Accept", BIP71_MIMETYPE_PAYMENTACK); | netRequest.setRawHeader("Accept", BIP71_MIMETYPE_PAYMENTACK); | ||||
payments::Payment payment; | payments::Payment payment; | ||||
payment.set_merchant_data(details.merchant_data()); | payment.set_merchant_data(details.merchant_data()); | ||||
payment.add_transactions(transaction.data(), transaction.size()); | payment.add_transactions(transaction.data(), transaction.size()); | ||||
// Create a new refund address, or re-use: | // Create a new refund address, or re-use: | ||||
QString account = tr("Refund from %1").arg(recipient.authenticatedMerchant); | std::string label = | ||||
std::string strAccount = account.toStdString(); | tr("Refund from %1").arg(recipient.authenticatedMerchant).toStdString(); | ||||
std::set<CTxDestination> refundAddresses = | std::set<CTxDestination> refundAddresses = wallet->GetLabelAddresses(label); | ||||
wallet->GetAccountAddresses(strAccount); | |||||
if (!refundAddresses.empty()) { | if (!refundAddresses.empty()) { | ||||
CScript s = GetScriptForDestination(*refundAddresses.begin()); | CScript s = GetScriptForDestination(*refundAddresses.begin()); | ||||
payments::Output *refund_to = payment.add_refund_to(); | payments::Output *refund_to = payment.add_refund_to(); | ||||
refund_to->set_script(&s[0], s.size()); | refund_to->set_script(&s[0], s.size()); | ||||
} else { | } else { | ||||
CPubKey newKey; | CPubKey newKey; | ||||
if (wallet->GetKeyFromPool(newKey)) { | if (wallet->GetKeyFromPool(newKey)) { | ||||
CKeyID keyID = newKey.GetID(); | CKeyID keyID = newKey.GetID(); | ||||
wallet->SetAddressBook(keyID, strAccount, "refund"); | wallet->SetAddressBook(keyID, label, "refund"); | ||||
CScript s = GetScriptForDestination(keyID); | CScript s = GetScriptForDestination(keyID); | ||||
payments::Output *refund_to = payment.add_refund_to(); | payments::Output *refund_to = payment.add_refund_to(); | ||||
refund_to->set_script(&s[0], s.size()); | refund_to->set_script(&s[0], s.size()); | ||||
} else { | } else { | ||||
// This should never happen, because sending coins should have just | // This should never happen, because sending coins should have just | ||||
// unlocked the wallet and refilled the keypool. | // unlocked the wallet and refilled the keypool. | ||||
qWarning() << "PaymentServer::fetchPaymentACK: Error getting " | qWarning() << "PaymentServer::fetchPaymentACK: Error getting " | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |