clean up notif node calls

This commit is contained in:
julian 2023-04-26 16:12:24 -06:00
parent b14263eca5
commit 9749443472

View file

@ -276,11 +276,7 @@ mixin PaynymWalletInterface {
required bool generateSegwitAddress, required bool generateSegwitAddress,
bip32.BIP32? mySendBip32Node, bip32.BIP32? mySendBip32Node,
}) async { }) async {
final node = mySendBip32Node ?? final node = mySendBip32Node ?? await deriveNotificationBip32Node();
await deriveNotificationBip32Node(
mnemonic: (await _getMnemonicString())!,
mnemonicPassphrase: (await _getMnemonicPassphrase())!,
);
final paymentAddress = PaymentAddress( final paymentAddress = PaymentAddress(
bip32Node: node, bip32Node: node,
@ -377,10 +373,7 @@ mixin PaynymWalletInterface {
bip32.BIP32? _cachedRootNode; bip32.BIP32? _cachedRootNode;
Future<bip32.BIP32> deriveNotificationBip32Node({ Future<bip32.BIP32> deriveNotificationBip32Node() async {
required String mnemonic,
required String mnemonicPassphrase,
}) async {
final root = await _getRootNode(); final root = await _getRootNode();
final node = root final node = root
.derivePath( .derivePath(
@ -408,10 +401,7 @@ mixin PaynymWalletInterface {
} }
Future<Uint8List> signWithNotificationKey(Uint8List data) async { Future<Uint8List> signWithNotificationKey(Uint8List data) async {
final myPrivateKeyNode = await deriveNotificationBip32Node( final myPrivateKeyNode = await deriveNotificationBip32Node();
mnemonic: (await _getMnemonicString())!,
mnemonicPassphrase: (await _getMnemonicPassphrase())!,
);
final pair = btc_dart.ECPair.fromPrivateKey(myPrivateKeyNode.privateKey!, final pair = btc_dart.ECPair.fromPrivateKey(myPrivateKeyNode.privateKey!,
network: _network); network: _network);
final signed = pair.sign(SHA256Digest().process(data)); final signed = pair.sign(SHA256Digest().process(data));
@ -434,10 +424,7 @@ mixin PaynymWalletInterface {
throw PaynymSendException( throw PaynymSendException(
"No notification transaction sent to $paymentCode"); "No notification transaction sent to $paymentCode");
} else { } else {
final myPrivateKeyNode = await deriveNotificationBip32Node( final myPrivateKeyNode = await deriveNotificationBip32Node();
mnemonic: (await _getMnemonicString())!,
mnemonicPassphrase: (await _getMnemonicPassphrase())!,
);
final sendToAddress = await nextUnusedSendAddressFrom( final sendToAddress = await nextUnusedSendAddressFrom(
pCode: paymentCode, pCode: paymentCode,
privateKeyNode: myPrivateKeyNode, privateKeyNode: myPrivateKeyNode,
@ -968,11 +955,7 @@ mixin PaynymWalletInterface {
final pubKey = _pubKeyFromInput(designatedInput)!; final pubKey = _pubKeyFromInput(designatedInput)!;
final myPrivateKey = (await deriveNotificationBip32Node( final myPrivateKey = (await deriveNotificationBip32Node()).privateKey!;
mnemonic: (await _getMnemonicString())!,
mnemonicPassphrase: (await _getMnemonicPassphrase())!,
))
.privateKey!;
final S = SecretPoint(myPrivateKey, pubKey); final S = SecretPoint(myPrivateKey, pubKey);
@ -1023,11 +1006,7 @@ mixin PaynymWalletInterface {
final pubKey = _pubKeyFromInput(designatedInput)!; final pubKey = _pubKeyFromInput(designatedInput)!;
final myPrivateKey = (await deriveNotificationBip32Node( final myPrivateKey = (await deriveNotificationBip32Node()).privateKey!;
mnemonic: (await _getMnemonicString())!,
mnemonicPassphrase: (await _getMnemonicPassphrase())!,
))
.privateKey!;
final S = SecretPoint(myPrivateKey, pubKey); final S = SecretPoint(myPrivateKey, pubKey);
@ -1189,13 +1168,7 @@ mixin PaynymWalletInterface {
const maxCount = 2147483647; const maxCount = 2147483647;
assert(maxNumberOfIndexesToCheck < maxCount); assert(maxNumberOfIndexesToCheck < maxCount);
final mnemonic = (await _getMnemonicString())!; final mySendBip32Node = await deriveNotificationBip32Node();
final mnemonicPassphrase = (await _getMnemonicPassphrase())!;
final mySendBip32Node = await deriveNotificationBip32Node(
mnemonic: mnemonic,
mnemonicPassphrase: mnemonicPassphrase,
);
List<Address> addresses = []; List<Address> addresses = [];
int receivingGapCounter = 0; int receivingGapCounter = 0;