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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 71 additions and 35 deletions

View file

@ -1,4 +1,2 @@
Monero enhancements Exchange flow enhancements and fixes
In-App live status page for the app services Generic enhancements and bug fixes
Add Exolix exchange provider
Bug fixes and enhancements

View file

@ -1 +1,6 @@
Bug fixes and enhancements Exchange flow enhancements and fixes
Add MoonPay to Buy options
Add THORChain to Exchange providers
Improve Bitcoin fee calculations
Fixes and enhancements for Solana
Generic enhancements and bug fixes

View file

@ -544,6 +544,8 @@ abstract class ElectrumWalletBase
); );
} }
bool hasTaprootInputs = false;
final transaction = txb.buildTransaction((txDigest, utxo, publicKey, sighash) { final transaction = txb.buildTransaction((txDigest, utxo, publicKey, sighash) {
final key = estimatedTx.privateKeys final key = estimatedTx.privateKeys
.firstWhereOrNull((element) => element.getPublic().toHex() == publicKey); .firstWhereOrNull((element) => element.getPublic().toHex() == publicKey);
@ -553,21 +555,25 @@ abstract class ElectrumWalletBase
} }
if (utxo.utxo.isP2tr()) { if (utxo.utxo.isP2tr()) {
hasTaprootInputs = true;
return key.signTapRoot(txDigest, sighash: sighash); return key.signTapRoot(txDigest, sighash: sighash);
} else { } else {
return key.signInput(txDigest, sigHash: sighash); return key.signInput(txDigest, sigHash: sighash);
} }
}); });
return PendingBitcoinTransaction(transaction, type, return PendingBitcoinTransaction(
electrumClient: electrumClient, transaction,
amount: estimatedTx.amount, type,
fee: estimatedTx.fee, electrumClient: electrumClient,
feeRate: feeRateInt.toString(), amount: estimatedTx.amount,
network: network, fee: estimatedTx.fee,
hasChange: estimatedTx.hasChange, feeRate: feeRateInt.toString(),
isSendAll: estimatedTx.isSendAll) network: network,
..addListener((transaction) async { hasChange: estimatedTx.hasChange,
isSendAll: estimatedTx.isSendAll,
hasTaprootInputs: hasTaprootInputs,
)..addListener((transaction) async {
transactionHistory.addOne(transaction); transactionHistory.addOne(transaction);
await updateBalance(); await updateBalance();
}); });

View file

@ -8,15 +8,18 @@ import 'package:cw_core/transaction_direction.dart';
import 'package:cw_core/wallet_type.dart'; import 'package:cw_core/wallet_type.dart';
class PendingBitcoinTransaction with PendingTransaction { class PendingBitcoinTransaction with PendingTransaction {
PendingBitcoinTransaction(this._tx, this.type, PendingBitcoinTransaction(
{required this.electrumClient, this._tx,
required this.amount, this.type, {
required this.fee, required this.electrumClient,
required this.feeRate, required this.amount,
this.network, required this.fee,
required this.hasChange, required this.feeRate,
required this.isSendAll}) this.network,
: _listeners = <void Function(ElectrumTransactionInfo transaction)>[]; required this.hasChange,
required this.isSendAll,
this.hasTaprootInputs = false,
}) : _listeners = <void Function(ElectrumTransactionInfo transaction)>[];
final WalletType type; final WalletType type;
final BtcTransaction _tx; final BtcTransaction _tx;
@ -27,6 +30,7 @@ class PendingBitcoinTransaction with PendingTransaction {
final BasedUtxoNetwork? network; final BasedUtxoNetwork? network;
final bool hasChange; final bool hasChange;
final bool isSendAll; final bool isSendAll;
final bool hasTaprootInputs;
@override @override
String get id => _tx.txId(); String get id => _tx.txId();

View file

@ -13,6 +13,7 @@ class PolygonClient extends EVMChainClient {
required EthereumAddress to, required EthereumAddress to,
required EtherAmount amount, required EtherAmount amount,
EtherAmount? maxPriorityFeePerGas, EtherAmount? maxPriorityFeePerGas,
Uint8List? data,
}) { }) {
return Transaction( return Transaction(
from: from, from: from,

View file

@ -239,4 +239,9 @@ class CWBitcoin extends Bitcoin {
return SegwitAddresType.p2wpkh; return SegwitAddresType.p2wpkh;
} }
} }
@override
bool hasTaprootInput(PendingTransaction pendingTransaction) {
return (pendingTransaction as PendingBitcoinTransaction).hasTaprootInputs;
}
} }

View file

@ -308,13 +308,19 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
pendingTransaction = await wallet.createTransaction(_credentials()); pendingTransaction = await wallet.createTransaction(_credentials());
if (provider is ThorChainExchangeProvider) { if (provider is ThorChainExchangeProvider) {
final outputCount = pendingTransaction?.outputCount ?? 0; 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(); state = ExecutedSuccessfullyState();
return pendingTransaction; return pendingTransaction;
} catch (e) { } catch (e) {
state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency)); state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency));
} }
return null;
} }
@action @action
@ -512,4 +518,12 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
return errorMessage; return errorMessage;
} }
bool _hasTaprootInput(PendingTransaction? pendingTransaction) {
if (walletType == WalletType.bitcoin && pendingTransaction != null) {
return bitcoin!.hasTaprootInput(pendingTransaction);
}
return false;
}
} }

View file

@ -15,15 +15,15 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
APP_ANDROID_TYPE=$1 APP_ANDROID_TYPE=$1
MONERO_COM_NAME="Monero.com" MONERO_COM_NAME="Monero.com"
MONERO_COM_VERSION="1.12.0" MONERO_COM_VERSION="1.12.1"
MONERO_COM_BUILD_NUMBER=79 MONERO_COM_BUILD_NUMBER=80
MONERO_COM_BUNDLE_ID="com.monero.app" MONERO_COM_BUNDLE_ID="com.monero.app"
MONERO_COM_PACKAGE="com.monero.app" MONERO_COM_PACKAGE="com.monero.app"
MONERO_COM_SCHEME="monero.com" MONERO_COM_SCHEME="monero.com"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.15.2" CAKEWALLET_VERSION="4.15.3"
CAKEWALLET_BUILD_NUMBER=200 CAKEWALLET_BUILD_NUMBER=202
CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet" CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet" CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
CAKEWALLET_SCHEME="cakewallet" CAKEWALLET_SCHEME="cakewallet"

View file

@ -13,13 +13,13 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
APP_IOS_TYPE=$1 APP_IOS_TYPE=$1
MONERO_COM_NAME="Monero.com" MONERO_COM_NAME="Monero.com"
MONERO_COM_VERSION="1.12.0" MONERO_COM_VERSION="1.12.1"
MONERO_COM_BUILD_NUMBER=77 MONERO_COM_BUILD_NUMBER=77
MONERO_COM_BUNDLE_ID="com.cakewallet.monero" MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.15.2" CAKEWALLET_VERSION="4.15.3"
CAKEWALLET_BUILD_NUMBER=219 CAKEWALLET_BUILD_NUMBER=221
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
HAVEN_NAME="Haven" HAVEN_NAME="Haven"

View file

@ -16,13 +16,13 @@ if [ -n "$1" ]; then
fi fi
MONERO_COM_NAME="Monero.com" MONERO_COM_NAME="Monero.com"
MONERO_COM_VERSION="1.2.0" MONERO_COM_VERSION="1.2.1"
MONERO_COM_BUILD_NUMBER=10 MONERO_COM_BUILD_NUMBER=11
MONERO_COM_BUNDLE_ID="com.cakewallet.monero" MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="1.8.2" CAKEWALLET_VERSION="1.8.3"
CAKEWALLET_BUILD_NUMBER=59 CAKEWALLET_BUILD_NUMBER=61
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then

View file

@ -61,6 +61,7 @@ Future<void> main(List<String> args) async {
Future<void> generateBitcoin(bool hasImplementation) async { Future<void> generateBitcoin(bool hasImplementation) async {
final outputFile = File(bitcoinOutputPath); final outputFile = File(bitcoinOutputPath);
const bitcoinCommonHeaders = """ const bitcoinCommonHeaders = """
import 'package:cw_core/pending_transaction.dart';
import 'package:cw_core/receive_page_option.dart'; import 'package:cw_core/receive_page_option.dart';
import 'package:cw_core/unspent_transaction_output.dart'; import 'package:cw_core/unspent_transaction_output.dart';
import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_credentials.dart';
@ -74,6 +75,7 @@ import 'package:cake_wallet/view_model/send/output.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:bitcoin_base/bitcoin_base.dart';"""; import 'package:bitcoin_base/bitcoin_base.dart';""";
const bitcoinCWHeaders = """ const bitcoinCWHeaders = """
import 'package:cw_bitcoin/pending_bitcoin_transaction.dart';
import 'package:cw_bitcoin/bitcoin_receive_page_option.dart'; import 'package:cw_bitcoin/bitcoin_receive_page_option.dart';
import 'package:cw_bitcoin/electrum_wallet.dart'; import 'package:cw_bitcoin/electrum_wallet.dart';
import 'package:cw_bitcoin/bitcoin_unspent.dart'; import 'package:cw_bitcoin/bitcoin_unspent.dart';
@ -148,6 +150,7 @@ abstract class Bitcoin {
ReceivePageOption getSelectedAddressType(Object wallet); ReceivePageOption getSelectedAddressType(Object wallet);
List<ReceivePageOption> getBitcoinReceivePageOptions(); List<ReceivePageOption> getBitcoinReceivePageOptions();
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option); BitcoinAddressType getBitcoinAddressType(ReceivePageOption option);
bool hasTaprootInput(PendingTransaction pendingTransaction);
} }
"""; """;