mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
315e92d645
48439b3c10391e5f5555c7d98e1a99706b77eaf7 Don't link SSL_LIBS with GUI unless BIP70 is enabled (James Hilliard) fbb643d2a55ade3c06593a7490601acd2e36dce8 Add BIP70 deprecation warning (James Hilliard) 38b98507cdda02ff02a524d41bcc3427ca9e4fd9 qt: cleanup: Move BIP70 functions together in paymentserver (Wladimir J. van der Laan) 9dcf6c0dfec51f2a49edef537f377422d6dbdceb build: Add --disable-bip70 configure option (Wladimir J. van der Laan) Pull request description: This is based off of #11622 and adds a deprecation warning when a BIP70 URL is used. Rational: - BIP70 increases attack surface in multiple ways and is difficult for third party wallets to implement in a secure manner - Very few merchants use the standard BIP70 variant supported by Bitcoin Core - The one major payment processor that doesn't support BIP21 and currently uses a customized non-standard version of BIP70 has indicated that "Unfortunately the original BIP70 is not useful for us." Tree-SHA512: 1e16ee8d2cdac9499f751ee7b50d058278150f9e38a87a47ddb5105dd0353cdedabe462903f54ead6209b249b249fe5e6a10d29631531be27400f2f69c25b9b9
95 lines
2.8 KiB
C++
95 lines
2.8 KiB
C++
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config/dash-config.h>
|
|
#endif
|
|
|
|
#include <qt/walletmodeltransaction.h>
|
|
|
|
#include <interfaces/node.h>
|
|
#include <key_io.h>
|
|
|
|
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &_recipients) :
|
|
recipients(_recipients),
|
|
fee(0)
|
|
{
|
|
}
|
|
|
|
QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const
|
|
{
|
|
return recipients;
|
|
}
|
|
|
|
std::unique_ptr<interfaces::PendingWalletTx>& WalletModelTransaction::getWtx()
|
|
{
|
|
return wtx;
|
|
}
|
|
|
|
unsigned int WalletModelTransaction::getTransactionSize()
|
|
{
|
|
return wtx != nullptr ? ::GetSerializeSize(wtx->get(), SER_NETWORK, PROTOCOL_VERSION) : 0;
|
|
}
|
|
|
|
CAmount WalletModelTransaction::getTransactionFee() const
|
|
{
|
|
return fee;
|
|
}
|
|
|
|
void WalletModelTransaction::setTransactionFee(const CAmount& newFee)
|
|
{
|
|
fee = newFee;
|
|
}
|
|
|
|
void WalletModelTransaction::reassignAmounts()
|
|
{
|
|
// For each recipient look for a matching CTxOut in walletTransaction and reassign amounts
|
|
for (QList<SendCoinsRecipient>::iterator it = recipients.begin(); it != recipients.end(); ++it)
|
|
{
|
|
SendCoinsRecipient& rcp = (*it);
|
|
|
|
#ifdef ENABLE_BIP70
|
|
if (rcp.paymentRequest.IsInitialized())
|
|
{
|
|
CAmount subtotal = 0;
|
|
const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
|
|
for (int j = 0; j < details.outputs_size(); j++)
|
|
{
|
|
const payments::Output& out = details.outputs(j);
|
|
if (out.amount() <= 0) continue;
|
|
const unsigned char* scriptStr = (const unsigned char*)out.script().data();
|
|
CScript scriptPubKey(scriptStr, scriptStr+out.script().size());
|
|
for (const auto& txout : wtx->get().vout) {
|
|
if (txout.scriptPubKey == scriptPubKey) {
|
|
subtotal += txout.nValue;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
rcp.amount = subtotal;
|
|
}
|
|
else // normal recipient (no payment request)
|
|
#endif
|
|
{
|
|
for (const auto& txout : wtx->get().vout) {
|
|
CScript scriptPubKey = GetScriptForDestination(DecodeDestination(rcp.address.toStdString()));
|
|
if (txout.scriptPubKey == scriptPubKey) {
|
|
rcp.amount = txout.nValue;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
CAmount WalletModelTransaction::getTotalTransactionAmount() const
|
|
{
|
|
CAmount totalTransactionAmount = 0;
|
|
for (const SendCoinsRecipient &rcp : recipients)
|
|
{
|
|
totalTransactionAmount += rcp.amount;
|
|
}
|
|
return totalTransactionAmount;
|
|
}
|