33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#include " qt/pivx/masternodewizarddialog.h"
6- #include " optional.h"
7- #include " primitives/transaction.h"
86#include " qt/pivx/forms/ui_masternodewizarddialog.h"
97
108#include " key_io.h"
@@ -418,12 +416,12 @@ bool MasterNodeWizardDialog::createMN()
418416 auto r = walletModel->getNewAddress (alias);
419417 if (!r) return errorOut (tr (r.getError ().c_str ()));
420418 if (!mnModel->createMNCollateral (addressLabel,
421- QString::fromStdString (r.getObjResult ()->ToString ()),
422- collateralOut,
423- returnStr)) {
424- // error str set internally
425- return false ;
426- }
419+ QString::fromStdString (r.getObjResult ()->ToString ()),
420+ collateralOut,
421+ returnStr)) {
422+ // error str set internally
423+ return false ;
424+ }
427425 }
428426
429427 if (isDeterministic) {
@@ -447,7 +445,7 @@ bool MasterNodeWizardDialog::createMN()
447445 // 3) Get operator data
448446 QString operatorKey = ui->lineEditOperatorKey ->text ();
449447 Optional<CKeyID> operatorPayoutKeyId = walletModel->getKeyIDFromAddr (ui->lineEditOperatorPayoutAddress ->text ().toStdString ());
450- double operatorPercentage = ui->lineEditPercentage ->text ().isEmpty () ? 0 : (double ) ui->lineEditPercentage ->text ().toDouble ();
448+ double operatorPercentage = ui->lineEditPercentage ->text ().isEmpty () ? 0 : (double )ui->lineEditPercentage ->text ().toDouble ();
451449
452450 // 4) Get voter data
453451 Optional<CKeyID> votingAddr;
@@ -463,32 +461,32 @@ bool MasterNodeWizardDialog::createMN()
463461 votingAddr = ownerKeyId;
464462 }
465463
466- Optional<COutPoint> collateralOut = COutPoint ();
464+ Optional<COutPoint> collateralOut = COutPoint ();
467465 bool foundCandidate = false ;
468- if (!walletModel->getMNCollateralCandidate (*collateralOut)){
469- collateralOut= nullopt ;
470- }else {
471- // We have to lock the collateral or the system could spend it
466+ if (!walletModel->getMNCollateralCandidate (*collateralOut)) {
467+ collateralOut = nullopt ;
468+ } else {
469+ // We have to lock the collateral or the system could spend it
472470 walletModel->lockCoin (*collateralOut);
473471 foundCandidate = true ;
474472 }
475473 std::string error_str;
476-
474+
477475 auto res = mnModel->createDMN (alias,
478- collateralOut,
479- addressLabel,
480- ipAddress,
481- port,
482- ownerKeyId,
483- operatorKey.isEmpty () ? nullopt : Optional<std::string>(operatorKey.toStdString ()),
484- votingAddr,
485- payoutKeyId,
486- error_str,
487- (uint16_t ) operatorPercentage * 100 , // operator percentage
488- operatorPayoutKeyId); // operator payout script
476+ collateralOut,
477+ addressLabel,
478+ ipAddress,
479+ port,
480+ ownerKeyId,
481+ operatorKey.isEmpty () ? nullopt : Optional<std::string>(operatorKey.toStdString ()),
482+ votingAddr,
483+ payoutKeyId,
484+ error_str,
485+ (uint16_t )operatorPercentage * 100 , // operator percentage
486+ operatorPayoutKeyId); // operator payout script
489487 if (!res) {
490- // unlock in case of error
491- if (foundCandidate){
488+ // unlock in case of error
489+ if (foundCandidate) {
492490 walletModel->unlockCoin (*collateralOut);
493491 }
494492 return errorOut (tr (error_str.c_str ()));
@@ -497,18 +495,17 @@ bool MasterNodeWizardDialog::createMN()
497495 // future: move "operatorSk" to a constant field
498496 std::string operatorSk = walletModel->getStrFromTxExtraData (*res.getObjResult (), " operatorSk" );
499497 mnSummary = std::make_unique<MNSummary>(alias,
500- ipAddress+ " :" + port,
501- collateralOut? *collateralOut: COutPoint (UINT256_ZERO ,0 ), // TODO: the outpoint index is not 0 in general, but it does not matter (just display)
502- ownerAddrStr,
503- payoutAddrStr,
504- operatorSk.empty () ? operatorKey.toStdString () : operatorSk,
505- ownerAddrStr, // voting key, for now fixed to owner addr
506- 0 , // operator percentage
507- nullopt ); // operator payout
498+ ipAddress + " :" + port,
499+ collateralOut ? *collateralOut : COutPoint (UINT256_ZERO , 0 ), // TODO: the outpoint index is not 0 in general, but it does not matter (just display)
500+ ownerAddrStr,
501+ payoutAddrStr,
502+ operatorSk.empty () ? operatorKey.toStdString () : operatorSk,
503+ ownerAddrStr, // voting key, for now fixed to owner addr
504+ 0 , // operator percentage
505+ nullopt ); // operator payout
508506
509507 returnStr = tr (" Deterministic Masternode created! It will appear on your list on the next mined block!" );
510508 } else {
511-
512509 // Legacy
513510 // Look for a valid collateral utxo
514511 COutPoint collateralOut;
@@ -517,10 +514,10 @@ bool MasterNodeWizardDialog::createMN()
517514 // New receive address
518515 auto r = walletModel->getNewAddress (alias);
519516 if (!r) return errorOut (tr (r.getError ().c_str ()));
520- if (!mnModel->createDMNExternalCollateral (addressLabel,
521- QString::fromStdString (r.getObjResult ()->ToString ()),
522- collateralOut,
523- returnStr)) {
517+ if (!mnModel->createDMNExternalCollateral (addressLabel,
518+ QString::fromStdString (r.getObjResult ()->ToString ()),
519+ collateralOut,
520+ returnStr)) {
524521 // error str set internally
525522 return false ;
526523 }
0 commit comments