Skip to content

Commit

Permalink
Don't convert unselected inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
willyfromtheblock committed Apr 20, 2024
1 parent 560b8cb commit b48631e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/screens/wallet/wallet_sign_transaction.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:coinlib_flutter/coinlib_flutter.dart';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -170,11 +171,19 @@ class _WalletSignTransactionScreenState
final privKey = WIF.fromString(wif).privkey;

Transaction tx = Transaction.fromHex(_txInputController.text);
final selectedInputResult = await _showInputSelector(tx.inputs.length);
if (selectedInputResult == false) return;
if (_checkedInputs.values.every((element) => element == false)) return;

// conversion step for cointoolkit start
tx = Transaction(
inputs: tx.inputs.map((input) {
// Determine program from CTK input script data
inputs: tx.inputs.mapIndexed((i, input) {
if (!_checkedInputs.containsKey(i)) {
//don't convert this unselected input, return as is
return input;
}

// Determine program from cointoolkit input script data
final program = Program.decompile(input.scriptSig);

if (program is P2PKH) {
Expand All @@ -199,10 +208,6 @@ class _WalletSignTransactionScreenState
);
// conversion step for cointoolkit end

final selectedInputResult = await _showInputSelector(tx.inputs.length);
if (selectedInputResult == false) return;
if (_checkedInputs.values.every((element) => element == false)) return;

Transaction txToSign = tx;
_checkedInputs.forEach((key, value) {
if (value) {
Expand Down

0 comments on commit b48631e

Please sign in to comment.