Search in sources :

Example 1 with OAuthManager

use of com.samourai.wallet.util.oauth.OAuthManager in project samourai-wallet-android by Samourai-Wallet.

the class AndroidWhirlpoolWalletService method computeWhirlpoolWalletConfig.

protected WhirlpoolWalletConfig computeWhirlpoolWalletConfig(Context ctx, String walletIdentifier) throws Exception {
    WebUtil webUtil = WebUtil.getInstance(ctx);
    TorManager torManager = TorManager.getInstance(ctx);
    String dojoParams = DojoUtil.getInstance(ctx).getDojoParams();
    boolean useDojo = (dojoParams != null);
    boolean testnet = SamouraiWallet.getInstance().isTestNet();
    boolean onion = useDojo || torManager.isRequired();
    Log.v(TAG, "whirlpoolWalletConfig[Tor] = onion=" + onion + ", useDojo=" + useDojo + ", torManager.isRequired=" + torManager.isRequired());
    String scode = WhirlpoolMeta.getInstance(ctx).getSCODE();
    // backend configuration
    String backendUrl;
    Optional<OAuthManager> oAuthManager;
    if (useDojo) {
        // dojo backend
        backendUrl = DojoUtil.getInstance(ctx).getUrl(dojoParams);
        APIFactory apiFactory = APIFactory.getInstance(ctx);
        oAuthManager = Optional.of(new AndroidOAuthManager(apiFactory));
    } else {
        // samourai backend
        backendUrl = BackendServer.get(testnet).getBackendUrl(onion);
        oAuthManager = Optional.empty();
    }
    IHttpClient httpClient = new AndroidHttpClient(webUtil, torManager);
    BackendApi backendApi = new BackendApi(httpClient, backendUrl, oAuthManager);
    File fileIndex = whirlpoolUtils.computeIndexFile(walletIdentifier, ctx);
    File fileUtxo = whirlpoolUtils.computeUtxosFile(walletIdentifier, ctx);
    WhirlpoolWalletPersistHandler persistHandler = new FileWhirlpoolWalletPersistHandler(fileIndex, fileUtxo);
    return computeWhirlpoolWalletConfig(torManager, persistHandler, testnet, onion, MIXS_TARGET_DEFAULT, scode, httpClient, backendApi);
}
Also used : OAuthManager(com.samourai.wallet.util.oauth.OAuthManager) AndroidOAuthManager(com.samourai.http.client.AndroidOAuthManager) BackendApi(com.samourai.wallet.api.backend.BackendApi) IHttpClient(com.samourai.http.client.IHttpClient) FileWhirlpoolWalletPersistHandler(com.samourai.whirlpool.client.wallet.persist.FileWhirlpoolWalletPersistHandler) AndroidHttpClient(com.samourai.http.client.AndroidHttpClient) APIFactory(com.samourai.wallet.api.APIFactory) WebUtil(com.samourai.wallet.util.WebUtil) FileWhirlpoolWalletPersistHandler(com.samourai.whirlpool.client.wallet.persist.FileWhirlpoolWalletPersistHandler) WhirlpoolWalletPersistHandler(com.samourai.whirlpool.client.wallet.persist.WhirlpoolWalletPersistHandler) AndroidOAuthManager(com.samourai.http.client.AndroidOAuthManager) TorManager(com.samourai.wallet.tor.TorManager) File(java.io.File)

Aggregations

AndroidHttpClient (com.samourai.http.client.AndroidHttpClient)1 AndroidOAuthManager (com.samourai.http.client.AndroidOAuthManager)1 IHttpClient (com.samourai.http.client.IHttpClient)1 APIFactory (com.samourai.wallet.api.APIFactory)1 BackendApi (com.samourai.wallet.api.backend.BackendApi)1 TorManager (com.samourai.wallet.tor.TorManager)1 WebUtil (com.samourai.wallet.util.WebUtil)1 OAuthManager (com.samourai.wallet.util.oauth.OAuthManager)1 FileWhirlpoolWalletPersistHandler (com.samourai.whirlpool.client.wallet.persist.FileWhirlpoolWalletPersistHandler)1 WhirlpoolWalletPersistHandler (com.samourai.whirlpool.client.wallet.persist.WhirlpoolWalletPersistHandler)1 File (java.io.File)1