pass bip32 root node is available to save generation time

This commit is contained in:
julian 2023-04-20 12:35:08 -06:00
parent 703ceee86d
commit 8e73e3ecba
2 changed files with 13 additions and 10 deletions

View file

@ -660,7 +660,7 @@ class BitcoinWallet extends CoinServiceAPI
}
// get own payment code
final myCode = await getPaymentCode(DerivePathType.bip44);
final myCode = await getPaymentCode(DerivePathType.bip44, root);
// refresh transactions to pick up any received notification transactions
await _refreshTransactions();

View file

@ -280,9 +280,10 @@ mixin PaynymWalletInterface {
/// fetch or generate this wallet's bip47 payment code
Future<PaymentCode> getPaymentCode(
DerivePathType derivePathType,
) async {
final address = await getMyNotificationAddress(derivePathType);
DerivePathType derivePathType, [
bip32.BIP32? bip32Root,
]) async {
final address = await getMyNotificationAddress(derivePathType, bip32Root);
final pCodeString = await paymentCodeStringByKey(address.otherData!);
final paymentCode = PaymentCode.fromPaymentCode(
pCodeString!,
@ -1305,8 +1306,9 @@ mixin PaynymWalletInterface {
}
Future<Address> getMyNotificationAddress(
DerivePathType derivePathType,
) async {
DerivePathType derivePathType, [
bip32.BIP32? bip32Root,
]) async {
// TODO: fix when segwit is here
derivePathType = DerivePathType.bip44;
@ -1339,10 +1341,11 @@ mixin PaynymWalletInterface {
if (storedAddress != null) {
return storedAddress;
} else {
final root = await _getRootNode(
mnemonic: (await _getMnemonicString())!,
mnemonicPassphrase: (await _getMnemonicPassphrase())!,
);
final root = bip32Root ??
await _getRootNode(
mnemonic: (await _getMnemonicString())!,
mnemonicPassphrase: (await _getMnemonicPassphrase())!,
);
final node = root.derivePath(kPaynymDerivePath);
final paymentCode = PaymentCode.fromBip32Node(
node,