Skip to content

Commit 8b82eb1

Browse files
committed
fix: checkBlockUTXO only checking the specific UTXO output
1 parent 243015b commit 8b82eb1

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

lib/wallets/wallet/impl/particl_wallet.dart

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,36 @@ class ParticlWallet<T extends ElectrumXCurrencyInterface>
7373
String? blockedReason;
7474
String? utxoLabel;
7575

76+
// Only check the specific output this UTXO corresponds to, not all outputs.
77+
final vout = jsonUTXO["tx_pos"] as int;
7678
final outputs = jsonTX["vout"] as List? ?? [];
7779

78-
for (final output in outputs) {
79-
if (output is Map) {
80-
if (output['ct_fee'] != null) {
81-
// Blind output, ignore for now.
82-
blocked = true;
83-
blockedReason = "Blind output.";
84-
utxoLabel = "Unsupported output type.";
85-
} else if (output['rangeproof'] != null) {
86-
// Private RingCT output, ignore for now.
87-
blocked = true;
88-
blockedReason = "Confidential output.";
89-
utxoLabel = "Unsupported output type.";
90-
} else if (output['data_hex'] != null) {
91-
// Data output, ignore for now.
80+
final output = outputs.cast<Map<String, dynamic>?>().firstWhere(
81+
(e) => e?["n"] == vout,
82+
orElse: () => null,
83+
);
84+
85+
if (output != null) {
86+
if (output['ct_fee'] != null) {
87+
blocked = true;
88+
blockedReason = "Blind output.";
89+
utxoLabel = "Unsupported output type.";
90+
} else if (output['rangeproof'] != null) {
91+
blocked = true;
92+
blockedReason = "Confidential output.";
93+
utxoLabel = "Unsupported output type.";
94+
} else if (output['data_hex'] != null) {
95+
blocked = true;
96+
blockedReason = "Data output.";
97+
utxoLabel = "Unsupported output type.";
98+
} else if (output['scriptPubKey'] != null) {
99+
if (output['scriptPubKey']?['asm'] is String &&
100+
(output['scriptPubKey']['asm'] as String).contains(
101+
"OP_ISCOINSTAKE",
102+
)) {
92103
blocked = true;
93-
blockedReason = "Data output.";
104+
blockedReason = "Spending staking";
94105
utxoLabel = "Unsupported output type.";
95-
} else if (output['scriptPubKey'] != null) {
96-
if (output['scriptPubKey']?['asm'] is String &&
97-
(output['scriptPubKey']['asm'] as String).contains(
98-
"OP_ISCOINSTAKE",
99-
)) {
100-
blocked = true;
101-
blockedReason = "Spending staking";
102-
utxoLabel = "Unsupported output type.";
103-
}
104106
}
105107
}
106108
}

0 commit comments

Comments
 (0)