mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 20:09:24 +00:00
feat: use silent payment address regex
This commit is contained in:
parent
4b3b3f6d2c
commit
d3d925c7ff
2 changed files with 4 additions and 5 deletions
|
@ -465,11 +465,12 @@ abstract class ElectrumWalletBase
|
||||||
final outputAmount = hasMultiDestination ? item.formattedCryptoAmount : amount;
|
final outputAmount = hasMultiDestination ? item.formattedCryptoAmount : amount;
|
||||||
final outputAddress = item.isParsedAddress ? item.extractedAddress! : item.address;
|
final outputAddress = item.isParsedAddress ? item.extractedAddress! : item.address;
|
||||||
|
|
||||||
// TODO: silent payments regex
|
if (bitcoin.SilentPaymentAddress.REGEX.hasMatch(outputAddress)) {
|
||||||
if (outputAddress.startsWith('tsp1')) {
|
// Add all silent payment destinations to a list and generate outputs later
|
||||||
silentPaymentDestinations
|
silentPaymentDestinations
|
||||||
.add(bitcoin.SilentPaymentDestination.fromAddress(outputAddress, outputAmount!));
|
.add(bitcoin.SilentPaymentDestination.fromAddress(outputAddress, outputAmount!));
|
||||||
} else {
|
} else {
|
||||||
|
// Add all non-silent payment destinations to the transaction
|
||||||
txb.addOutput(addressToOutputScript(outputAddress, networkType), outputAmount!);
|
txb.addOutput(addressToOutputScript(outputAddress, networkType), outputAmount!);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,8 +24,7 @@ class AddressValidator extends TextValidator {
|
||||||
return '^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{104}\$'
|
return '^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{104}\$'
|
||||||
'|^[0-9a-zA-Z]{105}\$|^addr1[0-9a-zA-Z]{98}\$';
|
'|^[0-9a-zA-Z]{105}\$|^addr1[0-9a-zA-Z]{98}\$';
|
||||||
case CryptoCurrency.btc:
|
case CryptoCurrency.btc:
|
||||||
final silentpayments = '^tsp1[0-9a-zA-Z]{113}\$';
|
return '${bitcoin.P2pkhAddress.REGEX.pattern}|${bitcoin.P2shAddress.REGEX.pattern}|${bitcoin.P2wpkhAddress.REGEX.pattern}|${bitcoin.P2trAddress.REGEX.pattern}|${bitcoin.SilentPaymentAddress.REGEX.pattern}';
|
||||||
return '${bitcoin.P2pkhAddress.REGEX.pattern}|${bitcoin.P2shAddress.REGEX.pattern}|${bitcoin.P2wpkhAddress.REGEX.pattern}|${bitcoin.P2trAddress.REGEX.pattern}|$silentpayments';
|
|
||||||
case CryptoCurrency.nano:
|
case CryptoCurrency.nano:
|
||||||
case CryptoCurrency.nano:
|
case CryptoCurrency.nano:
|
||||||
return '[0-9a-zA-Z_]';
|
return '[0-9a-zA-Z_]';
|
||||||
|
@ -286,4 +285,3 @@ class AddressValidator extends TextValidator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue