/
KeyManagerCreateApi.scala
62 lines (57 loc) · 2.04 KB
/
KeyManagerCreateApi.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package org.bitcoins.keymanager
import org.bitcoins.core.crypto.MnemonicCode
import org.bitcoins.keymanager.bip39.BIP39KeyManager
import scodec.bits.BitVector
/**
* @define initialize
* Initializes the wallet, generating a wallet seed.
* This seed should be displayed to the user, so they
* can write it down. They should also be prompted
* to confirm at least parts of the code.
* @define initializeWithEnt
* Initializes the with a user-provided seed,
* generating a wallet seed.
* This seed should be displayed to the user, so they
* can write it down. They should also be prompted
* to confirm at least parts of the code.
*/
trait BIP39KeyManagerCreateApi {
/**
* $initialize
*/
final def initialize(
kmParams: KeyManagerParams,
bip39PasswordOpt: Option[String]): Either[
KeyManagerInitializeError,
BIP39KeyManager] =
initializeWithEntropy(entropy = MnemonicCode.getEntropy256Bits,
bip39PasswordOpt = bip39PasswordOpt,
kmParams = kmParams)
/**
* $initializeWithEnt
*/
def initializeWithEntropy(
entropy: BitVector,
bip39PasswordOpt: Option[String],
kmParams: KeyManagerParams): Either[
KeyManagerInitializeError,
BIP39KeyManager]
/**
* Helper method to initialize a [[KeyManagerCreate$ KeyManager]] with a [[MnemonicCode MnemonicCode]]
*
* @param mnemonicCode
* @param kmParams
* @return
*/
final def initializeWithMnemonic(
mnemonicCode: MnemonicCode,
bip39PasswordOpt: Option[String],
kmParams: KeyManagerParams): Either[
KeyManagerInitializeError,
BIP39KeyManager] = {
val entropy = mnemonicCode.toEntropy
initializeWithEntropy(entropy = entropy,
bip39PasswordOpt = bip39PasswordOpt,
kmParams = kmParams)
}
}