mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
Merge pull request #783 from cypherstack/update-to-latest-epic
Update to latest epic
This commit is contained in:
commit
9ee3377be1
3 changed files with 65 additions and 66 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 9eb24dd00cd0e1df08624ece1ca47090c158c08c
|
||||
Subproject commit 396d519a4c3ae1c47c8406e5506b0966f1f7098f
|
|
@ -1048,7 +1048,7 @@ class _TransactionV2DetailsViewState
|
|||
pTransactionNote(
|
||||
(
|
||||
txid: (coin == Coin.epicCash) ?
|
||||
_transaction.slateId as String
|
||||
_transaction.slateId.toString()
|
||||
: _transaction.txid,
|
||||
walletId: walletId
|
||||
),
|
||||
|
|
|
@ -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');
|
||||
EpicBoxConfigModel? _epicBoxConfig =
|
||||
EpicBoxConfigModel.fromServer(DefaultEpicBoxes.defaultEpicBoxServer);
|
||||
|
||||
// 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);
|
||||
//Get the default Epicbox server and check if it's conected
|
||||
// bool isEpicboxConnected = await _testEpicboxServer(
|
||||
// DefaultEpicBoxes.defaultEpicBoxServer.host, DefaultEpicBoxes.defaultEpicBoxServer.port ?? 443);
|
||||
|
||||
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
|
||||
// if (isEpicboxConnected) {
|
||||
//Use default server for as Epicbox config
|
||||
|
||||
_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
|
||||
}
|
||||
// }
|
||||
// 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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
final walletAddress = await epiccash.LibEpiccash.getAddressInfo(
|
||||
wallet: wallet!,
|
||||
index: index,
|
||||
epicboxConfig: epicboxConfig.toString(),
|
||||
);
|
||||
|
||||
Logging.instance.log(
|
||||
"WALLET_ADDRESS_IS $walletAddress",
|
||||
level: LogLevel.Info,
|
||||
);
|
||||
|
||||
address = Address(
|
||||
walletId: walletId,
|
||||
value: walletAddress,
|
||||
derivationIndex: index,
|
||||
derivationPath: null,
|
||||
type: AddressType.mimbleWimble,
|
||||
subType: AddressSubType.receiving,
|
||||
publicKey: [], // ??
|
||||
);
|
||||
|
||||
await mainDB.updateOrPutAddresses([address]);
|
||||
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;
|
||||
}
|
||||
|
||||
Future<Address> thisWalletAddress(int index, EpicBoxConfigModel epicboxConfig) async {
|
||||
final wallet =
|
||||
await secureStorageInterface.read(key: '${walletId}_wallet');
|
||||
// EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig();
|
||||
|
||||
final walletAddress = await epiccash.LibEpiccash.getAddressInfo(
|
||||
wallet: wallet!,
|
||||
index: index,
|
||||
epicboxConfig: epicboxConfig.toString(),
|
||||
);
|
||||
|
||||
Logging.instance.log(
|
||||
"WALLET_ADDRESS_IS $walletAddress",
|
||||
level: LogLevel.Info,
|
||||
);
|
||||
|
||||
final address = Address(
|
||||
walletId: walletId,
|
||||
value: walletAddress,
|
||||
derivationIndex: index,
|
||||
derivationPath: null,
|
||||
type: AddressType.mimbleWimble,
|
||||
subType: AddressSubType.receiving,
|
||||
publicKey: [], // ??
|
||||
);
|
||||
|
||||
await mainDB.updateOrPutAddresses([address]);
|
||||
return address;
|
||||
}
|
||||
|
||||
|
@ -936,6 +934,7 @@ class EpiccashWallet extends Bip39Wallet {
|
|||
.findAll();
|
||||
final myAddressesSet = myAddresses.toSet();
|
||||
|
||||
|
||||
final transactions = await epiccash.LibEpiccash.getTransactions(
|
||||
wallet: wallet!,
|
||||
refreshFromNode: refreshFromNode,
|
||||
|
|
Loading…
Reference in a new issue