mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 03:06:29 +00:00
ensure cashaddrs are converted to normal addresses for the tx builder to properly extract a script
This commit is contained in:
parent
0c97fa6635
commit
d5e8d3fe3e
3 changed files with 34 additions and 1 deletions
|
@ -356,4 +356,18 @@ class BitcoincashWallet extends Bip39HDWallet
|
|||
int estimateTxFee({required int vSize, required int feeRatePerKB}) {
|
||||
return vSize * (feeRatePerKB / 1000).ceil();
|
||||
}
|
||||
|
||||
@override
|
||||
String normalizeAddress(String address) {
|
||||
try {
|
||||
if (bitbox.Address.detectFormat(address) ==
|
||||
bitbox.Address.formatCashAddr) {
|
||||
return bitbox.Address.toLegacyAddress(address);
|
||||
} else {
|
||||
return address;
|
||||
}
|
||||
} catch (_) {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -351,4 +351,18 @@ class EcashWallet extends Bip39HDWallet
|
|||
int estimateTxFee({required int vSize, required int feeRatePerKB}) {
|
||||
return vSize * (feeRatePerKB / 1000).ceil();
|
||||
}
|
||||
|
||||
@override
|
||||
String normalizeAddress(String address) {
|
||||
try {
|
||||
if (bitbox.Address.detectFormat(address) ==
|
||||
bitbox.Address.formatCashAddr) {
|
||||
return bitbox.Address.toLegacyAddress(address);
|
||||
} else {
|
||||
return address;
|
||||
}
|
||||
} catch (_) {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -697,7 +697,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
|
|||
// Add transaction output
|
||||
for (var i = 0; i < txData.recipients!.length; i++) {
|
||||
txb.addOutput(
|
||||
txData.recipients![i].address,
|
||||
normalizeAddress(txData.recipients![i].address),
|
||||
txData.recipients![i].amount.raw.toInt(),
|
||||
cryptoCurrency.networkParams.bech32Hrp,
|
||||
);
|
||||
|
@ -2021,5 +2021,10 @@ mixin ElectrumXInterface on Bip39HDWallet {
|
|||
return result;
|
||||
}
|
||||
|
||||
// lolcashaddrs
|
||||
String normalizeAddress(String address) {
|
||||
return address;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue