From 07b21a42c66fb26737f8b55b73a4a3cec5c807ee Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 3 Jan 2024 11:01:04 -0600 Subject: [PATCH] check change address diversifier on spark address generate --- .../wallet_mixin_interfaces/spark_interface.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index c27b662ed..56b188e41 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -23,8 +23,6 @@ const kDefaultSparkIndex = 1; // TODO dart style constants. Maybe move to spark lib? const MAX_STANDARD_TX_WEIGHT = 400000; -const SPARK_CHANGE_D = 0x270F; - //https://github.com/firoorg/sparkmobile/blob/ef2e39aae18ecc49e0ddc63a3183e9764b96012e/include/spark.h#L16 const SPARK_OUT_LIMIT_PER_TX = 16; @@ -70,7 +68,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { _sparkChangeAddressCached = await LibSpark.getAddress( privateKey: keys.privateKey.data, index: kDefaultSparkIndex, - diversifier: SPARK_CHANGE_D, + diversifier: kSparkChange, isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, ); } @@ -116,7 +114,11 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { (await getCurrentReceivingSparkAddress())?.derivationIndex; // default to starting at 1 if none found - final int diversifier = (highestStoredDiversifier ?? 0) + 1; + int diversifier = (highestStoredDiversifier ?? 0) + 1; + // change address check + if (diversifier == kSparkChange) { + diversifier++; + } final root = await getRootHDNode(); final String derivationPath;