Search in sources :

Example 1 with Escrow

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;
}
Also used : Escrow(eu.cryptoeuro.accountmapper.domain.Escrow) EthereumAccount(eu.cryptoeuro.accountmapper.domain.EthereumAccount)

Example 2 with Escrow

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;
}
Also used : Escrow(eu.cryptoeuro.accountmapper.domain.Escrow) ECKey(org.ethereum.crypto.ECKey)

Example 3 with 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;
}
Also used : Escrow(eu.cryptoeuro.accountmapper.domain.Escrow) EscrowTransfer(eu.cryptoeuro.accountmapper.response.EscrowTransfer) ArrayList(java.util.ArrayList)

Aggregations

Escrow (eu.cryptoeuro.accountmapper.domain.Escrow)3 EthereumAccount (eu.cryptoeuro.accountmapper.domain.EthereumAccount)1 EscrowTransfer (eu.cryptoeuro.accountmapper.response.EscrowTransfer)1 ArrayList (java.util.ArrayList)1 ECKey (org.ethereum.crypto.ECKey)1