Search in sources :

Example 1 with AddressSecurityChangeRequest

use of run.wallet.iota.api.requests.AddressSecurityChangeRequest in project run-wallet-android by runplay.

the class AddressSecurityChangeRequestHandler method handle.

@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;
    AddressSecurityChangeRequest gnr = ((AddressSecurityChangeRequest) request);
    try {
        jota.dto.response.GetNewAddressResponse resp = apiProxy.getNewAddress(gnr.getAddress().getAddress(), gnr.getSecurity(), gnr.getAddress().getIndex(), false, 1, true);
        // Log.e("ADDRES-SECURITY","has response: "+resp.getAddresses().get(0));
        response = new GetNewAddressResponse(gnr.getSeed(), resp);
        Store.updateAddressFromSecurity(context, gnr, (GetNewAddressResponse) response);
        return new AddressSecurityChangeResponse();
    } catch (ArgumentException e) {
        response = new NetworkError();
    }
    return response;
}
Also used : GetNewAddressResponse(run.wallet.iota.api.responses.GetNewAddressResponse) AddressSecurityChangeRequest(run.wallet.iota.api.requests.AddressSecurityChangeRequest) AddressSecurityChangeResponse(run.wallet.iota.api.responses.AddressSecurityChangeResponse) NetworkError(run.wallet.iota.api.responses.error.NetworkError) ArgumentException(jota.error.ArgumentException) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Example 2 with AddressSecurityChangeRequest

use of run.wallet.iota.api.requests.AddressSecurityChangeRequest in project run-wallet-android by runplay.

the class AppService method addressSecurityChange.

public static void addressSecurityChange(Context context, Seeds.Seed seed, Address address, int security) {
    if (Validator.isValidCaller() && Store.getCurrentSeed() != null) {
        if (security < 1)
            security = 1;
        if (security > 3)
            security = 3;
        AddressSecurityChangeRequest rtr = new AddressSecurityChangeRequest(seed, address, security);
        TaskManager rt = new TaskManager(SERVICE);
        runTask(rt, rtr);
    }
}
Also used : AddressSecurityChangeRequest(run.wallet.iota.api.requests.AddressSecurityChangeRequest) TaskManager(run.wallet.iota.api.TaskManager)

Aggregations

AddressSecurityChangeRequest (run.wallet.iota.api.requests.AddressSecurityChangeRequest)2 ArgumentException (jota.error.ArgumentException)1 TaskManager (run.wallet.iota.api.TaskManager)1 AddressSecurityChangeResponse (run.wallet.iota.api.responses.AddressSecurityChangeResponse)1 ApiResponse (run.wallet.iota.api.responses.ApiResponse)1 GetNewAddressResponse (run.wallet.iota.api.responses.GetNewAddressResponse)1 NetworkError (run.wallet.iota.api.responses.error.NetworkError)1