cancelTransactions and createTransaction

This commit is contained in:
ryleedavis 2023-09-29 09:51:24 -06:00
parent b178c30620
commit b8a412988f

View file

@ -140,8 +140,15 @@ Future<void> executeNative(Map<String, dynamic> arguments) async {
secretKeyIndex == null || secretKeyIndex == null ||
epicboxConfig == null || epicboxConfig == null ||
minimumConfirmations == null)) { minimumConfirmations == null)) {
var res = await createTransaction(wallet, amount, address, var res = await epiccash.LibEpiccash.createTransaction(
secretKeyIndex, epicboxConfig, minimumConfirmations, onChainNote!); wallet: wallet,
amount: amount,
address: address,
secretKeyIndex: secretKeyIndex,
epicboxConfig: epicboxConfig,
minimumConfirmations: minimumConfirmations,
note: onChainNote!,
);
result['result'] = res; result['result'] = res;
sendPort.send(result); sendPort.send(result);
return; return;
@ -194,14 +201,6 @@ void stop(ReceivePort port) {
} }
} }
// Keep Wrapper functions outside of the class to avoid memory leaks and errors about receive ports and illegal arguments.
// TODO: Can get rid of this wrapper and call it in a full isolate instead of compute() if we want more control over this
Future<String> _cancelTransactionWrapper(Tuple2<String, String> data) async {
// assuming this returns an empty string on success
// or an error message string on failure
return cancelTransaction(data.item1, data.item2);
}
Future<String> deleteEpicWallet({ Future<String> deleteEpicWallet({
required String walletId, required String walletId,
required SecureStorageInterface secureStore, required SecureStorageInterface secureStore,
@ -358,12 +357,9 @@ class EpicCashWallet extends CoinServiceAPI
))!; ))!;
final result = await m.protect(() async { final result = await m.protect(() async {
return await compute( return await epiccash.LibEpiccash.cancelTransaction(
_cancelTransactionWrapper, wallet: wallet,
Tuple2( transactionId: txSlateId,
wallet,
txSlateId,
),
); );
}); });
Logging.instance.log( Logging.instance.log(
@ -1126,7 +1122,11 @@ class EpicCashWallet extends CoinServiceAPI
await _secureStore.write( await _secureStore.write(
key: '${_walletId}_epicboxConfig', value: epicboxConfig.toString()); key: '${_walletId}_epicboxConfig', value: epicboxConfig.toString());
await epiccash.LibEpiccash.recoverWallet(config: stringConfig, password: password, mnemonic: mnemonic, name: name); await epiccash.LibEpiccash.recoverWallet(
config: stringConfig,
password: password,
mnemonic: mnemonic,
name: name);
await Future.wait([ await Future.wait([
epicUpdateRestoreHeight(height), epicUpdateRestoreHeight(height),
@ -1262,8 +1262,8 @@ class EpicCashWallet extends CoinServiceAPI
} }
} }
Future<bool> putSendToAddresses( Future<bool> putSendToAddresses(({String slateId, String commitId}) slateData,
({String slateId, String commitId}) slateData, Map<String, String> txAddressInfo) async { Map<String, String> txAddressInfo) async {
try { try {
var slatesToCommits = await getSlatesToCommits(); var slatesToCommits = await getSlatesToCommits();
// final slate0 = jsonDecode(slateMessage); // final slate0 = jsonDecode(slateMessage);