From 226617c4c18f265b14ff518abb2e288c946bd2ee Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 14 Nov 2023 09:56:07 -0600 Subject: [PATCH] ecash cash addr specific script hash convert --- lib/wallets/crypto_currency/coins/ecash.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/wallets/crypto_currency/coins/ecash.dart b/lib/wallets/crypto_currency/coins/ecash.dart index 9cc026f82..9b5d84b37 100644 --- a/lib/wallets/crypto_currency/coins/ecash.dart +++ b/lib/wallets/crypto_currency/coins/ecash.dart @@ -82,6 +82,23 @@ class Ecash extends Bip39HDCurrency { } } + @override + String addressToScriptHash({required String address}) { + try { + if (bitbox.Address.detectFormat(address) == + bitbox.Address.formatCashAddr && + _validateCashAddr(address)) { + address = bitbox.Address.toLegacyAddress(address); + } + + final addr = coinlib.Address.fromString(address, networkParams); + return Bip39HDCurrency.convertBytesToScriptHash( + addr.program.script.compiled); + } catch (e) { + rethrow; + } + } + @override String constructDerivePath({ required DerivePathType derivePathType,