bug-fix: account for other send outputs that are part of the same tx

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
This commit is contained in:
Philemon Ukane 2024-08-12 15:49:14 +01:00 committed by JoeGruff
parent 2de388bd51
commit 48b3fd2472
5 changed files with 11 additions and 7 deletions

View file

@ -337,7 +337,7 @@ abstract class DecredWalletBase extends WalletBase<DecredBalance,
return defaultFeeRate; return defaultFeeRate;
} }
}; };
final p = priority as DecredTransactionPriority; final p = priority;
switch (p) { switch (p) {
case DecredTransactionPriority.slow: case DecredTransactionPriority.slow:
if (feeRateSlow.isOld()) { if (feeRateSlow.isOld()) {
@ -388,7 +388,6 @@ abstract class DecredWalletBase extends WalletBase<DecredBalance,
return this.fetchFiveTransactions(0); return this.fetchFiveTransactions(0);
} }
@override
Future<Map<String, DecredTransactionInfo>> fetchFiveTransactions( Future<Map<String, DecredTransactionInfo>> fetchFiveTransactions(
int from) async { int from) async {
final res = final res =
@ -396,7 +395,7 @@ abstract class DecredWalletBase extends WalletBase<DecredBalance,
final decoded = json.decode(res); final decoded = json.decode(res);
var txs = <String, DecredTransactionInfo>{}; var txs = <String, DecredTransactionInfo>{};
for (final d in decoded) { for (final d in decoded) {
final txid = d["txid"] ?? ""; final txid = uniqueTxID(d["txid"] ?? "", d["vout"] ?? 0);
var direction = TransactionDirection.outgoing; var direction = TransactionDirection.outgoing;
if (d["category"] == "receive") { if (d["category"] == "receive") {
direction = TransactionDirection.incoming; direction = TransactionDirection.incoming;
@ -423,6 +422,11 @@ abstract class DecredWalletBase extends WalletBase<DecredBalance,
return txs; return txs;
} }
// uniqueTxID combines the tx id and vout to create a unique id.
String uniqueTxID(String id, int vout) {
return id + ":" + vout.toString();
}
@override @override
Future<void> save() async {} Future<void> save() async {}

View file

@ -182,7 +182,7 @@ abstract class TransactionDetailsViewModelBase with Store {
case WalletType.wownero: case WalletType.wownero:
return 'https://explore.wownero.com/tx/${txId}'; return 'https://explore.wownero.com/tx/${txId}';
case WalletType.decred: case WalletType.decred:
return 'https://dcrdata.decred.org/tx/${txId}'; return 'https://dcrdata.decred.org/tx/${txId.split(':')[0]}';
case WalletType.none: case WalletType.none:
return ''; return '';
} }

View file

@ -4,7 +4,7 @@
CW_DECRED_DIR=${WORKDIR}/cake_wallet/cw_decred CW_DECRED_DIR=${WORKDIR}/cake_wallet/cw_decred
LIBWALLET_PATH="${WORKDIR}/decred/libwallet" LIBWALLET_PATH="${WORKDIR}/decred/libwallet"
LIBWALLET_URL="https://github.com/decred/libwallet.git" LIBWALLET_URL="https://github.com/decred/libwallet.git"
LIBWALLET_VERSION="v1.0.4" LIBWALLET_VERSION="v1.1.0"
if [ -e $LIBWALLET_PATH ]; then if [ -e $LIBWALLET_PATH ]; then
rm -fr $LIBWALLET_PATH rm -fr $LIBWALLET_PATH

View file

@ -3,7 +3,7 @@
. ./config.sh . ./config.sh
LIBWALLET_PATH="${EXTERNAL_IOS_SOURCE_DIR}/libwallet" LIBWALLET_PATH="${EXTERNAL_IOS_SOURCE_DIR}/libwallet"
LIBWALLET_URL="https://github.com/decred/libwallet.git" LIBWALLET_URL="https://github.com/decred/libwallet.git"
LIBWALLET_VERSION="v1.0.4" LIBWALLET_VERSION="v1.1.0"
if [ -e $LIBWALLET_PATH ]; then if [ -e $LIBWALLET_PATH ]; then
rm -fr $LIBWALLET_PATH rm -fr $LIBWALLET_PATH

View file

@ -4,7 +4,7 @@
LIBWALLET_PATH="${EXTERNAL_MACOS_SOURCE_DIR}/libwallet" LIBWALLET_PATH="${EXTERNAL_MACOS_SOURCE_DIR}/libwallet"
LIBWALLET_URL="https://github.com/decred/libwallet.git" LIBWALLET_URL="https://github.com/decred/libwallet.git"
LIBWALLET_VERSION="v1.0.4" LIBWALLET_VERSION="v1.1.0"
echo "======================= DECRED LIBWALLET =========================" echo "======================= DECRED LIBWALLET ========================="