mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +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 outputAddress = item.isParsedAddress ? item.extractedAddress! : item.address;
|
||||
|
||||
// TODO: silent payments regex
|
||||
if (outputAddress.startsWith('tsp1')) {
|
||||
if (bitcoin.SilentPaymentAddress.REGEX.hasMatch(outputAddress)) {
|
||||
// Add all silent payment destinations to a list and generate outputs later
|
||||
silentPaymentDestinations
|
||||
.add(bitcoin.SilentPaymentDestination.fromAddress(outputAddress, outputAmount!));
|
||||
} else {
|
||||
// Add all non-silent payment destinations to the transaction
|
||||
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}\$'
|
||||
'|^[0-9a-zA-Z]{105}\$|^addr1[0-9a-zA-Z]{98}\$';
|
||||
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}|$silentpayments';
|
||||
return '${bitcoin.P2pkhAddress.REGEX.pattern}|${bitcoin.P2shAddress.REGEX.pattern}|${bitcoin.P2wpkhAddress.REGEX.pattern}|${bitcoin.P2trAddress.REGEX.pattern}|${bitcoin.SilentPaymentAddress.REGEX.pattern}';
|
||||
case CryptoCurrency.nano:
|
||||
case CryptoCurrency.nano:
|
||||
return '[0-9a-zA-Z_]';
|
||||
|
@ -286,4 +285,3 @@ class AddressValidator extends TextValidator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue