Adds support for NIP-06 seed word key derivation (bip32 and bip39)
This commit is contained in:
@@ -80,8 +80,6 @@ class Split<T>() {
|
||||
} else {
|
||||
splitItem.percentage = percentage
|
||||
|
||||
println("Update ${items[index].key} to $percentage")
|
||||
|
||||
val othersMustShare = 1.0f - splitItem.percentage
|
||||
|
||||
val othersHave =
|
||||
@@ -89,8 +87,6 @@ class Split<T>() {
|
||||
|
||||
if (abs(othersHave - othersMustShare) < 0.01) return // nothing to do
|
||||
|
||||
println("Others Must Share $othersMustShare but have $othersHave")
|
||||
|
||||
bottomUpAdjustment(othersMustShare, othersHave, index)
|
||||
}
|
||||
}
|
||||
@@ -109,14 +105,10 @@ class Split<T>() {
|
||||
val oldValue = items[i].percentage
|
||||
items[i].percentage -= needToRemove
|
||||
needToRemove = 0f
|
||||
println(
|
||||
"- Updating ${items[i].key} from $oldValue to ${items[i].percentage - needToRemove}. $needToRemove left",
|
||||
)
|
||||
} else {
|
||||
val oldValue = items[i].percentage
|
||||
needToRemove -= items[i].percentage
|
||||
items[i].percentage = 0f
|
||||
println("- Updating ${items[i].key} from $oldValue to ${0}. $needToRemove left")
|
||||
}
|
||||
|
||||
if (needToRemove < 0.01) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.vitorpamplona.amethyst.service.HttpClientManager
|
||||
import com.vitorpamplona.amethyst.service.relays.Client
|
||||
import com.vitorpamplona.quartz.crypto.CryptoUtils
|
||||
import com.vitorpamplona.quartz.crypto.KeyPair
|
||||
import com.vitorpamplona.quartz.crypto.nip06.Nip06
|
||||
import com.vitorpamplona.quartz.encoders.Hex
|
||||
import com.vitorpamplona.quartz.encoders.Nip19Bech32
|
||||
import com.vitorpamplona.quartz.encoders.bechToBytes
|
||||
@@ -127,6 +128,14 @@ class AccountStateViewModel() : ViewModel() {
|
||||
proxyPort = proxyPort,
|
||||
signer = NostrSignerInternal(keyPair),
|
||||
)
|
||||
} else if (key.contains(" ") && Nip06().isValidMnemonic(key)) {
|
||||
val keyPair = KeyPair(privKey = Nip06().privateKeyFromMnemonic(key))
|
||||
Account(
|
||||
keyPair,
|
||||
proxy = proxy,
|
||||
proxyPort = proxyPort,
|
||||
signer = NostrSignerInternal(keyPair),
|
||||
)
|
||||
} else if (pubKeyParsed != null) {
|
||||
val keyPair = KeyPair(pubKey = pubKeyParsed)
|
||||
Account(
|
||||
@@ -137,7 +146,7 @@ class AccountStateViewModel() : ViewModel() {
|
||||
)
|
||||
} else if (EMAIL_PATTERN.matcher(key).matches()) {
|
||||
val keyPair = KeyPair()
|
||||
// Evaluate NIP-5
|
||||
// TODO: Evaluate NIP-5
|
||||
Account(
|
||||
keyPair,
|
||||
proxy = proxy,
|
||||
|
||||
Reference in New Issue
Block a user