Search in sources :

Example 1 with WalletExtension

use of org.bitcoinj.wallet.WalletExtension in project bisq-core by bisq-network.

the class WalletConfig method loadWallet.

private Wallet loadWallet(File walletFile, boolean shouldReplayWallet, boolean useBitcoinDeterministicKeyChain) throws Exception {
    Wallet wallet;
    try (FileInputStream walletStream = new FileInputStream(walletFile)) {
        List<WalletExtension> extensions = provideWalletExtensions();
        WalletExtension[] extArray = extensions.toArray(new WalletExtension[extensions.size()]);
        Protos.Wallet proto = WalletProtobufSerializer.parseToProto(walletStream);
        final WalletProtobufSerializer serializer;
        if (walletFactory != null)
            serializer = new WalletProtobufSerializer(walletFactory);
        else
            serializer = new WalletProtobufSerializer();
        serializer.setKeyChainFactory(new BisqKeyChainFactory(useBitcoinDeterministicKeyChain));
        wallet = serializer.readWallet(params, extArray, proto);
        if (shouldReplayWallet)
            wallet.reset();
    }
    return wallet;
}
Also used : WalletExtension(org.bitcoinj.wallet.WalletExtension) Protos(org.bitcoinj.wallet.Protos) Wallet(org.bitcoinj.wallet.Wallet) FileInputStream(java.io.FileInputStream) WalletProtobufSerializer(org.bitcoinj.wallet.WalletProtobufSerializer)

Aggregations

FileInputStream (java.io.FileInputStream)1 Protos (org.bitcoinj.wallet.Protos)1 Wallet (org.bitcoinj.wallet.Wallet)1 WalletExtension (org.bitcoinj.wallet.WalletExtension)1 WalletProtobufSerializer (org.bitcoinj.wallet.WalletProtobufSerializer)1