mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-22 06:28:39 +02:00
implement-payjoin (#1949)
* Initial Payjoin * Initial Payjoin * More payjoin stuff * Minor fixes * Minor fixes * Minor cleanup * Minor cleanup * Minor cleanup * Minor cleanup * Minor cleanup * Minor cleanup * Fix minor bug causes by data inconsistency in the btc utxos * Minor cleanup * Minor cleanup * Minor cleanup * Minor cleanup * Initial Payjoin * Initial Payjoin * More payjoin stuff * Minor fixes * Minor fixes * Minor cleanup * Minor cleanup * Minor cleanup * Minor cleanup * Minor cleanup * Minor cleanup * Fix minor bug causes by data inconsistency in the btc utxos * Minor cleanup * Minor cleanup * Minor cleanup * Minor cleanup * Fix Rebase issues * Move PJ Receiver to isolate * Add Payjoin Setting * Payjoin Sender are now isolated * Added Payjoin sessions to tx overview. Fix Fee issue with payjoin * Clean up code * Fix taproot for payjoin * Fix CI Errors * Add Payjoin UI elements and details page * Add Payjoin UI elements and details page * Fix Translations * feat: Detect Payjoin URIs in pasted text and show to the User sending Payjoin * feat: rename pjUri to payjoinURI for more code clarity * Update res/values/strings_pl.arb Co-authored-by: cyan <cyjan@mrcyjanek.net> * Update cw_bitcoin/lib/payjoin/manager.dart Co-authored-by: cyan <cyjan@mrcyjanek.net> * Update cw_bitcoin/lib/payjoin/manager.dart Co-authored-by: cyan <cyjan@mrcyjanek.net> * feat: Disable Payjoin per default * feat: Disable Payjoin fully if disabled or no Inputs available * feat: Resume Payjoin if app comes back to foreground * chore: Revert overly aggressive code formats * feat: show correct Payjoin amount for receivers * feat: Improved payjoin status * feat: Show payjoin errors on payjoin details screen * deps: update flutter to 3.27.4 * feat: Revert localisations * bug: Remove duplicate transaction id on payjoin details * style: remove double await in payjoin sender * refactor(cw_bitcoin): Refactor method signatures and convert constructor to factory * refactor(cw_bitcoin): Refactor wallet service and PSBT signer for cleaner code Removed unnecessary `CakeHive` dependency and refactored `BitcoinWallet` initialization to use `payjoinSessionSource`. Improved code readability in `PsbtSigner` by reformatting lines and simplifying constructor methods for `UtxoWithPrivateKey`. * fix: Resume Payjoin Sessions and load PJUri after sleep * feat: Add "Copy Payjoin URL button" to receive screen * fix: Add "Payjoin enabled"-Box below QR Code on the receive screen * fix: Set payjoin_enabled color to black independent of the theme * refactor: Payjoin session management and cleanup unused code. --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> Co-authored-by: cyan <cyjan@mrcyjanek.net>
This commit is contained in:
co-authored by
cyan
Omar Hatem
parent
4a08e18f00
commit
82e3ebf4fa
@@ -0,0 +1,47 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cake_wallet/view_model/dashboard/payjoin_transaction_list_item.dart';
|
||||
import 'package:cw_core/payjoin_session.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'payjoin_transactions_store.g.dart';
|
||||
|
||||
class PayjoinTransactionsStore = PayjoinTransactionsStoreBase
|
||||
with _$PayjoinTransactionsStore;
|
||||
|
||||
abstract class PayjoinTransactionsStoreBase with Store {
|
||||
PayjoinTransactionsStoreBase({
|
||||
required this.payjoinSessionSource,
|
||||
}) : transactions = <PayjoinTransactionListItem>[] {
|
||||
payjoinSessionSource.watch().listen((_) => updateTransactionList());
|
||||
updateTransactionList();
|
||||
}
|
||||
|
||||
Box<PayjoinSession> payjoinSessionSource;
|
||||
|
||||
@observable
|
||||
List<PayjoinTransactionListItem> transactions;
|
||||
|
||||
@action
|
||||
Future<void> updateTransactionList() async {
|
||||
final updatedTransactions = <PayjoinTransactionListItem>[];
|
||||
payjoinSessionSource.toMap().forEach((dynamic key, PayjoinSession session) {
|
||||
if ([
|
||||
PayjoinSessionStatus.inProgress.name,
|
||||
PayjoinSessionStatus.success.name,
|
||||
PayjoinSessionStatus.unrecoverable.name
|
||||
].contains(session.status) &&
|
||||
session.inProgressSince != null) {
|
||||
updatedTransactions.add(PayjoinTransactionListItem(
|
||||
sessionId: key as String,
|
||||
session: session,
|
||||
key: ValueKey('payjoin_transaction_list_item_${key}_key'),
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
transactions = updatedTransactions;
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,7 @@ abstract class SettingsStoreBase with Store {
|
||||
required this.lookupsOpenAlias,
|
||||
required this.lookupsENS,
|
||||
required this.lookupsWellKnown,
|
||||
required this.usePayjoin,
|
||||
required this.customBitcoinFeeRate,
|
||||
required this.silentPaymentsCardDisplay,
|
||||
required this.silentPaymentsAlwaysScan,
|
||||
@@ -483,6 +484,11 @@ abstract class SettingsStoreBase with Store {
|
||||
(bool looksUpWellKnown) =>
|
||||
_sharedPreferences.setBool(PreferencesKey.lookupsWellKnown, looksUpWellKnown));
|
||||
|
||||
reaction(
|
||||
(_) => usePayjoin,
|
||||
(bool usePayjoin) =>
|
||||
_sharedPreferences.setBool(PreferencesKey.usePayjoin, usePayjoin));
|
||||
|
||||
// secure storage keys:
|
||||
reaction(
|
||||
(_) => allowBiometricalAuthentication,
|
||||
@@ -802,6 +808,9 @@ abstract class SettingsStoreBase with Store {
|
||||
@observable
|
||||
bool lookupsWellKnown;
|
||||
|
||||
@observable
|
||||
bool usePayjoin;
|
||||
|
||||
@observable
|
||||
SyncMode currentSyncMode;
|
||||
|
||||
@@ -1009,6 +1018,7 @@ abstract class SettingsStoreBase with Store {
|
||||
final lookupsOpenAlias = sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias) ?? true;
|
||||
final lookupsENS = sharedPreferences.getBool(PreferencesKey.lookupsENS) ?? true;
|
||||
final lookupsWellKnown = sharedPreferences.getBool(PreferencesKey.lookupsWellKnown) ?? true;
|
||||
final usePayjoin = sharedPreferences.getBool(PreferencesKey.usePayjoin) ?? false;
|
||||
final customBitcoinFeeRate = sharedPreferences.getInt(PreferencesKey.customBitcoinFeeRate) ?? 1;
|
||||
final silentPaymentsCardDisplay =
|
||||
sharedPreferences.getBool(PreferencesKey.silentPaymentsCardDisplay) ?? true;
|
||||
@@ -1311,6 +1321,7 @@ abstract class SettingsStoreBase with Store {
|
||||
lookupsOpenAlias: lookupsOpenAlias,
|
||||
lookupsENS: lookupsENS,
|
||||
lookupsWellKnown: lookupsWellKnown,
|
||||
usePayjoin: usePayjoin,
|
||||
customBitcoinFeeRate: customBitcoinFeeRate,
|
||||
silentPaymentsCardDisplay: silentPaymentsCardDisplay,
|
||||
silentPaymentsAlwaysScan: silentPaymentsAlwaysScan,
|
||||
|
||||
Reference in New Issue
Block a user