Skip to content

Commit

Permalink
Fix PjURI amount not filling on send page
Browse files Browse the repository at this point in the history
  • Loading branch information
J0J0XMR committed Dec 11, 2024
1 parent 7364c7d commit 15e70fe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion cw_bitcoin/lib/bitcoin_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
BitcoinOrdering outputOrdering = BitcoinOrdering.bip69,
}) async {
final psbtReadyInputs = <PSBTReadyUtxoWithAddress>[];
for (final utxo in utxos) {
for (final UtxoWithAddress utxo in utxos) {
debugPrint('[+] BITCOINWALLET => UTXO.utxo - ${utxo.utxo.toString()}');
final rawTx =
await electrumClient.getTransactionHex(hash: utxo.utxo.txHash);
final publicKeyAndDerivationPath =
Expand Down
6 changes: 3 additions & 3 deletions lib/src/screens/send/send_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,13 @@ class SendPage extends BasePage {
context,
conditionToDetermineIfToUse2FA: check,
onAuthSuccess: (value) async {
debugPrint('[+] SendPage | value: $value');
debugPrint(
'[+] SENDPAGE => onAuthSuccess - value: $value');
if (value) {
// await sendViewModel.stringToPjUri();
if (sendViewModel.pjUri != null) {
debugPrint(
'[+] SendPage || INITIATE PAYJOIN SEND');
'[+] SENDPAGE => onAuthSuccess - INITIATE PAYJOIN SEND');
await sendViewModel.performPayjoinSend();
} else {
await sendViewModel.createTransaction();
Expand Down Expand Up @@ -481,7 +482,6 @@ class SendPage extends BasePage {
}

if (sendViewModel.isElectrumWallet) {
debugPrint('[+] SendPage || _setEffects() => isElectrumWallet');
bitcoin!.updateFeeRates(sendViewModel.wallet);
}

Expand Down
16 changes: 10 additions & 6 deletions lib/src/screens/send/widgets/send_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ class SendCardState extends State<SendCard>
return;
}

print("[+] SendCard || _setEffects => output.address: ${output.address}");
debugPrint(
"[+] SENDCARD => _setEffects - output.address: ${output.address}");

if (output.address.isNotEmpty) {
addressController.text = output.address;
Expand Down Expand Up @@ -510,13 +511,13 @@ class SendCardState extends State<SendCard>
}
});

addressController.addListener(() {
addressController.addListener(() async {
final address = addressController.text;

if (output.address != address) {
output.resetParsedAddress();
output.address = address;
sendViewModel.stringToPjUri();
await sendViewModel.stringToPjUri();
}
});

Expand All @@ -537,11 +538,14 @@ class SendCardState extends State<SendCard>
});

reaction((_) => sendViewModel.pjUri, (dynamic pjUri) {
print('[+] SendCard || pjUri reaction');
debugPrint(
'[+] SENDCARD => pjUri reaction - address: ${pjUri.address()}, amount: ${pjUri.amountSats()}');
if (pjUri != null) {
final amount = pjUri.amount();
final amount = pjUri.amountSats();
if (amount != null) {
cryptoAmountController.text = amount.toString();
final amountSats = int.parse(amount.toString());
final amountBtc = (amountSats / 100000000.0).toStringAsFixed(8);
cryptoAmountController.text = amountBtc.toString();
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions lib/view_model/send/send_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:cw_core/exceptions.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cake_wallet/view_model/send/output.dart';
import 'package:cake_wallet/view_model/send/send_template_view_model.dart';
import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
import 'package:ledger_flutter/ledger_flutter.dart';
import 'package:mobx/mobx.dart';
Expand Down Expand Up @@ -734,6 +735,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel

@action
Future<void> stringToPjUri() async {
debugPrint('[+] SENDVIEWMODEL => stringToPjUri()');
final address = outputs.first.address;
final uri = await bitcoin!.stringToPjUri(address);
pjUri = uri;
Expand Down

0 comments on commit 15e70fe

Please sign in to comment.