diff --git a/secretk/src/commonMain/kotlin/io/eqoty/secretk/wallet/BaseWallet.kt b/secretk/src/commonMain/kotlin/io/eqoty/secretk/wallet/BaseWallet.kt index e21d2ec..e8bfaf5 100644 --- a/secretk/src/commonMain/kotlin/io/eqoty/secretk/wallet/BaseWallet.kt +++ b/secretk/src/commonMain/kotlin/io/eqoty/secretk/wallet/BaseWallet.kt @@ -43,7 +43,7 @@ interface Wallet { } sealed class BaseWallet( - mnemonic: String, + mnemonic: String?, hdPath: Array = makeSecretNetworkPath(0.toUInt()), bech32Prefix: String = "secret" ) : Wallet { @@ -53,7 +53,11 @@ sealed class BaseWallet( protected var address: String init { - val seed = Mnemonics.MnemonicCode(mnemonic).toSeed().toUByteArray() + val seed = if (mnemonic != null) { + Mnemonics.MnemonicCode(mnemonic).toSeed().toUByteArray() + } else { + Mnemonics.MnemonicCode(Mnemonics.WordCount.COUNT_12).toSeed().toUByteArray() + } val result = Slip10.derivePath(Slip10Curve.Secp256k1, seed, hdPath) privkey = result.privkey val uncompressed = Secp256k1.makeKeypair(privkey).pubkey diff --git a/secretk/src/commonMain/kotlin/io/eqoty/secretk/wallet/DirectSigningWallet.kt b/secretk/src/commonMain/kotlin/io/eqoty/secretk/wallet/DirectSigningWallet.kt index 894c352..25e1ad0 100644 --- a/secretk/src/commonMain/kotlin/io/eqoty/secretk/wallet/DirectSigningWallet.kt +++ b/secretk/src/commonMain/kotlin/io/eqoty/secretk/wallet/DirectSigningWallet.kt @@ -7,8 +7,12 @@ import kotlinx.serialization.protobuf.ProtoBuf class DirectSigningWallet( - mnemonic: String, + mnemonic: String?, ) : BaseWallet(mnemonic) { + + // helper constructor for swift + constructor() : this(null) + override suspend fun getSignMode(): SignMode? = null fun signDirect(address: String, signDoc: SignDocProto): SignResponse {