Skip to content

Commit 08ed0fc

Browse files
committed
fix list type cast
1 parent 4fff270 commit 08ed0fc

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

lib/wallets/wallet/impl/particl_wallet.dart

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,10 @@ class ParticlWallet<T extends ElectrumXCurrencyInterface>
352352
@override
353353
Future<TxData> buildTransaction({
354354
required TxData txData,
355-
required covariant List<StandardInput> inputsWithKeys,
355+
required List<BaseInput> inputsWithKeys,
356356
}) async {
357+
final insAndKeys = inputsWithKeys.cast<StandardInput>();
358+
357359
Logging.instance.d("Starting Particl buildTransaction ----------");
358360

359361
// TODO: use coinlib (For this we need coinlib to support particl)
@@ -371,8 +373,8 @@ class ParticlWallet<T extends ElectrumXCurrencyInterface>
371373
);
372374

373375
final List<({Uint8List? output, Uint8List? redeem})> extraData = [];
374-
for (int i = 0; i < inputsWithKeys.length; i++) {
375-
final sd = inputsWithKeys[i];
376+
for (int i = 0; i < insAndKeys.length; i++) {
377+
final sd = insAndKeys[i];
376378

377379
final pubKey = sd.key!.publicKey.data;
378380
final bitcoindart.PaymentData? data;
@@ -448,11 +450,11 @@ class ParticlWallet<T extends ElectrumXCurrencyInterface>
448450
final List<OutputV2> tempOutputs = [];
449451

450452
// Add inputs.
451-
for (var i = 0; i < inputsWithKeys.length; i++) {
452-
final txid = inputsWithKeys[i].utxo.txid;
453+
for (var i = 0; i < insAndKeys.length; i++) {
454+
final txid = insAndKeys[i].utxo.txid;
453455
txb.addInput(
454456
txid,
455-
inputsWithKeys[i].utxo.vout,
457+
insAndKeys[i].utxo.vout,
456458
null,
457459
extraData[i].output!,
458460
cryptoCurrency.networkParams.bech32Hrp,
@@ -464,14 +466,14 @@ class ParticlWallet<T extends ElectrumXCurrencyInterface>
464466
scriptSigAsm: null,
465467
sequence: 0xffffffff - 1,
466468
outpoint: OutpointV2.isarCantDoRequiredInDefaultConstructor(
467-
txid: inputsWithKeys[i].utxo.txid,
468-
vout: inputsWithKeys[i].utxo.vout,
469+
txid: insAndKeys[i].utxo.txid,
470+
vout: insAndKeys[i].utxo.vout,
469471
),
470472
addresses:
471-
inputsWithKeys[i].utxo.address == null
473+
insAndKeys[i].utxo.address == null
472474
? []
473-
: [inputsWithKeys[i].utxo.address!],
474-
valueStringSats: inputsWithKeys[i].utxo.value.toString(),
475+
: [insAndKeys[i].utxo.address!],
476+
valueStringSats: insAndKeys[i].utxo.value.toString(),
475477
witness: null,
476478
innerRedeemScriptAsm: null,
477479
coinbase: null,
@@ -508,15 +510,15 @@ class ParticlWallet<T extends ElectrumXCurrencyInterface>
508510

509511
// Sign.
510512
try {
511-
for (var i = 0; i < inputsWithKeys.length; i++) {
513+
for (var i = 0; i < insAndKeys.length; i++) {
512514
txb.sign(
513515
vin: i,
514516
keyPair: bitcoindart.ECPair.fromPrivateKey(
515-
inputsWithKeys[i].key!.privateKey!.data,
517+
insAndKeys[i].key!.privateKey!.data,
516518
network: convertedNetwork,
517-
compressed: inputsWithKeys[i].key!.privateKey!.compressed,
519+
compressed: insAndKeys[i].key!.privateKey!.compressed,
518520
),
519-
witnessValue: inputsWithKeys[i].utxo.value,
521+
witnessValue: insAndKeys[i].utxo.value,
520522
redeemScript: extraData[i].redeem,
521523
overridePrefix: cryptoCurrency.networkParams.bech32Hrp,
522524
);

lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ mixin BCashInterface<T extends ElectrumXCurrencyInterface>
1818
@override
1919
Future<TxData> buildTransaction({
2020
required TxData txData,
21-
required covariant List<StandardInput> inputsWithKeys,
21+
required List<BaseInput> inputsWithKeys,
2222
}) async {
23+
final insAndKeys = inputsWithKeys.cast<StandardInput>();
24+
2325
Logging.instance.d("Starting buildTransaction ----------");
2426

2527
// TODO: use coinlib
@@ -35,26 +37,23 @@ mixin BCashInterface<T extends ElectrumXCurrencyInterface>
3537
final List<OutputV2> tempOutputs = [];
3638

3739
// Add transaction inputs
38-
for (int i = 0; i < inputsWithKeys.length; i++) {
39-
builder.addInput(
40-
inputsWithKeys[i].utxo.txid,
41-
inputsWithKeys[i].utxo.vout,
42-
);
40+
for (int i = 0; i < insAndKeys.length; i++) {
41+
builder.addInput(insAndKeys[i].utxo.txid, insAndKeys[i].utxo.vout);
4342

4443
tempInputs.add(
4544
InputV2.isarCantDoRequiredInDefaultConstructor(
4645
scriptSigHex: "000000",
4746
scriptSigAsm: null,
4847
sequence: 0xffffffff - 1,
4948
outpoint: OutpointV2.isarCantDoRequiredInDefaultConstructor(
50-
txid: inputsWithKeys[i].utxo.txid,
51-
vout: inputsWithKeys[i].utxo.vout,
49+
txid: insAndKeys[i].utxo.txid,
50+
vout: insAndKeys[i].utxo.vout,
5251
),
5352
addresses:
54-
inputsWithKeys[i].utxo.address == null
53+
insAndKeys[i].utxo.address == null
5554
? []
56-
: [inputsWithKeys[i].utxo.address!],
57-
valueStringSats: inputsWithKeys[i].utxo.value.toString(),
55+
: [insAndKeys[i].utxo.address!],
56+
valueStringSats: insAndKeys[i].utxo.value.toString(),
5857
witness: null,
5958
innerRedeemScriptAsm: null,
6059
coinbase: null,
@@ -92,9 +91,9 @@ mixin BCashInterface<T extends ElectrumXCurrencyInterface>
9291

9392
try {
9493
// Sign the transaction accordingly
95-
for (int i = 0; i < inputsWithKeys.length; i++) {
94+
for (int i = 0; i < insAndKeys.length; i++) {
9695
final bitboxEC = bitbox.ECPair.fromPrivateKey(
97-
inputsWithKeys[i].key!.privateKey!.data,
96+
insAndKeys[i].key!.privateKey!.data,
9897
network: bitbox_utils.Network(
9998
cryptoCurrency.networkParams.privHDPrefix,
10099
cryptoCurrency.networkParams.pubHDPrefix,
@@ -103,10 +102,10 @@ mixin BCashInterface<T extends ElectrumXCurrencyInterface>
103102
cryptoCurrency.networkParams.wifPrefix,
104103
cryptoCurrency.networkParams.p2pkhPrefix,
105104
),
106-
compressed: inputsWithKeys[i].key!.privateKey!.compressed,
105+
compressed: insAndKeys[i].key!.privateKey!.compressed,
107106
);
108107

109-
builder.sign(i, bitboxEC, inputsWithKeys[i].utxo.value);
108+
builder.sign(i, bitboxEC, insAndKeys[i].utxo.value);
110109
}
111110
} catch (e, s) {
112111
Logging.instance.e(

0 commit comments

Comments
 (0)