Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main to v1.10.2 #803

Merged
merged 36 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
51b709e
use add_return_used_coins branch of flutter_libsparkmobile
sneurlax Feb 26, 2024
5d9dc02
update _createSparkSend signature to return used coins
sneurlax Feb 26, 2024
01881aa
translate usedCoins to usedUTXOs
sneurlax Feb 27, 2024
06e6407
Revert "remove temporary doge fee hackfix"
sneurlax Feb 27, 2024
2513600
update epicbox
sneurlax Feb 27, 2024
2ac1558
find SparkCoins that correspond to the usedCoins returned from spark lib
sneurlax Feb 28, 2024
a90071f
use base64 used coins returned from flutter_libsparkmobile
sneurlax Feb 28, 2024
38c9de2
WIP: Update to latest Epic release
Likho Feb 28, 2024
4c98ee0
tweak spark used coins update on successful send
julian-CStack Feb 28, 2024
ab3df05
Check if default Epicbox is up on start up, always update wallet addr…
Likho Feb 28, 2024
891f2d8
Attemp to update cached receiving address
Likho Feb 28, 2024
41d71f0
Remove failover options for Epicbox
Likho Feb 28, 2024
a147217
Merge pull request #780 from cypherstack/fees
rehrar Feb 28, 2024
5b18631
Merge pull request #781 from cypherstack/epicbox
rehrar Feb 28, 2024
9ee3377
Merge pull request #783 from cypherstack/update-to-latest-epic
rehrar Feb 28, 2024
e6fd6d0
point to flutter_libsparkmobile main
sneurlax Feb 28, 2024
9eaa939
Merge branch 'staging' into firo
sneurlax Feb 28, 2024
defc301
add "&all" param to eth api call
sneurlax Feb 28, 2024
c1ca427
Merge pull request #782 from cypherstack/firo
rehrar Feb 28, 2024
bdc06db
Merge pull request #785 from cypherstack/eth
rehrar Feb 28, 2024
3a5a886
remove Expanded widget from restore wallet view
sneurlax Mar 1, 2024
b7cb9ab
Merge pull request #788 from cypherstack/ui
rehrar Feb 29, 2024
375ca6e
Update version (v1.10.2, build 213)
rehrar Mar 1, 2024
fd47c13
Update to latest version of Epic
Likho Mar 1, 2024
dffcd31
Merge pull request #789 from cypherstack/epic-v3.6.0-update
rehrar Mar 1, 2024
794e969
export specific NDK version for flutter_libepiccash android build
sneurlax Mar 4, 2024
d63cda7
Merge pull request #790 from cypherstack/epic
rehrar Mar 4, 2024
a55775d
move epic hackfix into build_all.sh
sneurlax Mar 4, 2024
11db23c
Merge pull request #791 from cypherstack/epic
rehrar Mar 4, 2024
c0d54ee
update ANDROID_NDK_HOME var
sneurlax Mar 4, 2024
0060f9c
fix r21 NDK URL in flutter_libepiccash
sneurlax Mar 4, 2024
414803d
scripts fixes
sneurlax Mar 4, 2024
0c8e99b
Merge pull request #792 from cypherstack/epic
rehrar Mar 4, 2024
e893945
build opensll for flutter_libepiccash android as well
sneurlax Mar 4, 2024
31df6b1
Merge pull request #793 from cypherstack/epic
rehrar Mar 4, 2024
7cebd31
Update version (v1.10.2, build 214)
rehrar Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/electrumx_rpc/electrumx_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,18 @@ class ElectrumXClient {
],
);
try {
// If the response is -1 or null, return a temporary hardcoded value for
// Dogecoin. This is a temporary fix until the fee estimation is fixed.
if (coin == Coin.dogecoin &&
(response == null ||
response == -1 ||
Decimal.parse(response.toString()) == Decimal.parse("-1"))) {
// Return 0.05 for slow, 0.2 for average, and 1 for fast txs.
// These numbers produce tx fees in line with txs in the wild on
// https://dogechain.info/
return Decimal.parse((1 / blocks).toString());
// TODO [prio=med]: Fix fee estimation.
}
return Decimal.parse(response.toString());
} catch (e, s) {
final String msg = "Error parsing fee rate. Response: $response"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,15 +724,10 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
],
),
body: Container(
color: Theme.of(context).extension<StackColors>()!.background,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: ConditionalParent(
condition: isDesktop,
builder: (child) => Expanded(
child: child,
),
child: SingleChildScrollView(
color: Theme.of(context).extension<StackColors>()!.background,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: SingleChildScrollView(
controller: controller,
child: Column(
children: [
Expand Down Expand Up @@ -1203,7 +1198,6 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
),
),
),
),
);
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ class _TransactionV2DetailsViewState
pTransactionNote(
(
txid: (coin == Coin.epicCash) ?
_transaction.slateId as String
_transaction.slateId.toString()
: _transaction.txid,
walletId: walletId
),
Expand Down
2 changes: 1 addition & 1 deletion lib/services/ethereum/ethereum_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ abstract class EthereumAPI {
final response = await client.get(
url: Uri.parse(
// "$stackBaseServer/tokens?addrs=$contractAddress&parts=all",
"$stackBaseServer/names?terms=$contractAddress",
"$stackBaseServer/names?terms=$contractAddress&all",
),
proxyInfo: Prefs.instance.useTor
? TorService.sharedInstance.getProxyInfo()
Expand Down
2 changes: 1 addition & 1 deletion lib/utilities/default_epicboxes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class DefaultEpicBoxes {
static List<String> get defaultIds => ['americas', 'asia', 'europe'];

static EpicBoxServerModel get americas => EpicBoxServerModel(
host: 'stackwallet.epicbox.com',
host: 'epicbox.stackwallet.com',
port: 443,
name: 'Americas',
id: 'americas',
Expand Down
6 changes: 6 additions & 0 deletions lib/wallets/models/tx_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
import 'package:stackwallet/wallets/isar/models/spark_coin.dart';
import 'package:tezart/tezart.dart' as tezart;
import 'package:web3dart/web3dart.dart' as web3dart;

Expand Down Expand Up @@ -69,6 +70,7 @@ class TxData {
bool isChange,
})>? sparkRecipients;
final List<TxData>? sparkMints;
final List<SparkCoin>? usedSparkCoins;

final TransactionV2? tempTx;

Expand Down Expand Up @@ -105,6 +107,7 @@ class TxData {
this.tezosOperationsList,
this.sparkRecipients,
this.sparkMints,
this.usedSparkCoins,
this.tempTx,
});

Expand Down Expand Up @@ -187,6 +190,7 @@ class TxData {
})>?
sparkRecipients,
List<TxData>? sparkMints,
List<SparkCoin>? usedSparkCoins,
TransactionV2? tempTx,
}) {
return TxData(
Expand Down Expand Up @@ -224,6 +228,7 @@ class TxData {
tezosOperationsList: tezosOperationsList ?? this.tezosOperationsList,
sparkRecipients: sparkRecipients ?? this.sparkRecipients,
sparkMints: sparkMints ?? this.sparkMints,
usedSparkCoins: usedSparkCoins ?? this.usedSparkCoins,
tempTx: tempTx ?? this.tempTx,
);
}
Expand Down Expand Up @@ -262,6 +267,7 @@ class TxData {
'tezosOperationsList: $tezosOperationsList, '
'sparkRecipients: $sparkRecipients, '
'sparkMints: $sparkMints, '
'usedSparkCoins: $usedSparkCoins, '
'tempTx: $tempTx, '
'}';
}
127 changes: 63 additions & 64 deletions lib/wallets/wallet/impl/epiccash_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,46 +103,30 @@ class EpiccashWallet extends Bip39Wallet {
}

Future<EpicBoxConfigModel> getEpicBoxConfig() async {
EpicBoxConfigModel? _epicBoxConfig;
// read epicbox config from secure store
String? storedConfig =
await secureStorageInterface.read(key: '${walletId}_epicboxConfig');

// we should move to storing the primary server model like we do with nodes, and build the config from that (see epic-mobile)
// EpicBoxServerModel? _epicBox = epicBox ??
// DB.instance.get<EpicBoxServerModel>(
// boxName: DB.boxNamePrimaryEpicBox, key: 'primary');
// Logging.instance.log(
// "Read primary Epic Box config: ${jsonEncode(_epicBox)}",
// level: LogLevel.Info);

if (storedConfig == null) {
// if no config stored, use the default epicbox server as config
_epicBoxConfig =
EpicBoxConfigModel.fromServer(DefaultEpicBoxes.defaultEpicBoxServer);
} else {
// if a config is stored, test it

_epicBoxConfig = EpicBoxConfigModel.fromString(
storedConfig); // fromString handles checking old config formats
}

bool isEpicboxConnected = await _testEpicboxServer(
_epicBoxConfig.host, _epicBoxConfig.port ?? 443);

if (!isEpicboxConnected) {
// default Epicbox is not connected, default to Europe
_epicBoxConfig = EpicBoxConfigModel.fromServer(DefaultEpicBoxes.europe);

// example of selecting another random server from the default list
// alternative servers: copy list of all default EB servers but remove the default default
// List<EpicBoxServerModel> alternativeServers = DefaultEpicBoxes.all;
// alternativeServers.removeWhere((opt) => opt.name == DefaultEpicBoxes.defaultEpicBoxServer.name);
// alternativeServers.shuffle(); // randomize which server is used
// _epicBoxConfig = EpicBoxConfigModel.fromServer(alternativeServers.first);

// TODO test this connection before returning it
}
EpicBoxConfigModel? _epicBoxConfig =
EpicBoxConfigModel.fromServer(DefaultEpicBoxes.defaultEpicBoxServer);

//Get the default Epicbox server and check if it's conected
// bool isEpicboxConnected = await _testEpicboxServer(
// DefaultEpicBoxes.defaultEpicBoxServer.host, DefaultEpicBoxes.defaultEpicBoxServer.port ?? 443);

// if (isEpicboxConnected) {
//Use default server for as Epicbox config

// }
// else {
// //Use Europe config
// _epicBoxConfig = EpicBoxConfigModel.fromServer(DefaultEpicBoxes.europe);
// }
// // example of selecting another random server from the default list
// // alternative servers: copy list of all default EB servers but remove the default default
// // List<EpicBoxServerModel> alternativeServers = DefaultEpicBoxes.all;
// // alternativeServers.removeWhere((opt) => opt.name == DefaultEpicBoxes.defaultEpicBoxServer.name);
// // alternativeServers.shuffle(); // randomize which server is used
// // _epicBoxConfig = EpicBoxConfigModel.fromServer(alternativeServers.first);
//
// // TODO test this connection before returning it
// }

return _epicBoxConfig;
}
Expand Down Expand Up @@ -334,36 +318,50 @@ class EpiccashWallet extends Bip39Wallet {
int index,
) async {
Address? address = await getCurrentReceivingAddress();
EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig();

if (address == null) {
final wallet =
await secureStorageInterface.read(key: '${walletId}_wallet');
EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig();
if (address != null) {
final splitted = address.value.split('@');
//Check if the address is the same as the current epicbox domain
//Since we're only using one epicbpox now this doesn't apply but will be
// useful in the future
if (splitted[1] != epicboxConfig.host) {
//Update the address
address = await thisWalletAddress(index, epicboxConfig);
}
} else {
address = await thisWalletAddress(index, epicboxConfig);
}
return address;
}

final walletAddress = await epiccash.LibEpiccash.getAddressInfo(
wallet: wallet!,
index: index,
epicboxConfig: epicboxConfig.toString(),
);
Future<Address> thisWalletAddress(int index, EpicBoxConfigModel epicboxConfig) async {
final wallet =
await secureStorageInterface.read(key: '${walletId}_wallet');
// EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig();

Logging.instance.log(
"WALLET_ADDRESS_IS $walletAddress",
level: LogLevel.Info,
);
final walletAddress = await epiccash.LibEpiccash.getAddressInfo(
wallet: wallet!,
index: index,
epicboxConfig: epicboxConfig.toString(),
);

address = Address(
walletId: walletId,
value: walletAddress,
derivationIndex: index,
derivationPath: null,
type: AddressType.mimbleWimble,
subType: AddressSubType.receiving,
publicKey: [], // ??
);
Logging.instance.log(
"WALLET_ADDRESS_IS $walletAddress",
level: LogLevel.Info,
);

await mainDB.updateOrPutAddresses([address]);
}
final address = Address(
walletId: walletId,
value: walletAddress,
derivationIndex: index,
derivationPath: null,
type: AddressType.mimbleWimble,
subType: AddressSubType.receiving,
publicKey: [], // ??
);

await mainDB.updateOrPutAddresses([address]);
return address;
}

Expand Down Expand Up @@ -936,6 +934,7 @@ class EpiccashWallet extends Bip39Wallet {
.findAll();
final myAddressesSet = myAddresses.toSet();


final transactions = await epiccash.LibEpiccash.getTransactions(
wallet: wallet!,
refreshFromNode: refreshFromNode,
Expand Down
44 changes: 36 additions & 8 deletions lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,27 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
),
);

final List<SparkCoin> usedSparkCoins = [];

for (final usedCoin in spend.usedCoins) {
try {
usedSparkCoins.add(coins
.firstWhere((e) =>
usedCoin.height == e.height &&
usedCoin.groupId == e.groupId &&
base64Decode(e.serializedCoinB64!)
.toHex
.startsWith(base64Decode(usedCoin.serializedCoin).toHex))
.copyWith(
isUsed: true,
));
} catch (_) {
throw Exception(
"Unexpectedly did not find used spark coin. This should never happen.",
);
}
}

return txData.copyWith(
raw: rawTxHex,
vSize: extractedTx.virtualSize(),
Expand All @@ -523,7 +544,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
height: null,
version: 3,
),
// TODO used coins
usedSparkCoins: usedSparkCoins,
);
}

Expand All @@ -540,17 +561,17 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
Logging.instance.log("Sent txHash: $txHash", level: LogLevel.Info);

txData = txData.copyWith(
// TODO mark spark coins as spent locally and update balance before waiting to check via electrumx?

// usedUTXOs:
// txData.usedUTXOs!.map((e) => e.copyWith(used: true)).toList(),

// TODO revisit setting these both
txHash: txHash,
txid: txHash,
);
// // mark utxos as used
// await mainDB.putUTXOs(txData.usedUTXOs!);

// Update used spark coins as used in database. They should already have
// been marked as isUsed.
// TODO: [prio=med] Could (probably should) throw an exception here if txData.usedSparkCoins is null or empty
if (txData.usedSparkCoins != null && txData.usedSparkCoins!.isNotEmpty) {
await _addOrUpdateSparkCoins(txData.usedSparkCoins!);
}

return await updateSentCachedTxData(txData: txData);
} catch (e, s) {
Expand Down Expand Up @@ -1499,6 +1520,13 @@ Future<
Uint8List serializedSpendPayload,
List<Uint8List> outputScripts,
int fee,
List<
({
int groupId,
int height,
String serializedCoin,
String serializedCoinContext
})> usedCoins,
})> _createSparkSend(
({
String privateKeyHex,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: fb50031056fbea0326f7dd76ad59d165c1e5eee5
resolved-ref: fb50031056fbea0326f7dd76ad59d165c1e5eee5
ref: "3f986ca1a94bdac5d31373454c989cc2f5842de8"
resolved-ref: "3f986ca1a94bdac5d31373454c989cc2f5842de8"
url: "https://github.com/cypherstack/flutter_libsparkmobile.git"
source: git
version: "0.0.1"
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Stack Wallet
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.10.1+212
version: 1.10.2+214

environment:
sdk: ">=3.0.2 <4.0.0"
Expand All @@ -30,7 +30,7 @@ dependencies:
flutter_libsparkmobile:
git:
url: https://github.com/cypherstack/flutter_libsparkmobile.git
ref: fb50031056fbea0326f7dd76ad59d165c1e5eee5
ref: 3f986ca1a94bdac5d31373454c989cc2f5842de8

flutter_libmonero:
path: ./crypto_plugins/flutter_libmonero
Expand Down
2 changes: 1 addition & 1 deletion scripts/android/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdir -p build
./install_ndk.sh

(cd ../../crypto_plugins/flutter_liblelantus/scripts/android && ./build_all.sh ) &
(cd ../../crypto_plugins/flutter_libepiccash/scripts/android && ./install_ndk.sh && ./build_all.sh ) &
(cd ../../crypto_plugins/flutter_libepiccash/scripts/android && ./install_ndk.sh && ./build_opensll.sh && ./build_all.sh ) &
(cd ../../crypto_plugins/flutter_libmonero/scripts/android/ && ./build_all.sh ) &

wait
Expand Down
Loading