mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-07-22 17:15:48 +00:00
feat: Bitcoin key derivation, secrets storage, and chain-family plumbing
Derives a BIP84 (native SegWit) keypair alongside the existing substrate/ ethereum/tron ones, stores it in MetaAccountSecrets/CloudBackup, persists bitcoinPublicKey/bitcoinAddress on meta_accounts (DB migration 74->75), and threads isBitcoinBased through Chain/ChainLocal/mappers/ChainExt/ChainRegistry the same way isTronBased was wired. Adds BitcoinAddressBackfillMigration, mirroring TronAddressBackfillMigration, so existing wallets get a Bitcoin address without re-import.
This commit is contained in:
+20
@@ -28,6 +28,9 @@ object MetaAccountSecrets : Schema<MetaAccountSecrets>() {
|
||||
|
||||
val TronKeypair by schema(KeyPairSchema).optional()
|
||||
val TronDerivationPath by string().optional()
|
||||
|
||||
val BitcoinKeypair by schema(KeyPairSchema).optional()
|
||||
val BitcoinDerivationPath by string().optional()
|
||||
}
|
||||
|
||||
object ChainAccountSecrets : Schema<ChainAccountSecrets>() {
|
||||
@@ -47,6 +50,8 @@ fun MetaAccountSecrets(
|
||||
ethereumDerivationPath: String? = null,
|
||||
tronKeypair: Keypair? = null,
|
||||
tronDerivationPath: String? = null,
|
||||
bitcoinKeypair: Keypair? = null,
|
||||
bitcoinDerivationPath: String? = null,
|
||||
): EncodableStruct<MetaAccountSecrets> = MetaAccountSecrets { secrets ->
|
||||
secrets[Entropy] = entropy
|
||||
secrets[SubstrateSeed] = substrateSeed
|
||||
@@ -75,6 +80,15 @@ fun MetaAccountSecrets(
|
||||
}
|
||||
}
|
||||
secrets[TronDerivationPath] = tronDerivationPath
|
||||
|
||||
secrets[BitcoinKeypair] = bitcoinKeypair?.let {
|
||||
KeyPairSchema { keypair ->
|
||||
keypair[PublicKey] = it.publicKey
|
||||
keypair[PrivateKey] = it.privateKey
|
||||
keypair[Nonce] = null // bitcoin uses secp256k1 (like ethereum/tron), so nonce is always null
|
||||
}
|
||||
}
|
||||
secrets[BitcoinDerivationPath] = bitcoinDerivationPath
|
||||
}
|
||||
|
||||
fun ChainAccountSecrets(
|
||||
@@ -103,6 +117,9 @@ val EncodableStruct<MetaAccountSecrets>.ethereumDerivationPath
|
||||
val EncodableStruct<MetaAccountSecrets>.tronDerivationPath
|
||||
get() = get(MetaAccountSecrets.TronDerivationPath)
|
||||
|
||||
val EncodableStruct<MetaAccountSecrets>.bitcoinDerivationPath
|
||||
get() = get(MetaAccountSecrets.BitcoinDerivationPath)
|
||||
|
||||
val EncodableStruct<MetaAccountSecrets>.entropy
|
||||
get() = get(MetaAccountSecrets.Entropy)
|
||||
|
||||
@@ -118,6 +135,9 @@ val EncodableStruct<MetaAccountSecrets>.ethereumKeypair
|
||||
val EncodableStruct<MetaAccountSecrets>.tronKeypair
|
||||
get() = get(MetaAccountSecrets.TronKeypair)
|
||||
|
||||
val EncodableStruct<MetaAccountSecrets>.bitcoinKeypair
|
||||
get() = get(MetaAccountSecrets.BitcoinKeypair)
|
||||
|
||||
val EncodableStruct<ChainAccountSecrets>.derivationPath
|
||||
get() = get(ChainAccountSecrets.DerivationPath)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user