mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-28 06:28:41 +01:00
Changed way for generation of change address for electrum wallets. Remove some yats call.
This commit is contained in:
@@ -56,6 +56,12 @@ class CWBitcoin extends Bitcoin {
|
||||
final bitcoinWallet = wallet as BitcoinWallet;
|
||||
bitcoinWallet.walletAddresses.nextAddress();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> randomAddress(Object wallet) {
|
||||
final bitcoinWallet = wallet as BitcoinWallet;
|
||||
bitcoinWallet.walletAddresses.randomizeAddress();
|
||||
}
|
||||
|
||||
@override
|
||||
Object createBitcoinTransactionCredentials(List<Output> outputs, TransactionPriority priority)
|
||||
|
||||
+13
-13
@@ -197,7 +197,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_handleIncomingLinks();
|
||||
_handleInitialUri();
|
||||
//_handleInitialUri();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -235,18 +235,18 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||
}
|
||||
|
||||
void _fetchEmojiFromUri(Uri uri) {
|
||||
final queryParameters = uri.queryParameters;
|
||||
if (queryParameters?.isEmpty ?? true) {
|
||||
return;
|
||||
}
|
||||
final emoji = queryParameters['eid'];
|
||||
final refreshToken = queryParameters['refresh_token'];
|
||||
if ((emoji?.isEmpty ?? true)||(refreshToken?.isEmpty ?? true)) {
|
||||
return;
|
||||
}
|
||||
yatStore.emoji = emoji;
|
||||
yatStore.refreshToken = refreshToken;
|
||||
yatStore.emojiIncommingSC.add(emoji);
|
||||
//final queryParameters = uri.queryParameters;
|
||||
//if (queryParameters?.isEmpty ?? true) {
|
||||
// return;
|
||||
//}
|
||||
//final emoji = queryParameters['eid'];
|
||||
//final refreshToken = queryParameters['refresh_token'];
|
||||
//if ((emoji?.isEmpty ?? true)||(refreshToken?.isEmpty ?? true)) {
|
||||
// return;
|
||||
//}
|
||||
//yatStore.emoji = emoji;
|
||||
//yatStore.refreshToken = refreshToken;
|
||||
//yatStore.emojiIncommingSC.add(emoji);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -17,34 +17,34 @@ import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||
|
||||
ReactionDisposer _onCurrentWalletChangeReaction;
|
||||
ReactionDisposer _onCurrentWalletChangeFiatRateUpdateReaction;
|
||||
ReactionDisposer _onCurrentWalletAddressChangeReaction;
|
||||
//ReactionDisposer _onCurrentWalletAddressChangeReaction;
|
||||
|
||||
void startCurrentWalletChangeReaction(AppStore appStore,
|
||||
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
|
||||
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
||||
_onCurrentWalletChangeFiatRateUpdateReaction?.reaction?.dispose();
|
||||
_onCurrentWalletAddressChangeReaction?.reaction?.dispose();
|
||||
//_onCurrentWalletAddressChangeReaction?.reaction?.dispose();
|
||||
|
||||
_onCurrentWalletAddressChangeReaction = reaction((_) => appStore.wallet.walletAddresses.address,
|
||||
(String address) async {
|
||||
if (address == appStore.wallet.walletInfo.yatLastUsedAddress) {
|
||||
return;
|
||||
}
|
||||
//_onCurrentWalletAddressChangeReaction = reaction((_) => appStore.wallet.walletAddresses.address,
|
||||
//(String address) async {
|
||||
//if (address == appStore.wallet.walletInfo.yatLastUsedAddress) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
try {
|
||||
final yatStore = getIt.get<YatStore>();
|
||||
await updateEmojiIdAddress(
|
||||
appStore.wallet.walletInfo.yatEmojiId,
|
||||
appStore.wallet.walletAddresses.address,
|
||||
yatStore.apiKey,
|
||||
appStore.wallet.type
|
||||
);
|
||||
appStore.wallet.walletInfo.yatLastUsedAddress = address;
|
||||
await appStore.wallet.walletInfo.save();
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
});
|
||||
//try {
|
||||
// final yatStore = getIt.get<YatStore>();
|
||||
// await updateEmojiIdAddress(
|
||||
// appStore.wallet.walletInfo.yatEmojiId,
|
||||
// appStore.wallet.walletAddresses.address,
|
||||
// yatStore.apiKey,
|
||||
// appStore.wallet.type
|
||||
// );
|
||||
// appStore.wallet.walletInfo.yatLastUsedAddress = address;
|
||||
// await appStore.wallet.walletInfo.save();
|
||||
//} catch (e) {
|
||||
// print(e.toString());
|
||||
//}
|
||||
//});
|
||||
|
||||
_onCurrentWalletChangeReaction = reaction((_) => appStore.wallet, (WalletBase<
|
||||
Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>
|
||||
|
||||
@@ -27,6 +27,7 @@ class AddressPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
addressListViewModel.generateRandomAddress();
|
||||
autorun((_) async {
|
||||
if (!walletViewModel.isOutdatedElectrumWallet
|
||||
|| !walletViewModel.settingsStore.shouldShowReceiveWarning) {
|
||||
@@ -124,15 +125,15 @@ class AddressPage extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: PrimaryButton(
|
||||
onPressed: () => addressListViewModel.nextAddress(),
|
||||
text: 'Next address',
|
||||
color: Theme.of(context).buttonColor,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display3
|
||||
.backgroundColor);
|
||||
) : Container();
|
||||
//: PrimaryButton(
|
||||
// onPressed: () => addressListViewModel.nextAddress(),
|
||||
// text: 'Next address',
|
||||
// color: Theme.of(context).buttonColor,
|
||||
// textColor: Theme.of(context)
|
||||
// .accentTextTheme
|
||||
// .display3
|
||||
// .backgroundColor);
|
||||
})
|
||||
],
|
||||
),
|
||||
|
||||
@@ -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 =
|
||||
_wallet.walletInfo.yatLastUsedAddressStream.listen((String yatAddress) {
|
||||
if (yatAddress == _wallet.walletAddresses.address) {
|
||||
emoji = yatStore.emoji;
|
||||
} else {
|
||||
emoji = '';
|
||||
}
|
||||
});
|
||||
//_onLastUsedYatAddressSubscription =
|
||||
// _wallet.walletInfo.yatLastUsedAddressStream.listen((String yatAddress) {
|
||||
// if (yatAddress == _wallet.walletAddresses.address) {
|
||||
// emoji = yatStore.emoji;
|
||||
// } else {
|
||||
// emoji = '';
|
||||
// }
|
||||
//});
|
||||
|
||||
if (_wallet.walletAddresses.address == _wallet.walletInfo.yatLastUsedAddress) {
|
||||
emoji = yatStore.emoji;
|
||||
@@ -223,4 +223,15 @@ abstract class WalletAddressListViewModelBase with Store {
|
||||
wallet.save();
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
void generateRandomAddress() {
|
||||
final wallet = _wallet;
|
||||
|
||||
if (wallet.type == WalletType.bitcoin
|
||||
|| wallet.type == WalletType.litecoin) {
|
||||
bitcoin.randomAddress(wallet);
|
||||
wallet.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user