mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
commit
9fb2f5dd3d
9 changed files with 213 additions and 169 deletions
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:math';
|
||||||
import 'package:cw_core/unspent_coins_info.dart';
|
import 'package:cw_core/unspent_coins_info.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
||||||
|
@ -238,7 +239,7 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
||||||
}
|
}
|
||||||
|
|
||||||
final txb = bitcoin.TransactionBuilder(network: networkType);
|
final txb = bitcoin.TransactionBuilder(network: networkType);
|
||||||
final changeAddress = walletAddresses.address;
|
final changeAddress = getChangeAddress();
|
||||||
var leftAmount = totalAmount;
|
var leftAmount = totalAmount;
|
||||||
var totalInputAmount = 0;
|
var totalInputAmount = 0;
|
||||||
|
|
||||||
|
@ -545,4 +546,18 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
||||||
balance = await _fetchBalances();
|
balance = await _fetchBalances();
|
||||||
await save();
|
await save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getChangeAddress() {
|
||||||
|
const minCountOfHiddenAddresses = 5;
|
||||||
|
final random = Random();
|
||||||
|
var addresses = walletAddresses.addresses
|
||||||
|
.where((addr) => addr.isHidden)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (addresses.length < minCountOfHiddenAddresses) {
|
||||||
|
addresses = walletAddresses.addresses.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return addresses[random.nextInt(addresses.length)].address;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:cw_core/wallet_addresses.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
part 'electrum_wallet_addresses.g.dart';
|
part 'electrum_wallet_addresses.g.dart';
|
||||||
|
|
||||||
|
@ -129,4 +130,9 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void randomizeAddress() {
|
||||||
|
final random = Random();
|
||||||
|
address = addresses[random.nextInt(addresses.length)].address;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -196,4 +196,4 @@ SPEC CHECKSUMS:
|
||||||
|
|
||||||
PODFILE CHECKSUM: bc2591d23316907c9c90ca1cd2fce063fd866508
|
PODFILE CHECKSUM: bc2591d23316907c9c90ca1cd2fce063fd866508
|
||||||
|
|
||||||
COCOAPODS: 1.10.2
|
COCOAPODS: 1.11.2
|
||||||
|
|
|
@ -57,6 +57,12 @@ class CWBitcoin extends Bitcoin {
|
||||||
bitcoinWallet.walletAddresses.nextAddress();
|
bitcoinWallet.walletAddresses.nextAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> randomAddress(Object wallet) {
|
||||||
|
final bitcoinWallet = wallet as BitcoinWallet;
|
||||||
|
bitcoinWallet.walletAddresses.randomizeAddress();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Object createBitcoinTransactionCredentials(List<Output> outputs, TransactionPriority priority)
|
Object createBitcoinTransactionCredentials(List<Output> outputs, TransactionPriority priority)
|
||||||
=> BitcoinTransactionCredentials(
|
=> BitcoinTransactionCredentials(
|
||||||
|
|
|
@ -196,8 +196,8 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_handleIncomingLinks();
|
//_handleIncomingLinks();
|
||||||
_handleInitialUri();
|
//_handleInitialUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -214,7 +214,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
_fetchEmojiFromUri(uri);
|
//_fetchEmojiFromUri(uri);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
|
@ -226,7 +226,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
stream = getUriLinksStream().listen((Uri uri) {
|
stream = getUriLinksStream().listen((Uri uri) {
|
||||||
print('uri: $uri');
|
print('uri: $uri');
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
_fetchEmojiFromUri(uri);
|
//_fetchEmojiFromUri(uri);
|
||||||
}, onError: (Object error) {
|
}, onError: (Object error) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
print('Error: $error');
|
print('Error: $error');
|
||||||
|
@ -235,18 +235,18 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _fetchEmojiFromUri(Uri uri) {
|
void _fetchEmojiFromUri(Uri uri) {
|
||||||
final queryParameters = uri.queryParameters;
|
//final queryParameters = uri.queryParameters;
|
||||||
if (queryParameters?.isEmpty ?? true) {
|
//if (queryParameters?.isEmpty ?? true) {
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
final emoji = queryParameters['eid'];
|
//final emoji = queryParameters['eid'];
|
||||||
final refreshToken = queryParameters['refresh_token'];
|
//final refreshToken = queryParameters['refresh_token'];
|
||||||
if ((emoji?.isEmpty ?? true)||(refreshToken?.isEmpty ?? true)) {
|
//if ((emoji?.isEmpty ?? true)||(refreshToken?.isEmpty ?? true)) {
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
yatStore.emoji = emoji;
|
//yatStore.emoji = emoji;
|
||||||
yatStore.refreshToken = refreshToken;
|
//yatStore.refreshToken = refreshToken;
|
||||||
yatStore.emojiIncommingSC.add(emoji);
|
//yatStore.emojiIncommingSC.add(emoji);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -17,34 +17,34 @@ import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||||
|
|
||||||
ReactionDisposer _onCurrentWalletChangeReaction;
|
ReactionDisposer _onCurrentWalletChangeReaction;
|
||||||
ReactionDisposer _onCurrentWalletChangeFiatRateUpdateReaction;
|
ReactionDisposer _onCurrentWalletChangeFiatRateUpdateReaction;
|
||||||
ReactionDisposer _onCurrentWalletAddressChangeReaction;
|
//ReactionDisposer _onCurrentWalletAddressChangeReaction;
|
||||||
|
|
||||||
void startCurrentWalletChangeReaction(AppStore appStore,
|
void startCurrentWalletChangeReaction(AppStore appStore,
|
||||||
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
|
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
|
||||||
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
||||||
_onCurrentWalletChangeFiatRateUpdateReaction?.reaction?.dispose();
|
_onCurrentWalletChangeFiatRateUpdateReaction?.reaction?.dispose();
|
||||||
_onCurrentWalletAddressChangeReaction?.reaction?.dispose();
|
//_onCurrentWalletAddressChangeReaction?.reaction?.dispose();
|
||||||
|
|
||||||
_onCurrentWalletAddressChangeReaction = reaction((_) => appStore.wallet.walletAddresses.address,
|
//_onCurrentWalletAddressChangeReaction = reaction((_) => appStore.wallet.walletAddresses.address,
|
||||||
(String address) async {
|
//(String address) async {
|
||||||
if (address == appStore.wallet.walletInfo.yatLastUsedAddress) {
|
//if (address == appStore.wallet.walletInfo.yatLastUsedAddress) {
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
try {
|
//try {
|
||||||
final yatStore = getIt.get<YatStore>();
|
// final yatStore = getIt.get<YatStore>();
|
||||||
await updateEmojiIdAddress(
|
// await updateEmojiIdAddress(
|
||||||
appStore.wallet.walletInfo.yatEmojiId,
|
// appStore.wallet.walletInfo.yatEmojiId,
|
||||||
appStore.wallet.walletAddresses.address,
|
// appStore.wallet.walletAddresses.address,
|
||||||
yatStore.apiKey,
|
// yatStore.apiKey,
|
||||||
appStore.wallet.type
|
// appStore.wallet.type
|
||||||
);
|
// );
|
||||||
appStore.wallet.walletInfo.yatLastUsedAddress = address;
|
// appStore.wallet.walletInfo.yatLastUsedAddress = address;
|
||||||
await appStore.wallet.walletInfo.save();
|
// await appStore.wallet.walletInfo.save();
|
||||||
} catch (e) {
|
//} catch (e) {
|
||||||
print(e.toString());
|
// print(e.toString());
|
||||||
}
|
//}
|
||||||
});
|
//});
|
||||||
|
|
||||||
_onCurrentWalletChangeReaction = reaction((_) => appStore.wallet, (WalletBase<
|
_onCurrentWalletChangeReaction = reaction((_) => appStore.wallet, (WalletBase<
|
||||||
Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>
|
Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>
|
||||||
|
|
|
@ -27,6 +27,7 @@ class AddressPage extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
addressListViewModel.generateRandomAddress();
|
||||||
autorun((_) async {
|
autorun((_) async {
|
||||||
if (!walletViewModel.isOutdatedElectrumWallet
|
if (!walletViewModel.isOutdatedElectrumWallet
|
||||||
|| !walletViewModel.settingsStore.shouldShowReceiveWarning) {
|
|| !walletViewModel.settingsStore.shouldShowReceiveWarning) {
|
||||||
|
@ -124,15 +125,15 @@ class AddressPage extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
) : Container();
|
||||||
: PrimaryButton(
|
//: PrimaryButton(
|
||||||
onPressed: () => addressListViewModel.nextAddress(),
|
// onPressed: () => addressListViewModel.nextAddress(),
|
||||||
text: 'Next address',
|
// text: 'Next address',
|
||||||
color: Theme.of(context).buttonColor,
|
// color: Theme.of(context).buttonColor,
|
||||||
textColor: Theme.of(context)
|
// textColor: Theme.of(context)
|
||||||
.accentTextTheme
|
// .accentTextTheme
|
||||||
.display3
|
// .display3
|
||||||
.backgroundColor);
|
// .backgroundColor);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -15,18 +15,18 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
part 'yat_store.g.dart';
|
part 'yat_store.g.dart';
|
||||||
|
|
||||||
class YatLink {
|
class YatLink {
|
||||||
static const partnerId = 'CW';
|
static const partnerId = ''; // 'CW';
|
||||||
static const baseDevUrl = 'https://yat.fyi';
|
static const baseDevUrl = ''; // 'https://yat.fyi';
|
||||||
static const baseReleaseUrl = 'https://y.at';
|
static const baseReleaseUrl = ''; // 'https://y.at';
|
||||||
static const signInSuffix = '/partner/$partnerId/link-email';
|
static const signInSuffix = ''; // '/partner/$partnerId/link-email';
|
||||||
static const createSuffix = '/create';
|
static const createSuffix = ''; // '/create';
|
||||||
static const managePath = '/partner/$partnerId/manage';
|
static const managePath = ''; // '/partner/$partnerId/manage';
|
||||||
static const queryParameter = '?address_json=';
|
static const queryParameter = ''; // '?address_json=';
|
||||||
static const apiDevUrl = 'https://a.yat.fyi';
|
static const apiDevUrl = ''; // 'https://a.yat.fyi';
|
||||||
static const apiReleaseUrl = 'https://a.y.at';
|
static const apiReleaseUrl = ''; // 'https://a.y.at';
|
||||||
static const requestDevUrl = 'https://a.yat.fyi/emoji_id/';
|
static const requestDevUrl = ''; // 'https://a.yat.fyi/emoji_id/';
|
||||||
static const requestReleaseUrl = 'https://a.y.at/emoji_id/';
|
static const requestReleaseUrl = ''; //'https://a.y.at/emoji_id/';
|
||||||
static const startFlowUrl = 'https://www.y03btrk.com/4RQSJ/6JHXF/';
|
static const startFlowUrl = ''; // 'https://www.y03btrk.com/4RQSJ/6JHXF/';
|
||||||
static const isDevMode = true;
|
static const isDevMode = true;
|
||||||
static const tags = <String, List<String>>{"XMR" : ['0x1001', '0x1002'],
|
static const tags = <String, List<String>>{"XMR" : ['0x1001', '0x1002'],
|
||||||
"BTC" : ['0x1003'], "LTC" : ['0x3fff']};
|
"BTC" : ['0x1003'], "LTC" : ['0x3fff']};
|
||||||
|
@ -43,118 +43,122 @@ class YatLink {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<String>> fetchYatAddress(String emojiId, String ticker) async {
|
Future<List<String>> fetchYatAddress(String emojiId, String ticker) async {
|
||||||
final url = YatLink.emojiIdUrl + emojiId + '/payment';
|
//final url = YatLink.emojiIdUrl + emojiId + '/payment';
|
||||||
final response = await get(url);
|
//final response = await get(url);
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
//if (response.statusCode != 200) {
|
||||||
throw YatException(text: response.body.toString());
|
// throw YatException(text: response.body.toString());
|
||||||
}
|
//}
|
||||||
|
|
||||||
final addresses = <String>[];
|
//final addresses = <String>[];
|
||||||
final currency = ticker.toUpperCase();
|
//final currency = ticker.toUpperCase();
|
||||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
//final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||||
final result = responseJSON['result'] as Map<dynamic, dynamic>;
|
//final result = responseJSON['result'] as Map<dynamic, dynamic>;
|
||||||
result.forEach((dynamic key, dynamic value) {
|
//result.forEach((dynamic key, dynamic value) {
|
||||||
final tag = key as String ?? '';
|
// final tag = key as String ?? '';
|
||||||
final record = value as Map<String, dynamic>;
|
// final record = value as Map<String, dynamic>;
|
||||||
|
|
||||||
if (YatLink.tags[currency]?.contains(tag) ?? false) {
|
// if (YatLink.tags[currency]?.contains(tag) ?? false) {
|
||||||
final address = record['address'] as String;
|
// final address = record['address'] as String;
|
||||||
if (address?.isNotEmpty ?? false) {
|
// if (address?.isNotEmpty ?? false) {
|
||||||
addresses.add(address);
|
// addresses.add(address);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
//});
|
||||||
|
|
||||||
return addresses;
|
//return addresses;
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> fetchYatAccessToken(String refreshToken) async {
|
Future<String> fetchYatAccessToken(String refreshToken) async {
|
||||||
try {
|
//try {
|
||||||
final url = YatLink.apiUrl + '/auth/token/refresh';
|
// final url = YatLink.apiUrl + '/auth/token/refresh';
|
||||||
final bodyJson = json.encode({'refresh_token': refreshToken});
|
// final bodyJson = json.encode({'refresh_token': refreshToken});
|
||||||
final response = await post(
|
// final response = await post(
|
||||||
url,
|
// url,
|
||||||
headers: <String, String>{
|
// headers: <String, String>{
|
||||||
'Content-Type': 'application/json',
|
// 'Content-Type': 'application/json',
|
||||||
'Accept': '*/*'
|
// 'Accept': '*/*'
|
||||||
},
|
// },
|
||||||
body: bodyJson);
|
// body: bodyJson);
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
// if (response.statusCode != 200) {
|
||||||
throw YatException(text: response.body.toString());
|
// throw YatException(text: response.body.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
// final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||||
return responseJSON['access_token'] as String;
|
// return responseJSON['access_token'] as String;
|
||||||
}catch(_) {
|
//}catch(_) {
|
||||||
|
// return '';
|
||||||
|
//}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> fetchYatApiKey(String accessKey) async {
|
Future<String> fetchYatApiKey(String accessKey) async {
|
||||||
try {
|
//try {
|
||||||
final url = YatLink.apiUrl + '/api_keys';
|
// final url = YatLink.apiUrl + '/api_keys';
|
||||||
final bodyJson = json.encode({'name': 'CW'});
|
// final bodyJson = json.encode({'name': 'CW'});
|
||||||
final response = await post(
|
// final response = await post(
|
||||||
url,
|
// url,
|
||||||
headers: <String, String>{
|
// headers: <String, String>{
|
||||||
'Authorization': 'Bearer $accessKey',
|
// 'Authorization': 'Bearer $accessKey',
|
||||||
'Content-Type': 'application/json',
|
// 'Content-Type': 'application/json',
|
||||||
'Accept': '*/*'
|
// 'Accept': '*/*'
|
||||||
},
|
// },
|
||||||
body: bodyJson);
|
// body: bodyJson);
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
// if (response.statusCode != 200) {
|
||||||
throw YatException(text: response.body.toString());
|
// throw YatException(text: response.body.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
// final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||||
return responseJSON['api_key'] as String;
|
// return responseJSON['api_key'] as String;
|
||||||
}catch(_) {
|
//}catch(_) {
|
||||||
|
// return '';
|
||||||
|
//}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> updateEmojiIdAddress(String emojiId, String address, String apiKey, WalletType type) async {
|
Future<void> updateEmojiIdAddress(String emojiId, String address, String apiKey, WalletType type) async {
|
||||||
final url = YatLink.emojiIdUrl + emojiId;
|
//final url = YatLink.emojiIdUrl + emojiId;
|
||||||
final cur = walletTypeToCryptoCurrency(type);
|
//final cur = walletTypeToCryptoCurrency(type);
|
||||||
final curFormatted = cur.toString().toUpperCase();
|
//final curFormatted = cur.toString().toUpperCase();
|
||||||
var tag = '';
|
//var tag = '';
|
||||||
|
|
||||||
if (type == WalletType.monero && !address.startsWith('4')) {
|
//if (type == WalletType.monero && !address.startsWith('4')) {
|
||||||
tag = YatLink.tags[curFormatted].last;
|
// tag = YatLink.tags[curFormatted].last;
|
||||||
} else {
|
//} else {
|
||||||
tag = YatLink.tags[curFormatted].first;
|
// tag = YatLink.tags[curFormatted].first;
|
||||||
}
|
//}
|
||||||
|
|
||||||
final bodyJson = json.encode({
|
//final bodyJson = json.encode({
|
||||||
'insert': [{
|
// 'insert': [{
|
||||||
'data': address,
|
// 'data': address,
|
||||||
'tag': tag
|
// 'tag': tag
|
||||||
}]
|
// }]
|
||||||
});
|
//});
|
||||||
final response = await patch(
|
//final response = await patch(
|
||||||
url,
|
// url,
|
||||||
headers: <String, String>{
|
// headers: <String, String>{
|
||||||
'x-api-key': apiKey,
|
// 'x-api-key': apiKey,
|
||||||
'Content-Type': 'application/json',
|
// 'Content-Type': 'application/json',
|
||||||
'Accept': '*/*'
|
// 'Accept': '*/*'
|
||||||
},
|
// },
|
||||||
body: bodyJson);
|
// body: bodyJson);
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
//if (response.statusCode != 200) {
|
||||||
throw YatException(text: response.body.toString());
|
// throw YatException(text: response.body.toString());
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> visualisationForEmojiId(String emojiId) async {
|
Future<String> visualisationForEmojiId(String emojiId) async {
|
||||||
final url = YatLink.emojiIdUrl + emojiId + '/json/VisualizerFileLocations';
|
//final url = YatLink.emojiIdUrl + emojiId + '/json/VisualizerFileLocations';
|
||||||
final response = await get(url);
|
//final response = await get(url);
|
||||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
//final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||||
final data = responseJSON['data'] as Map<String, dynamic>;
|
//final data = responseJSON['data'] as Map<String, dynamic>;
|
||||||
final result = data['gif'] as String ?? '';
|
//final result = data['gif'] as String ?? '';
|
||||||
return result;
|
//return result;
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
class YatStore = YatStoreBase with _$YatStore;
|
class YatStore = YatStoreBase with _$YatStore;
|
||||||
|
@ -254,18 +258,19 @@ abstract class YatStoreBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
String defineQueryParameters() {
|
String defineQueryParameters() {
|
||||||
final result = <String, String>{};
|
//final result = <String, String>{};
|
||||||
final tags = YatLink.tags[_wallet.currency.toString().toUpperCase()];
|
//final tags = YatLink.tags[_wallet.currency.toString().toUpperCase()];
|
||||||
String tag = tags.first;
|
//String tag = tags.first;
|
||||||
|
|
||||||
if (_wallet.type == WalletType.monero
|
//if (_wallet.type == WalletType.monero
|
||||||
&& _wallet.walletAddresses.address.startsWith('4')) {
|
// && _wallet.walletAddresses.address.startsWith('4')) {
|
||||||
tag = tags.last;
|
// tag = tags.last;
|
||||||
}
|
//}
|
||||||
result[tag] = '${_wallet.walletAddresses.address}|${_wallet.name}';
|
//result[tag] = '${_wallet.walletAddresses.address}|${_wallet.name}';
|
||||||
final addressJson = json.encode([result]);
|
//final addressJson = json.encode([result]);
|
||||||
final addressJsonBytes = utf8.encode(addressJson);
|
//final addressJsonBytes = utf8.encode(addressJson);
|
||||||
|
|
||||||
return base64.encode(addressJsonBytes);
|
//return base64.encode(addressJsonBytes);
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -77,16 +77,16 @@ abstract class WalletAddressListViewModelBase with Store {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
reaction((_) => yatStore.emoji, (String emojiId) => this.emoji = emojiId);
|
//reaction((_) => yatStore.emoji, (String emojiId) => this.emoji = emojiId);
|
||||||
|
|
||||||
_onLastUsedYatAddressSubscription =
|
//_onLastUsedYatAddressSubscription =
|
||||||
_wallet.walletInfo.yatLastUsedAddressStream.listen((String yatAddress) {
|
// _wallet.walletInfo.yatLastUsedAddressStream.listen((String yatAddress) {
|
||||||
if (yatAddress == _wallet.walletAddresses.address) {
|
// if (yatAddress == _wallet.walletAddresses.address) {
|
||||||
emoji = yatStore.emoji;
|
// emoji = yatStore.emoji;
|
||||||
} else {
|
// } else {
|
||||||
emoji = '';
|
// emoji = '';
|
||||||
}
|
// }
|
||||||
});
|
//});
|
||||||
|
|
||||||
if (_wallet.walletAddresses.address == _wallet.walletInfo.yatLastUsedAddress) {
|
if (_wallet.walletAddresses.address == _wallet.walletInfo.yatLastUsedAddress) {
|
||||||
emoji = yatStore.emoji;
|
emoji = yatStore.emoji;
|
||||||
|
@ -223,4 +223,15 @@ abstract class WalletAddressListViewModelBase with Store {
|
||||||
wallet.save();
|
wallet.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
void generateRandomAddress() {
|
||||||
|
final wallet = _wallet;
|
||||||
|
|
||||||
|
if (wallet.type == WalletType.bitcoin
|
||||||
|
|| wallet.type == WalletType.litecoin) {
|
||||||
|
bitcoin.randomAddress(wallet);
|
||||||
|
wallet.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue