Search in sources :

Example 1 with SeedWords

use of network.bisq.api.model.SeedWords in project bisq-api by mrosseel.

the class BisqProxy method getSeedWords.

public SeedWords getSeedWords(String password) {
    final DeterministicSeed keyChainSeed = btcWalletService.getKeyChainSeed();
    final WalletsManager walletsManager = injector.getInstance(WalletsManager.class);
    final LocalDate walletCreationDate = Instant.ofEpochSecond(walletsManager.getChainSeedCreationTimeSeconds()).atZone(ZoneId.systemDefault()).toLocalDate();
    DeterministicSeed seed = keyChainSeed;
    if (keyChainSeed.isEncrypted()) {
        if (null == password)
            throw new UnauthorizedException();
        final KeyParameter aesKey = getAESKey(password);
        if (!isWalletPasswordValid(aesKey))
            throw new UnauthorizedException();
        seed = walletsManager.getDecryptedSeed(aesKey, btcWalletService.getKeyChainSeed(), btcWalletService.getKeyCrypter());
    }
    return new SeedWords(seed.getMnemonicCode(), walletCreationDate.toString());
}
Also used : DeterministicSeed(org.bitcoinj.wallet.DeterministicSeed) WalletsManager(bisq.core.btc.wallet.WalletsManager) SeedWords(network.bisq.api.model.SeedWords) KeyParameter(org.spongycastle.crypto.params.KeyParameter) LocalDate(java.time.LocalDate)

Aggregations

WalletsManager (bisq.core.btc.wallet.WalletsManager)1 LocalDate (java.time.LocalDate)1 SeedWords (network.bisq.api.model.SeedWords)1 DeterministicSeed (org.bitcoinj.wallet.DeterministicSeed)1 KeyParameter (org.spongycastle.crypto.params.KeyParameter)1