Search in sources :

Example 1 with InsufficientFundsException

use of com.hedera.services.exceptions.InsufficientFundsException in project hedera-services by hashgraph.

the class CryptoCreateTransitionLogic method doStateTransition.

@Override
public void doStateTransition() {
    try {
        TransactionBody cryptoCreateTxn = txnCtx.accessor().getTxn();
        AccountID sponsor = cryptoCreateTxn.getTransactionID().getAccountID();
        CryptoCreateTransactionBody op = cryptoCreateTxn.getCryptoCreateAccount();
        long balance = op.getInitialBalance();
        final var created = ledger.create(sponsor, balance, asCustomizer(op));
        sigImpactHistorian.markEntityChanged(created.getAccountNum());
        txnCtx.setCreated(created);
        txnCtx.setStatus(SUCCESS);
    } catch (InsufficientFundsException ife) {
        txnCtx.setStatus(INSUFFICIENT_PAYER_BALANCE);
    } catch (Exception e) {
        log.warn("Avoidable exception!", e);
        txnCtx.setStatus(FAIL_INVALID);
    }
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) AccountID(com.hederahashgraph.api.proto.java.AccountID) CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) InsufficientFundsException(com.hedera.services.exceptions.InsufficientFundsException) InsufficientFundsException(com.hedera.services.exceptions.InsufficientFundsException)

Aggregations

InsufficientFundsException (com.hedera.services.exceptions.InsufficientFundsException)1 AccountID (com.hederahashgraph.api.proto.java.AccountID)1 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)1 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)1