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"
@@ -410,22 +408,6 @@ bool MasterNodeWizardDialog::createMN()
410408 std::string ipAddress = addressStr.toStdString ();
411409 std::string port = portStr.toStdString ();
412410
413- // Look for a valid collateral utxo
414- COutPoint collateralOut;
415-
416- if (!walletModel->getMNCollateralCandidate (collateralOut)) {
417- // New receive address
418- auto r = walletModel->getNewAddress (alias);
419- if (!r) return errorOut (tr (r.getError ().c_str ()));
420- if (!mnModel->createMNCollateral (addressLabel,
421- QString::fromStdString (r.getObjResult ()->ToString ()),
422- collateralOut,
423- returnStr)) {
424- // error str set internally
425- return false ;
426- }
427- }
428-
429411 if (isDeterministic) {
430412 auto opOwnerAddrAndKeyId = getOrCreateOwnerAddress (alias);
431413 if (!opOwnerAddrAndKeyId.getRes ()) {
@@ -447,7 +429,7 @@ bool MasterNodeWizardDialog::createMN()
447429 // 3) Get operator data
448430 QString operatorKey = ui->lineEditOperatorKey ->text ();
449431 Optional<CKeyID> operatorPayoutKeyId = walletModel->getKeyIDFromAddr (ui->lineEditOperatorPayoutAddress ->text ().toStdString ());
450- double operatorPercentage = ui->lineEditPercentage ->text ().isEmpty () ? 0 : (double ) ui->lineEditPercentage ->text ().toDouble ();
432+ double operatorPercentage = ui->lineEditPercentage ->text ().isEmpty () ? 0 : (double )ui->lineEditPercentage ->text ().toDouble ();
451433
452434 // 4) Get voter data
453435 Optional<CKeyID> votingAddr;
@@ -463,32 +445,32 @@ bool MasterNodeWizardDialog::createMN()
463445 votingAddr = ownerKeyId;
464446 }
465447
466- Optional<COutPoint> collateralOut = COutPoint ();
448+ Optional<COutPoint> collateralOut = COutPoint ();
467449 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
450+ if (!walletModel->getMNCollateralCandidate (*collateralOut)) {
451+ collateralOut = nullopt ;
452+ } else {
453+ // We have to lock the collateral or the system could spend it
472454 walletModel->lockCoin (*collateralOut);
473455 foundCandidate = true ;
474456 }
475457 std::string error_str;
476-
458+
477459 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
460+ collateralOut,
461+ addressLabel,
462+ ipAddress,
463+ port,
464+ ownerKeyId,
465+ operatorKey.isEmpty () ? nullopt : Optional<std::string>(operatorKey.toStdString ()),
466+ votingAddr,
467+ payoutKeyId,
468+ error_str,
469+ (uint16_t )operatorPercentage * 100 , // operator percentage
470+ operatorPayoutKeyId); // operator payout script
489471 if (!res) {
490- // unlock in case of error
491- if (foundCandidate){
472+ // unlock in case of error
473+ if (foundCandidate) {
492474 walletModel->unlockCoin (*collateralOut);
493475 }
494476 return errorOut (tr (error_str.c_str ()));
@@ -497,18 +479,17 @@ bool MasterNodeWizardDialog::createMN()
497479 // future: move "operatorSk" to a constant field
498480 std::string operatorSk = walletModel->getStrFromTxExtraData (*res.getObjResult (), " operatorSk" );
499481 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
482+ ipAddress + " :" + port,
483+ collateralOut ? *collateralOut : COutPoint (UINT256_ZERO , 0 ), // TODO: the outpoint index is not 0 in general, but it does not matter (just display)
484+ ownerAddrStr,
485+ payoutAddrStr,
486+ operatorSk.empty () ? operatorKey.toStdString () : operatorSk,
487+ ownerAddrStr, // voting key, for now fixed to owner addr
488+ 0 , // operator percentage
489+ nullopt ); // operator payout
508490
509491 returnStr = tr (" Deterministic Masternode created! It will appear on your list on the next mined block!" );
510492 } else {
511-
512493 // Legacy
513494 // Look for a valid collateral utxo
514495 COutPoint collateralOut;
@@ -517,10 +498,10 @@ bool MasterNodeWizardDialog::createMN()
517498 // New receive address
518499 auto r = walletModel->getNewAddress (alias);
519500 if (!r) return errorOut (tr (r.getError ().c_str ()));
520- if (!mnModel->createDMNExternalCollateral (addressLabel,
521- QString::fromStdString (r.getObjResult ()->ToString ()),
522- collateralOut,
523- returnStr)) {
501+ if (!mnModel->createDMNExternalCollateral (addressLabel,
502+ QString::fromStdString (r.getObjResult ()->ToString ()),
503+ collateralOut,
504+ returnStr)) {
524505 // error str set internally
525506 return false ;
526507 }
0 commit comments