Search in sources :

Example 1 with AddressFormatException

use of co.rsk.bitcoinj.core.AddressFormatException in project rskj by rsksmart.

the class BridgeSupport method addOneOffLockWhitelistAddress.

/**
 * Adds the given address to the lock whitelist.
 * Returns 1 upon success, or -1 if the address was
 * already in the whitelist.
 * @param addressBase58 the base58-encoded address to add to the whitelist
 * @param maxTransferValue the max amount of satoshis enabled to transfer for this address
 * @return 1 upon success, -1 if the address was already
 * in the whitelist, -2 if address is invalid
 * LOCK_WHITELIST_GENERIC_ERROR_CODE otherwise.
 */
public Integer addOneOffLockWhitelistAddress(Transaction tx, String addressBase58, BigInteger maxTransferValue) {
    try {
        Address address = getParsedAddress(addressBase58);
        Coin maxTransferValueCoin = Coin.valueOf(maxTransferValue.longValueExact());
        return this.addLockWhitelistAddress(tx, new OneOffWhiteListEntry(address, maxTransferValueCoin));
    } catch (AddressFormatException e) {
        logger.warn(INVALID_ADDRESS_FORMAT_MESSAGE, e);
        return LOCK_WHITELIST_INVALID_ADDRESS_FORMAT_ERROR_CODE;
    }
}
Also used : Coin(co.rsk.bitcoinj.core.Coin) AddressFormatException(co.rsk.bitcoinj.core.AddressFormatException) Address(co.rsk.bitcoinj.core.Address) RskAddress(co.rsk.core.RskAddress) OneOffWhiteListEntry(co.rsk.peg.whitelist.OneOffWhiteListEntry)

Aggregations

Address (co.rsk.bitcoinj.core.Address)1 AddressFormatException (co.rsk.bitcoinj.core.AddressFormatException)1 Coin (co.rsk.bitcoinj.core.Coin)1 RskAddress (co.rsk.core.RskAddress)1 OneOffWhiteListEntry (co.rsk.peg.whitelist.OneOffWhiteListEntry)1