use of eu.cryptoeuro.accountmapper.domain.Escrow in project account-identity by cryptofiat.
the class EscrowService method approveEscrowAccountForId.
public EthereumAccount approveEscrowAccountForId(long idCode) throws IOException {
Escrow escrow = createEscrowKey(idCode);
EthereumAccount ethAccount = accountService.storeNewAccount(escrow.getAddress(), String.valueOf(escrow.getIdCode()), AuthorisationType.ESCROW);
String txHash = ethereumService.activateEthereumAccount(escrow.getAddress());
accountService.markActivated(ethAccount, txHash);
escrowRepository.save(escrow);
return ethAccount;
}
use of eu.cryptoeuro.accountmapper.domain.Escrow in project account-identity by cryptofiat.
the class EscrowService method createEscrowKey.
public Escrow createEscrowKey(long idCode) {
ECKey key = new ECKey();
Escrow escrow = Escrow.builder().privateKey(encUtils.encrypt(ethereumService.hex(key.getPrivKeyBytes()))).address(ethereumService.hex(key.getAddress())).idCode(idCode).build();
return escrow;
}
use of eu.cryptoeuro.accountmapper.domain.Escrow in project account-identity by cryptofiat.
the class EscrowService method clearAllToAddress.
public List<EscrowTransfer> clearAllToAddress(long idCode, String address) throws IOException, JSONException {
Escrow escrow;
List<EscrowTransfer> etxs = new ArrayList<EscrowTransfer>();
// Need to wait until the new account approval has been mined
// doesn't work for multiple, because of eth nonce - need to create queue
// assuming that this is always called after Account Approval tx
int nonceIncrement = 1;
while ((escrow = getExistingEscrow(idCode)) != null) {
List<EscrowTransfer> transfers = clearToAddress(escrow, address, nonceIncrement);
if (transfers != null) {
etxs.addAll(transfers);
// should change for multiple escrow tx per addr
escrow.setClearingHash(transfers.get(0).getTransactionHash());
}
escrow.setCleared(true);
escrowRepository.save(escrow);
}
return etxs;
}
Aggregations