use derive path type extension method per coin

This commit is contained in:
julian 2023-01-25 13:49:14 -06:00
parent 35ba2f9d79
commit 79db4f048c
7 changed files with 102 additions and 68 deletions

View file

@ -193,7 +193,7 @@ class BitcoinWallet extends CoinServiceAPI
.subTypeEqualTo(isar_models.AddressSubType.receiving)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(0, 0, DerivePathType.bip84);
await _generateAddressForChain(0, 0, DerivePathTypeExt.primaryFor(coin));
Future<String> get currentChangeAddress async =>
(await _currentChangeAddress).value;
@ -206,7 +206,7 @@ class BitcoinWallet extends CoinServiceAPI
.subTypeEqualTo(isar_models.AddressSubType.change)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(1, 0, DerivePathType.bip84);
await _generateAddressForChain(1, 0, DerivePathTypeExt.primaryFor(coin));
@override
Future<void> exit() async {
@ -1868,7 +1868,7 @@ class BitcoinWallet extends CoinServiceAPI
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip84);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1887,7 +1887,7 @@ class BitcoinWallet extends CoinServiceAPI
}
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -1907,7 +1907,7 @@ class BitcoinWallet extends CoinServiceAPI
// Use new index to derive a new change address
final newChangeAddress = await _generateAddressForChain(
1, newChangeIndex, DerivePathType.bip84);
1, newChangeIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1926,12 +1926,12 @@ class BitcoinWallet extends CoinServiceAPI
}
} on SocketException catch (se, s) {
Logging.instance.log(
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $se\n$s",
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $se\n$s",
level: LogLevel.Error);
return;
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -2269,7 +2269,7 @@ class BitcoinWallet extends CoinServiceAPI
utxoSigningData: utxoSigningData,
recipients: [
_recipientAddress,
await _getCurrentAddressForChain(1, DerivePathType.bip84),
await _getCurrentAddressForChain(1, DerivePathTypeExt.primaryFor(coin)),
],
satoshiAmounts: [
satoshiAmountToSend,
@ -2308,8 +2308,8 @@ class BitcoinWallet extends CoinServiceAPI
feeForTwoOutputs) {
// generate new change address if current change address has been used
await _checkChangeAddressForTransactions();
final String newChangeAddress =
await _getCurrentAddressForChain(1, DerivePathType.bip84);
final String newChangeAddress = await _getCurrentAddressForChain(
1, DerivePathTypeExt.primaryFor(coin));
int feeBeingPaid =
satoshisBeingUsed - satoshiAmountToSend - changeOutputSize;
@ -3035,7 +3035,7 @@ class BitcoinWallet extends CoinServiceAPI
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip84);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
// Add that new receiving address
await db.putAddress(newReceivingAddress);

View file

@ -169,7 +169,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
.subTypeEqualTo(isar_models.AddressSubType.receiving)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(0, 0, DerivePathType.bip44);
await _generateAddressForChain(0, 0, DerivePathTypeExt.primaryFor(coin));
Future<String> get currentChangeAddress async =>
(await _currentChangeAddress).value;
@ -182,7 +182,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
.subTypeEqualTo(isar_models.AddressSubType.change)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(1, 0, DerivePathType.bip44);
await _generateAddressForChain(1, 0, DerivePathTypeExt.primaryFor(coin));
@override
Future<void> exit() async {
@ -1754,7 +1754,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip44);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1773,12 +1773,12 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
} on SocketException catch (se, s) {
Logging.instance.log(
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip44}): $se\n$s",
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $se\n$s",
level: LogLevel.Error);
return;
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip44}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -1798,7 +1798,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
// Use new index to derive a new change address
final newChangeAddress = await _generateAddressForChain(
1, newChangeIndex, DerivePathType.bip44);
1, newChangeIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1817,12 +1817,12 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
} on SocketException catch (se, s) {
Logging.instance.log(
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip44}): $se\n$s",
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $se\n$s",
level: LogLevel.Error);
return;
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip44}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -2348,7 +2348,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
utxoSigningData: utxoSigningData,
recipients: [
_recipientAddress,
await _getCurrentAddressForChain(1, DerivePathType.bip44),
await _getCurrentAddressForChain(1, DerivePathTypeExt.primaryFor(coin)),
],
satoshiAmounts: [
satoshiAmountToSend,
@ -2401,8 +2401,8 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
feeForTwoOutputs) {
// generate new change address if current change address has been used
await _checkChangeAddressForTransactions();
final String newChangeAddress =
await _getCurrentAddressForChain(1, DerivePathType.bip44);
final String newChangeAddress = await _getCurrentAddressForChain(
1, DerivePathTypeExt.primaryFor(coin));
int feeBeingPaid =
satoshisBeingUsed - satoshiAmountToSend - changeOutputSize;
@ -3001,7 +3001,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip44);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
// Add that new receiving address
await db.putAddress(newReceivingAddress);

View file

@ -168,7 +168,7 @@ class DogecoinWallet extends CoinServiceAPI
.subTypeEqualTo(isar_models.AddressSubType.receiving)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(0, 0, DerivePathType.bip44);
await _generateAddressForChain(0, 0, DerivePathTypeExt.primaryFor(coin));
// @override
Future<String> get currentChangeAddress async =>
@ -182,7 +182,7 @@ class DogecoinWallet extends CoinServiceAPI
.subTypeEqualTo(isar_models.AddressSubType.change)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(1, 0, DerivePathType.bip44);
await _generateAddressForChain(1, 0, DerivePathTypeExt.primaryFor(coin));
@override
Future<void> exit() async {
@ -1657,7 +1657,7 @@ class DogecoinWallet extends CoinServiceAPI
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip44);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1676,12 +1676,12 @@ class DogecoinWallet extends CoinServiceAPI
}
} on SocketException catch (se, s) {
Logging.instance.log(
"SocketException caught in _checkReceivingAddressForTransactions($DerivePathType.bip44): $se\n$s",
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $se\n$s",
level: LogLevel.Error);
return;
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions($DerivePathType.bip44): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -1701,7 +1701,7 @@ class DogecoinWallet extends CoinServiceAPI
// Use new index to derive a new change address
final newChangeAddress = await _generateAddressForChain(
1, newChangeIndex, DerivePathType.bip44);
1, newChangeIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1720,7 +1720,7 @@ class DogecoinWallet extends CoinServiceAPI
}
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkChangeAddressForTransactions(${DerivePathType.bip44}): $e\n$s",
"Exception rethrown from _checkChangeAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -2089,7 +2089,7 @@ class DogecoinWallet extends CoinServiceAPI
utxoSigningData: utxoSigningData,
recipients: [
_recipientAddress,
await _getCurrentAddressForChain(1, DerivePathType.bip44),
await _getCurrentAddressForChain(1, DerivePathTypeExt.primaryFor(coin)),
],
satoshiAmounts: [
satoshiAmountToSend,
@ -2142,8 +2142,8 @@ class DogecoinWallet extends CoinServiceAPI
feeForTwoOutputs) {
// generate new change address if current change address has been used
await checkChangeAddressForTransactions();
final String newChangeAddress =
await _getCurrentAddressForChain(1, DerivePathType.bip44);
final String newChangeAddress = await _getCurrentAddressForChain(
1, DerivePathTypeExt.primaryFor(coin));
int feeBeingPaid =
satoshisBeingUsed - satoshiAmountToSend - changeOutputSize;
@ -2760,7 +2760,7 @@ class DogecoinWallet extends CoinServiceAPI
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip44);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
// Add that new receiving address
await db.putAddress(newReceivingAddress);

View file

@ -193,7 +193,7 @@ class LitecoinWallet extends CoinServiceAPI
.subTypeEqualTo(isar_models.AddressSubType.receiving)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(0, 0, DerivePathType.bip84);
await _generateAddressForChain(0, 0, DerivePathTypeExt.primaryFor(coin));
Future<String> get currentChangeAddress async =>
(await _currentChangeAddress).value;
@ -206,7 +206,7 @@ class LitecoinWallet extends CoinServiceAPI
.subTypeEqualTo(isar_models.AddressSubType.change)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(1, 0, DerivePathType.bip84);
await _generateAddressForChain(1, 0, DerivePathTypeExt.primaryFor(coin));
@override
Future<void> exit() async {
@ -1891,7 +1891,7 @@ class LitecoinWallet extends CoinServiceAPI
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip84);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1910,7 +1910,7 @@ class LitecoinWallet extends CoinServiceAPI
}
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -1930,7 +1930,7 @@ class LitecoinWallet extends CoinServiceAPI
// Use new index to derive a new change address
final newChangeAddress = await _generateAddressForChain(
1, newChangeIndex, DerivePathType.bip84);
1, newChangeIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1949,12 +1949,12 @@ class LitecoinWallet extends CoinServiceAPI
}
} on SocketException catch (se, s) {
Logging.instance.log(
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $se\n$s",
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $se\n$s",
level: LogLevel.Error);
return;
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -2349,7 +2349,7 @@ class LitecoinWallet extends CoinServiceAPI
utxoSigningData: utxoSigningData,
recipients: [
_recipientAddress,
await _getCurrentAddressForChain(1, DerivePathType.bip84),
await _getCurrentAddressForChain(1, DerivePathTypeExt.primaryFor(coin)),
],
satoshiAmounts: [
satoshiAmountToSend,
@ -2388,8 +2388,8 @@ class LitecoinWallet extends CoinServiceAPI
feeForTwoOutputs) {
// generate new change address if current change address has been used
await _checkChangeAddressForTransactions();
final String newChangeAddress =
await _getCurrentAddressForChain(1, DerivePathType.bip84);
final String newChangeAddress = await _getCurrentAddressForChain(
1, DerivePathTypeExt.primaryFor(coin));
int feeBeingPaid =
satoshisBeingUsed - satoshiAmountToSend - changeOutputSize;
@ -3345,7 +3345,7 @@ class LitecoinWallet extends CoinServiceAPI
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip84);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
// Add that new receiving address
await db.putAddress(newReceivingAddress);

View file

@ -188,7 +188,7 @@ class NamecoinWallet extends CoinServiceAPI
.subTypeEqualTo(isar_models.AddressSubType.receiving)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(0, 0, DerivePathType.bip84);
await _generateAddressForChain(0, 0, DerivePathTypeExt.primaryFor(coin));
Future<String> get currentChangeAddress async =>
(await _currentChangeAddress).value;
@ -201,7 +201,7 @@ class NamecoinWallet extends CoinServiceAPI
.subTypeEqualTo(isar_models.AddressSubType.change)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(1, 0, DerivePathType.bip84);
await _generateAddressForChain(1, 0, DerivePathTypeExt.primaryFor(coin));
@override
Future<void> exit() async {
@ -1873,7 +1873,7 @@ class NamecoinWallet extends CoinServiceAPI
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip84);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1892,7 +1892,7 @@ class NamecoinWallet extends CoinServiceAPI
}
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -1912,7 +1912,7 @@ class NamecoinWallet extends CoinServiceAPI
// Use new index to derive a new change address
final newChangeAddress = await _generateAddressForChain(
1, newChangeIndex, DerivePathType.bip84);
1, newChangeIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1932,12 +1932,12 @@ class NamecoinWallet extends CoinServiceAPI
}
} on SocketException catch (se, s) {
Logging.instance.log(
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $se\n$s",
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $se\n$s",
level: LogLevel.Error);
return;
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -2336,7 +2336,7 @@ class NamecoinWallet extends CoinServiceAPI
utxoSigningData: utxoSigningData,
recipients: [
_recipientAddress,
await _getCurrentAddressForChain(1, DerivePathType.bip84),
await _getCurrentAddressForChain(1, DerivePathTypeExt.primaryFor(coin)),
],
satoshiAmounts: [
satoshiAmountToSend,
@ -2375,8 +2375,8 @@ class NamecoinWallet extends CoinServiceAPI
feeForTwoOutputs) {
// generate new change address if current change address has been used
await _checkChangeAddressForTransactions();
final String newChangeAddress =
await _getCurrentAddressForChain(1, DerivePathType.bip84);
final String newChangeAddress = await _getCurrentAddressForChain(
1, DerivePathTypeExt.primaryFor(coin));
int feeBeingPaid =
satoshisBeingUsed - satoshiAmountToSend - changeOutputSize;
@ -3336,7 +3336,7 @@ class NamecoinWallet extends CoinServiceAPI
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip84);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
// Add that new receiving address
await db.putAddress(newReceivingAddress);

View file

@ -183,7 +183,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
.subTypeEqualTo(isar_models.AddressSubType.receiving)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(0, 0, DerivePathType.bip84);
await _generateAddressForChain(0, 0, DerivePathTypeExt.primaryFor(coin));
Future<String> get currentChangeAddress async =>
(await _currentChangeAddress).value;
@ -196,7 +196,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
.subTypeEqualTo(isar_models.AddressSubType.change)
.sortByDerivationIndexDesc()
.findFirst()) ??
await _generateAddressForChain(1, 0, DerivePathType.bip84);
await _generateAddressForChain(1, 0, DerivePathTypeExt.primaryFor(coin));
@override
Future<void> exit() async {
@ -1766,7 +1766,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip84);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1785,7 +1785,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -1805,7 +1805,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
// Use new index to derive a new change address
final newChangeAddress = await _generateAddressForChain(
1, newChangeIndex, DerivePathType.bip84);
1, newChangeIndex, DerivePathTypeExt.primaryFor(coin));
final existing = await db
.getAddresses(walletId)
@ -1824,12 +1824,12 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
} on SocketException catch (se, s) {
Logging.instance.log(
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $se\n$s",
"SocketException caught in _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $se\n$s",
level: LogLevel.Error);
return;
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s",
"Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathTypeExt.primaryFor(coin)}): $e\n$s",
level: LogLevel.Error);
rethrow;
}
@ -2506,7 +2506,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
utxoSigningData: utxoSigningData,
recipients: [
_recipientAddress,
await _getCurrentAddressForChain(1, DerivePathType.bip84),
await _getCurrentAddressForChain(1, DerivePathTypeExt.primaryFor(coin)),
],
satoshiAmounts: [
satoshiAmountToSend,
@ -2545,8 +2545,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
feeForTwoOutputs) {
// generate new change address if current change address has been used
await _checkChangeAddressForTransactions();
final String newChangeAddress =
await _getCurrentAddressForChain(1, DerivePathType.bip84);
final String newChangeAddress = await _getCurrentAddressForChain(
1, DerivePathTypeExt.primaryFor(coin));
int feeBeingPaid =
satoshisBeingUsed - satoshiAmountToSend - changeOutputSize;
@ -3335,7 +3335,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
// Use new index to derive a new receiving address
final newReceivingAddress = await _generateAddressForChain(
0, newReceivingIndex, DerivePathType.bip84);
0, newReceivingIndex, DerivePathTypeExt.primaryFor(coin));
// Add that new receiving address
await db.putAddress(newReceivingAddress);

View file

@ -1 +1,35 @@
enum DerivePathType { bip44, bip49, bip84 }
import 'package:stackwallet/utilities/enums/coin_enum.dart';
enum DerivePathType {
bip44,
bip49,
bip84,
}
extension DerivePathTypeExt on DerivePathType {
static DerivePathType primaryFor(Coin coin) {
switch (coin) {
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
case Coin.dogecoin:
case Coin.dogecoinTestNet:
case Coin.firo:
case Coin.firoTestNet:
return DerivePathType.bip44;
case Coin.bitcoin:
case Coin.bitcoinTestNet:
case Coin.litecoin:
case Coin.litecoinTestNet:
case Coin.namecoin:
case Coin.particl:
return DerivePathType.bip84;
case Coin.epicCash:
case Coin.monero:
case Coin.wownero:
throw UnsupportedError(
"$coin does not use bitcoin style derivation paths");
}
}
}