Example #1
0
  public CashMoneyWalletImpl(
      final PluginDatabaseSystem pluginDatabaseSystem,
      final UUID pluginId,
      final ErrorManager errorManager,
      String walletPublicKey)
      throws CantGetCashMoneyWalletException {
    this.pluginDatabaseSystem = pluginDatabaseSystem;
    this.pluginId = pluginId;
    this.errorManager = errorManager;
    this.walletPublicKey = walletPublicKey;

    try {
      this.dao = new CashMoneyWalletDao(pluginDatabaseSystem, pluginId, errorManager);
      dao.initialize();

      if (dao.walletExists(walletPublicKey)) this.walletPublicKey = walletPublicKey;
      else throw new CashMoneyWalletDoesNotExistException();

    } catch (Exception e) {
      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_CSH_WALLET_CASH_MONEY,
          UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
          e);
      throw new CantGetCashMoneyWalletException(
          CantGetCashMoneyWalletException.DEFAULT_MESSAGE, e, null, null);
    }
  }
Example #2
0
 @Override
 public void unhold(
     UUID transactionId,
     String publicKeyActor,
     String publicKeyPlugin,
     BigDecimal amount,
     String memo)
     throws CantRegisterUnholdException {
   try {
     CashMoneyWalletTransactionImpl transaction =
         new CashMoneyWalletTransactionImpl(
             transactionId,
             this.walletPublicKey,
             publicKeyActor,
             publicKeyPlugin,
             TransactionType.UNHOLD,
             BalanceType.AVAILABLE,
             amount,
             memo,
             (new Date().getTime() / 1000));
     dao.credit(this.walletPublicKey, BalanceType.AVAILABLE, amount);
     dao.registerTransaction(transaction);
   } catch (CantRegisterCashMoneyWalletTransactionException | CantRegisterCreditException e) {
     throw new CantRegisterUnholdException(
         CantRegisterHoldException.DEFAULT_MESSAGE,
         e,
         "Cant insert transaction record into database",
         null);
   }
 }
 @Override
 public List<CashMoney> getTransactionsCashMoney() throws CantTransactionCashMoneyException {
   try {
     return cashMoneyWalletDao.getTransactionsCashMoney();
   } catch (CantCreateCashMoneyException e) {
     throw new CantTransactionCashMoneyException(
         CantTransactionCashMoneyException.DEFAULT_MESSAGE,
         e,
         "Cant Transaction CashMoneyManagerImp Exception",
         "Cant Transaction CashMoneyManagerImp Exception");
   }
 }
 @Override
 public void start() throws CantStartPluginException {
   try {
     this.cashMoneyWalletDao = new CashMoneyWalletDao(pluginDatabaseSystem);
     cashMoneyWalletDao.initializeDatabase(pluginId);
     this.serviceStatus = ServiceStatus.STARTED;
   } catch (Exception exception) {
     throw new CantStartPluginException(
         CantStartPluginException.DEFAULT_MESSAGE,
         FermatException.wrapException(exception),
         null,
         null);
   }
 }
Example #5
0
 @Override
 public FiatCurrency getCurrency() throws CantGetCashMoneyWalletCurrencyException {
   return dao.getWalletCurrency(walletPublicKey);
 }
Example #6
0
 @Override
 public BigDecimal getHeldFunds(String actorPublicKey) throws CantGetHeldFundsException {
   return dao.getHeldFunds(walletPublicKey, actorPublicKey);
 }
Example #7
0
 @Override
 public List<CashMoneyWalletTransaction> getTransactions(
     List<TransactionType> transactionTypes, List<BalanceType> balanceTypes, int max, int offset)
     throws CantGetCashMoneyWalletTransactionsException {
   return dao.getTransactions(walletPublicKey, transactionTypes, balanceTypes, max, offset);
 }