9
9
#include < qt/optionsmodel.h>
10
10
11
11
#include < chainparams.h>
12
+ #include < interface/node.h>
12
13
#include < policy/policy.h>
13
14
#include < key_io.h>
14
15
#include < ui_interface.h>
@@ -199,7 +200,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
199
200
// Warning: ipcSendCommandLine() is called early in init,
200
201
// so don't use "Q_EMIT message()", but "QMessageBox::"!
201
202
//
202
- void PaymentServer::ipcParseCommandLine (int argc, char * argv[])
203
+ void PaymentServer::ipcParseCommandLine (interface::Node& node, int argc, char * argv[])
203
204
{
204
205
for (int i = 1 ; i < argc; i++)
205
206
{
@@ -221,11 +222,11 @@ void PaymentServer::ipcParseCommandLine(int argc, char* argv[])
221
222
auto tempChainParams = CreateChainParams (CBaseChainParams::MAIN);
222
223
223
224
if (IsValidDestinationString (r.address .toStdString (), *tempChainParams)) {
224
- SelectParams (CBaseChainParams::MAIN);
225
+ node. selectParams (CBaseChainParams::MAIN);
225
226
} else {
226
227
tempChainParams = CreateChainParams (CBaseChainParams::TESTNET);
227
228
if (IsValidDestinationString (r.address .toStdString (), *tempChainParams)) {
228
- SelectParams (CBaseChainParams::TESTNET);
229
+ node. selectParams (CBaseChainParams::TESTNET);
229
230
}
230
231
}
231
232
}
@@ -239,11 +240,11 @@ void PaymentServer::ipcParseCommandLine(int argc, char* argv[])
239
240
{
240
241
if (request.getDetails ().network () == " main" )
241
242
{
242
- SelectParams (CBaseChainParams::MAIN);
243
+ node. selectParams (CBaseChainParams::MAIN);
243
244
}
244
245
else if (request.getDetails ().network () == " test" )
245
246
{
246
- SelectParams (CBaseChainParams::TESTNET);
247
+ node. selectParams (CBaseChainParams::TESTNET);
247
248
}
248
249
}
249
250
}
@@ -526,7 +527,7 @@ bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, Sen
526
527
527
528
if (request.IsInitialized ()) {
528
529
// Payment request network matches client network?
529
- if (!verifyNetwork (request.getDetails ())) {
530
+ if (!verifyNetwork (optionsModel-> node (), request.getDetails ())) {
530
531
Q_EMIT message (tr (" Payment request rejected" ), tr (" Payment request network doesn't match client network." ),
531
532
CClientUIInterface::MSG_ERROR);
532
533
@@ -583,7 +584,7 @@ bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, Sen
583
584
584
585
// Extract and check amounts
585
586
CTxOut txOut (sendingTo.second , sendingTo.first );
586
- if (IsDust (txOut, ::dustRelayFee )) {
587
+ if (IsDust (txOut, optionsModel-> node (). getDustRelayFee () )) {
587
588
Q_EMIT message (tr (" Payment request error" ), tr (" Requested payment amount of %1 is too small (considered dust)." )
588
589
.arg (BitcoinUnits::formatWithUnit (optionsModel->getDisplayUnit (), sendingTo.second )),
589
590
CClientUIInterface::MSG_ERROR);
@@ -621,7 +622,7 @@ void PaymentServer::fetchRequest(const QUrl& url)
621
622
netManager->get (netRequest);
622
623
}
623
624
624
- void PaymentServer::fetchPaymentACK (CWallet* wallet , const SendCoinsRecipient& recipient, QByteArray transaction)
625
+ void PaymentServer::fetchPaymentACK (WalletModel* walletModel , const SendCoinsRecipient& recipient, QByteArray transaction)
625
626
{
626
627
const payments::PaymentDetails& details = recipient.paymentRequest .getDetails ();
627
628
if (!details.has_payment_url ())
@@ -640,17 +641,17 @@ void PaymentServer::fetchPaymentACK(CWallet* wallet, const SendCoinsRecipient& r
640
641
641
642
// Create a new refund address, or re-use:
642
643
CPubKey newKey;
643
- if (wallet-> GetKeyFromPool ( newKey)) {
644
+ if (walletModel-> wallet (). getKeyFromPool ( false /* internal */ , newKey)) {
644
645
// BIP70 requests encode the scriptPubKey directly, so we are not restricted to address
645
646
// types supported by the receiver. As a result, we choose the address format we also
646
647
// use for change. Despite an actual payment and not change, this is a close match:
647
648
// it's the output type we use subject to privacy issues, but not restricted by what
648
649
// other software supports.
649
- const OutputType change_type = wallet-> m_default_change_type != OutputType::NONE ? wallet-> m_default_change_type : wallet-> m_default_address_type ;
650
- wallet-> LearnRelatedScripts (newKey, change_type);
650
+ const OutputType change_type = walletModel-> wallet (). getDefaultChangeType () != OutputType::NONE ? walletModel-> wallet (). getDefaultChangeType () : walletModel-> wallet (). getDefaultAddressType () ;
651
+ walletModel-> wallet (). learnRelatedScripts (newKey, change_type);
651
652
CTxDestination dest = GetDestinationForKey (newKey, change_type);
652
653
std::string label = tr (" Refund from %1" ).arg (recipient.authenticatedMerchant ).toStdString ();
653
- wallet-> SetAddressBook (dest, label, " refund" );
654
+ walletModel-> wallet (). setAddressBook (dest, label, " refund" );
654
655
655
656
CScript s = GetScriptForDestination (dest);
656
657
payments::Output* refund_to = payment.add_refund_to ();
@@ -758,14 +759,14 @@ void PaymentServer::handlePaymentACK(const QString& paymentACKMsg)
758
759
Q_EMIT message (tr (" Payment acknowledged" ), paymentACKMsg, CClientUIInterface::ICON_INFORMATION | CClientUIInterface::MODAL);
759
760
}
760
761
761
- bool PaymentServer::verifyNetwork (const payments::PaymentDetails& requestDetails)
762
+ bool PaymentServer::verifyNetwork (interface::Node& node, const payments::PaymentDetails& requestDetails)
762
763
{
763
- bool fVerified = requestDetails.network () == Params (). NetworkIDString ();
764
+ bool fVerified = requestDetails.network () == node. getNetwork ();
764
765
if (!fVerified ) {
765
766
qWarning () << QString (" PaymentServer::%1: Payment request network \" %2\" doesn't match client network \" %3\" ." )
766
767
.arg (__func__)
767
768
.arg (QString::fromStdString (requestDetails.network ()))
768
- .arg (QString::fromStdString (Params (). NetworkIDString ()));
769
+ .arg (QString::fromStdString (node. getNetwork ()));
769
770
}
770
771
return fVerified ;
771
772
}
0 commit comments