New versions (#1355)

* New versions

* Check for Taproot inputs when exchanging with ThorChain

* Properly handle taproot case with thorchain

* fix missing import
This commit is contained in:
Omar Hatem
2024-04-01 15:31:14 +02:00
committed by GitHub
parent 1f904dcd47
commit 62ef545fce
11 changed files with 71 additions and 35 deletions
+5
View File
@@ -239,4 +239,9 @@ class CWBitcoin extends Bitcoin {
return SegwitAddresType.p2wpkh;
}
}
@override
bool hasTaprootInput(PendingTransaction pendingTransaction) {
return (pendingTransaction as PendingBitcoinTransaction).hasTaprootInputs;
}
}
+15 -1
View File
@@ -308,13 +308,19 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
pendingTransaction = await wallet.createTransaction(_credentials());
if (provider is ThorChainExchangeProvider) {
final outputCount = pendingTransaction?.outputCount ?? 0;
if (outputCount > 10) throw Exception("ThorChain does not support more than 10 outputs");
if (outputCount > 10) {
throw Exception("ThorChain does not support more than 10 outputs");
}
if (_hasTaprootInput(pendingTransaction)) {
throw Exception("ThorChain does not support Taproot addresses");
}
}
state = ExecutedSuccessfullyState();
return pendingTransaction;
} catch (e) {
state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency));
}
return null;
}
@action
@@ -512,4 +518,12 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
return errorMessage;
}
bool _hasTaprootInput(PendingTransaction? pendingTransaction) {
if (walletType == WalletType.bitcoin && pendingTransaction != null) {
return bitcoin!.hasTaprootInput(pendingTransaction);
}
return false;
}
}