def setupMasternode(self, mnOwner, miner, masternodeAlias, mnOwnerDirPath, mnRemotePos, masternodePrivKey):
    self.log.info((('adding balance to the mn owner for ' + masternodeAlias) + '..'))
    mnAddress = mnOwner.getnewaddress(masternodeAlias)
    collateralTxId = miner.sendtoaddress(mnAddress, Decimal('10000'))
    self.stake_and_sync(self.nodes.index(miner), 1)
    assert_greater_than_or_equal(mnOwner.getbalance(), Decimal('10000'))
    assert_greater_than(mnOwner.getrawtransaction(collateralTxId, 1)['confirmations'], 0)
    self.log.info((('all good, creating masternode ' + masternodeAlias) + '..'))
    mnCollateralOutputIndex = (- 1)
    for mnc in mnOwner.getmasternodeoutputs():
        if (collateralTxId == mnc['txhash']):
            mnCollateralOutputIndex = mnc['outputidx']
            break
    assert_greater_than(mnCollateralOutputIndex, (- 1))
    self.log.info((('collateral accepted for ' + masternodeAlias) + '. Updating masternode.conf...'))
    confData = ('%s %s %s %s %d' % (masternodeAlias, ('127.0.0.1:' + str(p2p_port(mnRemotePos))), masternodePrivKey, collateralTxId, mnCollateralOutputIndex))
    destinationDirPath = mnOwnerDirPath
    destPath = os.path.join(destinationDirPath, 'masternode.conf')
    with open(destPath, 'a+') as file_object:
        file_object.write('\n')
        file_object.write(confData)
    mnOwner.lockunspent(False, [{'txid': collateralTxId, 'vout': mnCollateralOutputIndex}])
    return collateralTxId
def setupMasternode(self, mnOwner, miner, masternodeAlias, mnOwnerDirPath, mnRemotePos, masternodePrivKey):
    self.log.info((('adding balance to the mn owner for ' + masternodeAlias) + '..'))
    mnAddress = mnOwner.getnewaddress(masternodeAlias)
    collateralTxId = miner.sendtoaddress(mnAddress, Decimal('10000'))
    self.stake_and_sync(self.nodes.index(miner), 1)
    assert_greater_than_or_equal(mnOwner.getbalance(), Decimal('10000'))
    assert_greater_than(mnOwner.getrawtransaction(collateralTxId, 1)['confirmations'], 0)
    self.log.info((('all good, creating masternode ' + masternodeAlias) + '..'))
    mnCollateralOutputIndex = (- 1)
    for mnc in mnOwner.getmasternodeoutputs():
        if (collateralTxId == mnc['txhash']):
            mnCollateralOutputIndex = mnc['outputidx']
            break
    assert_greater_than(mnCollateralOutputIndex, (- 1))
    self.log.info((('collateral accepted for ' + masternodeAlias) + '. Updating masternode.conf...'))
    confData = ('%s %s %s %s %d' % (masternodeAlias, ('127.0.0.1:' + str(p2p_port(mnRemotePos))), masternodePrivKey, collateralTxId, mnCollateralOutputIndex))
    destinationDirPath = mnOwnerDirPath
    destPath = os.path.join(destinationDirPath, 'masternode.conf')
    with open(destPath, 'a+') as file_object:
        file_object.write('\n')
        file_object.write(confData)
    mnOwner.lockunspent(False, [{'txid': collateralTxId, 'vout': mnCollateralOutputIndex}])
    return collateralTxId