@Asynchronous public void respondDepositConfMessage( Promise<BigDecimal> balance, Promise<BigDecimal> fee, Promise<DataSet> addr) { DataSet ds = addr.get(); Withdrawal dep = (Withdrawal) ds.getPayload(); BigDecimal bal = (dep.getBalance() != null) ? dep.getBalance() : balance.get(); BigDecimal f = (dep.getFee() != null) ? dep.getFee() : fee.get(); dep.setBalance(bal.subtract(f)); msgClient.sendMessage(ds); }
@Asynchronous public void setConfirm( @NoWait Settable<DataSet> account, OrPromise trigger, Promise<Action> isConfirmed, DataSet data) throws Throwable { if (isConfirmed.isReady()) { if (null != isConfirmed.get() && isConfirmed.get() != Action.WITHDRAWAL_REQ) { data.setAction(isConfirmed.get()); } account.set(data); } else { throw new Throwable("user did not confirm transaction."); } }
@Asynchronous public void respondTransactions(Promise<List<Transaction>> transactions, DataSet data) { data.setPayload(transactions.get()); msgClient.sendMessage(data); }
@Asynchronous public void cacheBalance(Promise<BigDecimal> balance, DataSet data) { data.setPayload(new Withdrawal().setBalance(balance.get())); msgClient.putCache(data); }
@Asynchronous public void respondBalance(Promise<BigDecimal> balance, Promise<BigDecimal> fee, DataSet data) { data.setPayload(new Withdrawal().setBalance(balance.get().subtract(fee.get()))); msgClient.sendMessage(data); }
@Asynchronous public void respondDataReq(Promise<String> bcAddress, DataSet data) { data.setPayload( new PaymentAddress().setAddress(bcAddress.get()).setAddressType(PaymentType.BTC)); msgClient.putAddressCache(data); }
@Asynchronous public void createAddress(Promise<Void> done, DataSet data) { Promise<String> bcAddress = bcdClient.getNewAddress(data.getCn()); respondDataReq(bcAddress, data); }