my wallet downloading and synchronizing get lots of time. how to resolve it?

by Sidhesh M   Last Updated August 01, 2018 13:27 PM

public class xyz {
    private static WalletAppKit kit;
    private static NetworkParameters params = TestNet3Params.get();
    private File file;

    public xyz(File file) throws BlockStoreException {
        this.file = file;
    }

    public static void refresh() throws ExecutionException, InterruptedException {
    }

    public void initialdownload(String btcpri, Context context) {
        ECKey key;
        BigInteger privKey = Base58.decodeToBigInteger(btcpri);
        key = ECKey.fromPrivate(privKey);
        setSDKThread();
        BriefLogFormatter.init();

        kit = new WalletAppKit(params, file, "bitcoin_wallet") {
            @Override
            protected void onSetupCompleted() {
                wallet().importKey(key);
                wallet().allowSpendingUnconfirmedTransactions();
                setupWalletListeners(wallet());
            }
        };
        kit.setDownloadListener(new DownloadProgressTracker() {
            @Override
            protected void progress(double pct, int blocksSoFar, Date date) {
                super.progress(pct, blocksSoFar, date);
            }

            @Override
            protected void doneDownload() {
                super.doneDownload();
            }
        });
        kit.setBlockingStartup(false);
        kit.startAsync();
    }

    private void setSDKThread() {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                final Handler handler = new Handler();
                Threading.USER_THREAD = handler::post;
            }
        });
    }

    private void setupWalletListeners(Wallet wallet) {
        wallet.addCoinsReceivedEventListener((wallet1, tx, prevBalance, newBalance) -> {
            if (tx.getPurpose() == Transaction.Purpose.UNKNOWN);
        });
        wallet.addCoinsSentEventListener((wallet12, tx, prevBalance, newBalance) -> {
        });
    }
}


Related Questions





how to use bitcoinj for litecoin in android?

Updated August 04, 2018 06:27 AM

how to use bitcoinj for Litecoin wallet?

Updated August 08, 2018 14:27 PM