private void addExistinPaymentAdresses() { List<Investor> listInvestors = investorRepository.findAllByOrderByCreationDateAsc(); listInvestors.stream().forEach((investor) -> { long timestamp = investor.getCreationDate().toInstant().getEpochSecond(); ofNullable(investor.getPayInBitcoinAddress()).ifPresent((bitcoinAddress) -> { bitcoinMonitor.addPaymentAddressesForMonitoring(bitcoinAddress, timestamp); }); ofNullable(investor.getPayInEtherAddress()).ifPresent((etherAddress) -> { ethereumMonitor.addPaymentAddressesForMonitoring(etherAddress, timestamp); }); }); }
@RequestMapping(value = "/register/{emailConfirmationToken}/validate", method = GET) public ResponseEntity<?> isConfirmationTokenValid(@Valid @Size(max = Constants.UUID_CHAR_MAX_SIZE) @PathVariable("emailConfirmationToken") String emailConfirmationToken, @Context HttpServletRequest requestContext) throws BaseException { // Get IP address from request String ipAddress = IPAddressUtil.getIPAddress(requestContext); LOG.info("/validate called from {} with token {}", ipAddress, emailConfirmationToken); Optional<Investor> oInvestor = Optional.empty(); try { oInvestor = investorRepository.findOptionalByEmailConfirmationToken(emailConfirmationToken); } catch (Exception e) { throw new UnexpectedException(); } if (!oInvestor.isPresent()) { throw new ConfirmationTokenNotFoundException(); } if (oInvestor.get().getWalletAddress() == null) { return ResponseEntity.ok().build(); } else { AddressResponse addressResponse = new AddressResponse() .setBtc(oInvestor.get().getPayInBitcoinAddress()) .setEther(oInvestor.get().getPayInEtherAddress()); return new ResponseEntity<>(addressResponse, HttpStatus.OK); } }
&& oInvestor.get().getPayInBitcoinAddress() != null && oInvestor.get().getPayInEtherAddress() != null) { SummaryEmailMessage summaryEmailMessage = new SummaryEmailMessage(build(oInvestor.get()));
@Test public void testFindByPayInBitcoinPublicKey() { Investor i = createInvestor(); investorRepository.save(i); Optional<Investor> oInvestor = investorRepository.findOptionalByPayInBitcoinAddress("payInBitcoin1"); assertTrue(oInvestor.isPresent()); assertTrue(oInvestor.filter((investor) -> investor.getPayInBitcoinAddress().equals("payInBitcoin1")).isPresent()); }
context.setVariable("payInBitcoinAddress", oInvestor.get().getPayInBitcoinAddress()); context.setVariable("refundEtherAddress", oInvestor.get().getRefundEtherAddress()); context.setVariable("refundBitcoinAddress", oInvestor.get().getRefundBitcoinAddress()); .from(oInvestor.get().getPayInBitcoinAddress()) .to(ImageType.PNG) .withSize(265, 200)
public static InvestorMessageDTO build(Investor investor) { return new InvestorMessageDTO( investor.getCreationDate(), investor.getEmail(), investor.getEmailConfirmationToken(), investor.getWalletAddress(), investor.getPayInEtherAddress(), investor.getPayInBitcoinAddress(), investor.getRefundEtherAddress(), investor.getRefundBitcoinAddress(), investor.getIpAddress() ); }