Merge pull request #226 from cake-tech/CW-17

Fixes for casting Litecoin wallets to Bitcoin wallets. Instead of tha…
This commit is contained in:
mkyq 2022-01-12 15:36:29 +02:00 committed by GitHub
commit 3697b300d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,7 @@ class CWBitcoin extends Bitcoin {
@override @override
Map<String, String> getWalletKeys(Object wallet) { Map<String, String> getWalletKeys(Object wallet) {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
final keys = bitcoinWallet.keys; final keys = bitcoinWallet.keys;
return <String, String>{ return <String, String>{
@ -41,25 +41,25 @@ class CWBitcoin extends Bitcoin {
@override @override
int getFeeRate(Object wallet, TransactionPriority priority) { int getFeeRate(Object wallet, TransactionPriority priority) {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
return bitcoinWallet.feeRate(priority); return bitcoinWallet.feeRate(priority);
} }
@override @override
Future<void> generateNewAddress(Object wallet) async { Future<void> generateNewAddress(Object wallet) async {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
await bitcoinWallet.walletAddresses.generateNewAddress(); await bitcoinWallet.walletAddresses.generateNewAddress();
} }
@override @override
Future<void> nextAddress(Object wallet) { Future<void> nextAddress(Object wallet) {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
bitcoinWallet.walletAddresses.nextAddress(); bitcoinWallet.walletAddresses.nextAddress();
} }
@override @override
Future<void> randomAddress(Object wallet) { Future<void> randomAddress(Object wallet) {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
bitcoinWallet.walletAddresses.randomizeAddress(); bitcoinWallet.walletAddresses.randomizeAddress();
} }
@ -80,7 +80,7 @@ class CWBitcoin extends Bitcoin {
@override @override
List<String> getAddresses(Object wallet) { List<String> getAddresses(Object wallet) {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
return bitcoinWallet.walletAddresses.addresses return bitcoinWallet.walletAddresses.addresses
.map((BitcoinAddressRecord addr) => addr.address) .map((BitcoinAddressRecord addr) => addr.address)
.toList(); .toList();
@ -88,7 +88,7 @@ class CWBitcoin extends Bitcoin {
@override @override
String getAddress(Object wallet) { String getAddress(Object wallet) {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
return bitcoinWallet.walletAddresses.address; return bitcoinWallet.walletAddresses.address;
} }
@ -106,7 +106,7 @@ class CWBitcoin extends Bitcoin {
@override @override
List<Unspent> getUnspents(Object wallet) { List<Unspent> getUnspents(Object wallet) {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
return bitcoinWallet.unspentCoins return bitcoinWallet.unspentCoins
.map((BitcoinUnspent bitcoinUnspent) => Unspent( .map((BitcoinUnspent bitcoinUnspent) => Unspent(
bitcoinUnspent.address.address, bitcoinUnspent.address.address,
@ -117,7 +117,7 @@ class CWBitcoin extends Bitcoin {
} }
void updateUnspents(Object wallet) async { void updateUnspents(Object wallet) async {
final bitcoinWallet = wallet as BitcoinWallet; final bitcoinWallet = wallet as ElectrumWallet;
await bitcoinWallet.updateUnspent(); await bitcoinWallet.updateUnspent();
} }