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
In-App live status page for the app services
Add Exolix exchange provider
Bug fixes and enhancements
Exchange flow enhancements and fixes
Generic enhancements and bug fixes

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

View file

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

View file

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

View file

@ -239,4 +239,9 @@ class CWBitcoin extends Bitcoin {
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());
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;
}
}

View file

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

View file

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

View file

@ -16,13 +16,13 @@ if [ -n "$1" ]; then
fi
MONERO_COM_NAME="Monero.com"
MONERO_COM_VERSION="1.2.0"
MONERO_COM_BUILD_NUMBER=10
MONERO_COM_VERSION="1.2.1"
MONERO_COM_BUILD_NUMBER=11
MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="1.8.2"
CAKEWALLET_BUILD_NUMBER=59
CAKEWALLET_VERSION="1.8.3"
CAKEWALLET_BUILD_NUMBER=61
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
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 {
final outputFile = File(bitcoinOutputPath);
const bitcoinCommonHeaders = """
import 'package:cw_core/pending_transaction.dart';
import 'package:cw_core/receive_page_option.dart';
import 'package:cw_core/unspent_transaction_output.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:bitcoin_base/bitcoin_base.dart';""";
const bitcoinCWHeaders = """
import 'package:cw_bitcoin/pending_bitcoin_transaction.dart';
import 'package:cw_bitcoin/bitcoin_receive_page_option.dart';
import 'package:cw_bitcoin/electrum_wallet.dart';
import 'package:cw_bitcoin/bitcoin_unspent.dart';
@ -148,6 +150,7 @@ abstract class Bitcoin {
ReceivePageOption getSelectedAddressType(Object wallet);
List<ReceivePageOption> getBitcoinReceivePageOptions();
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option);
bool hasTaprootInput(PendingTransaction pendingTransaction);
}
""";