CW-702: fix mismatched amounts in multDest transactions (#1653)

* CW-702: fix mismatched amounts in multDest transactions

* separate txkeys in multdest transactions

* update monero_c dependency
This commit is contained in:
cyan 2024-09-05 04:54:34 +02:00 committed by GitHub
parent 783f1a2349
commit 0b06ad3a07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 46 additions and 10 deletions

View file

@ -138,11 +138,17 @@ PendingTransactionDescription createTransactionMultDestSync(
int accountIndex = 0, int accountIndex = 0,
List<String> preferredInputs = const []}) { List<String> preferredInputs = const []}) {
final dstAddrs = outputs.map((e) => e.address).toList();
final amounts = outputs.map((e) => monero.Wallet_amountFromString(e.amount)).toList();
// print("multDest: dstAddrs: $dstAddrs");
// print("multDest: amounts: $amounts");
final txptr = monero.Wallet_createTransactionMultDest( final txptr = monero.Wallet_createTransactionMultDest(
wptr!, wptr!,
dstAddr: outputs.map((e) => e.address).toList(), dstAddr: dstAddrs,
isSweepAll: false, isSweepAll: false,
amounts: outputs.map((e) => monero.Wallet_amountFromString(e.amount)).toList(), amounts: amounts,
mixinCount: 0, mixinCount: 0,
pendingTransactionPriority: priorityRaw, pendingTransactionPriority: priorityRaw,
subaddr_account: accountIndex, subaddr_account: accountIndex,
@ -307,7 +313,34 @@ class Transaction {
confirmations = monero.TransactionInfo_confirmations(txInfo), confirmations = monero.TransactionInfo_confirmations(txInfo),
fee = monero.TransactionInfo_fee(txInfo), fee = monero.TransactionInfo_fee(txInfo),
description = monero.TransactionInfo_description(txInfo), description = monero.TransactionInfo_description(txInfo),
key = monero.Wallet_getTxKey(wptr!, txid: monero.TransactionInfo_hash(txInfo)); key = getTxKey(txInfo);
static String getTxKey(monero.TransactionInfo txInfo) {
final txKey = monero.Wallet_getTxKey(wptr!, txid: monero.TransactionInfo_hash(txInfo));
final status = monero.Wallet_status(wptr!);
if (status != 0) {
return monero.Wallet_errorString(wptr!);
}
return breakTxKey(txKey);
}
static String breakTxKey(String input) {
final x = 64;
StringBuffer buffer = StringBuffer();
for (int i = 0; i < input.length; i += x) {
int endIndex = i + x;
if (endIndex > input.length) {
endIndex = input.length;
}
buffer.write(input.substring(i, endIndex));
if (endIndex != input.length) {
buffer.write('\n\n');
}
}
return buffer.toString().trim();
}
Transaction.dummy({ Transaction.dummy({
required this.displayLabel, required this.displayLabel,

View file

@ -463,8 +463,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "impls/monero.dart" path: "impls/monero.dart"
ref: bcb328a4956105dc182afd0ce2e48fe263f5f20b ref: 3cb38bee9385faf46b03fd73aab85f3ac4115bf7
resolved-ref: bcb328a4956105dc182afd0ce2e48fe263f5f20b resolved-ref: 3cb38bee9385faf46b03fd73aab85f3ac4115bf7
url: "https://github.com/mrcyjanek/monero_c" url: "https://github.com/mrcyjanek/monero_c"
source: git source: git
version: "0.0.0" version: "0.0.0"

View file

@ -25,7 +25,7 @@ dependencies:
monero: monero:
git: git:
url: https://github.com/mrcyjanek/monero_c url: https://github.com/mrcyjanek/monero_c
ref: bcb328a4956105dc182afd0ce2e48fe263f5f20b # monero_c hash ref: 3cb38bee9385faf46b03fd73aab85f3ac4115bf7 # monero_c hash
path: impls/monero.dart path: impls/monero.dart
mutex: ^3.1.0 mutex: ^3.1.0

View file

@ -463,8 +463,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "impls/monero.dart" path: "impls/monero.dart"
ref: bcb328a4956105dc182afd0ce2e48fe263f5f20b ref: 3cb38bee9385faf46b03fd73aab85f3ac4115bf7
resolved-ref: bcb328a4956105dc182afd0ce2e48fe263f5f20b resolved-ref: 3cb38bee9385faf46b03fd73aab85f3ac4115bf7
url: "https://github.com/mrcyjanek/monero_c" url: "https://github.com/mrcyjanek/monero_c"
source: git source: git
version: "0.0.0" version: "0.0.0"

View file

@ -25,7 +25,7 @@ dependencies:
monero: monero:
git: git:
url: https://github.com/mrcyjanek/monero_c url: https://github.com/mrcyjanek/monero_c
ref: bcb328a4956105dc182afd0ce2e48fe263f5f20b # monero_c hash ref: 3cb38bee9385faf46b03fd73aab85f3ac4115bf7 # monero_c hash
path: impls/monero.dart path: impls/monero.dart
mutex: ^3.1.0 mutex: ^3.1.0

View file

@ -273,6 +273,7 @@ class SendPage extends BasePage {
? template.cryptoCurrency ? template.cryptoCurrency
: template.fiatCurrency, : template.fiatCurrency,
onTap: () async { onTap: () async {
sendViewModel.state = IsExecutingState();
if (template.additionalRecipients?.isNotEmpty ?? false) { if (template.additionalRecipients?.isNotEmpty ?? false) {
sendViewModel.clearOutputs(); sendViewModel.clearOutputs();
@ -301,6 +302,7 @@ class SendPage extends BasePage {
template: template, template: template,
); );
} }
sendViewModel.state = InitialExecutionState();
}, },
onRemove: () { onRemove: () {
showPopUp<void>( showPopUp<void>(
@ -368,6 +370,7 @@ class SendPage extends BasePage {
builder: (_) { builder: (_) {
return LoadingPrimaryButton( return LoadingPrimaryButton(
onPressed: () async { onPressed: () async {
if (sendViewModel.state is IsExecutingState) return;
if (_formKey.currentState != null && !_formKey.currentState!.validate()) { if (_formKey.currentState != null && !_formKey.currentState!.validate()) {
if (sendViewModel.outputs.length > 1) { if (sendViewModel.outputs.length > 1) {
showErrorValidationAlert(context); showErrorValidationAlert(context);

View file

@ -8,7 +8,7 @@ if [[ ! -d "monero_c" ]];
then then
git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip
cd monero_c cd monero_c
git checkout 5de323b1ba7387cf73973042f06383d4dbe619f5 git checkout 3cb38bee9385faf46b03fd73aab85f3ac4115bf7
git reset --hard git reset --hard
git submodule update --init --force --recursive git submodule update --init --force --recursive
./apply_patches.sh monero ./apply_patches.sh monero