Huge refactoring, because loki is now oxen
This commit is contained in:
parent
9525a8e2a2
commit
479e558cba
|
@ -76,11 +76,10 @@ android/app/.cxx/
|
|||
|
||||
|
||||
# External libs
|
||||
monero_android/
|
||||
android/app/.externalNativeBuild/
|
||||
cw_monero/ios/External/
|
||||
cw_monero/cw_monero/android/.externalNativeBuild/
|
||||
cw_monero/cw_monero/android/.cxx/
|
||||
oxen_coin/ios/External/
|
||||
oxen_coin/cw_monero/android/.externalNativeBuild/
|
||||
oxen_coin/cw_monero/android/.cxx/
|
||||
|
||||
# Generated dart files
|
||||
**/*.g.dart
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Konstantin Ullrich
|
||||
Copyright (c) 2020 Cake Technologies LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Loki Wallet
|
||||
# Oxen Wallet
|
||||
|
||||
The Loki Wallet is a Fork of the Cake Wallet.
|
||||
The Oxen Wallet is a Fork of the Cake Wallet.
|
||||
|
||||
## Build
|
||||
|
||||
|
@ -14,6 +14,8 @@ flutter pub get
|
|||
flutter pub run build_runner build
|
||||
```
|
||||
|
||||
3. Build the Loki Static Libs and paste them into cw_monero/ios/External/android
|
||||
3. Build the Oxen Static Libs and paste them into oxen_coin/ios/External/android
|
||||
|
||||
Copyright (c) 2020 Konstantin Ullrich.
|
||||
|
||||
Copyright (c) 2020 Cake Technologies LLC.
|
||||
|
|
|
@ -21,11 +21,11 @@ if (flutterVersionName == null) {
|
|||
flutterVersionName = '1.0'
|
||||
}
|
||||
|
||||
def keystoreProperties = new Properties()
|
||||
def keystorePropertiesFile = rootProject.file('key.properties')
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
//def keystoreProperties = new Properties()
|
||||
//def keystorePropertiesFile = rootProject.file('key.properties')
|
||||
//if (keystorePropertiesFile.exists()) {
|
||||
// keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
//}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
@ -43,8 +43,7 @@ android {
|
|||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "com.cakewallet.cake_wallet"
|
||||
applicationId "io.oxen.wallet"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
|
@ -61,16 +60,17 @@ android {
|
|||
|
||||
signingConfigs {
|
||||
release {
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile file(keystoreProperties['storeFile'])
|
||||
storePassword keystoreProperties['storePassword']
|
||||
// keyAlias keystoreProperties['keyAlias']
|
||||
// keyPassword keystoreProperties['keyPassword']
|
||||
// storeFile file(keystoreProperties['storeFile'])
|
||||
// storePassword keystoreProperties['storePassword']
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
signingConfig signingConfigs.debug
|
||||
// signingConfig signingConfigs.release
|
||||
|
||||
minifyEnabled true
|
||||
useProguard true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="network.loki.next">
|
||||
package="io.oxen.wallet">
|
||||
<!-- Flutter needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="network.loki.next">
|
||||
package="io.oxen.wallet">
|
||||
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
||||
calls FlutterMain.startInitialization(this); in its onCreate method.
|
||||
In most cases you can leave this as-is, but you if you want to provide
|
||||
|
@ -10,7 +10,7 @@
|
|||
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
|
||||
|
||||
<application
|
||||
android:label="Loki Wallet"
|
||||
android:label="Oxen Wallet"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:extractNativeLibs="true"
|
||||
tools:replace="android:extractNativeLibs">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package network.loki.next
|
||||
package io.oxen.wallet
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import io.flutter.embedding.android.FlutterFragmentActivity
|
|
@ -1,5 +1,5 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="network.loki.next">
|
||||
package="io.oxen.wallet">
|
||||
<!-- Flutter needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
1. Use of Cake Wallet
|
||||
The Cake Wallet app (hereinafter, referred to as the "App") allows the use of accessing the Monero Blockchain/network. You are not authorized, and nor should you rely on the App for legal advice, business advice, or advice of any kind. You act at your own risk in reliance on the contents of the App. Should you make a decision to act or not act you should contact a licensed attorney in the relevant jurisdiction in which you want or need help. In no way are the owners of, or contributors to, the App responsible for the actions, decisions, or other behavior taken or not taken by you in reliance upon the App.
|
||||
1. Use of the OXEN Wallet
|
||||
The OXEN Wallet app (hereinafter, referred to as the "App") allows the use of accessing the Oxen Blockchain/network. You are not authorized, and nor should you rely on the App for legal advice, business advice, or advice of any kind. You act at your own risk in reliance on the contents of the App. Should you make a decision to act or not act you should contact a licensed attorney in the relevant jurisdiction in which you want or need help. In no way are the owners of, or contributors to, the App responsible for the actions, decisions, or other behavior taken or not taken by you in reliance upon the App.
|
||||
2. Translations
|
||||
The App may contain translations of the English version of the content available on the App. These translations are provided only as a convenience. In the event of any conflict between the English language version and the translated version, the English language version shall take precedence. If you notice any inconsistency, please report them on GitHub.
|
||||
3. Risks related to the use of Cake Wallet.
|
||||
The App, the App’s owner Cake Technologies LLC and Cake Technologies owners, partners, employees, contributors, and any affiliates will not be responsible for any losses, damages or claims arising from events falling within the scope of the following five categories:
|
||||
1. (1) Mistakes made by the user of any Monero-related software or service, e.g., forgotten passwords, payments sent to wrong Monero addresses, and accidental deletion of wallets.
|
||||
2. (2) Software problems of the App and/or any Monero-related software or service, e.g., corrupted wallet file, incorrectly constructed transactions, unsafe cryptographic libraries, malware affecting the App and/or any Monero-related software or service.
|
||||
3. (3) Technical failures in the hardware of the user of any Monero-related software or service, e.g., data loss due to a faulty or damaged storage device.
|
||||
4. (4) Security problems experienced by the user of any Monero-related software or service, e.g., unauthorized access to users' wallets and/or accounts.
|
||||
5. (5) Actions or inactions of third parties and/or events experienced by third parties, e.g., bankruptcy of service providers, information security attacks on service providers, and fraud conducted by third parties.
|
||||
3. Risks related to the use of the OXEN Wallet.
|
||||
The App, the App’s owner the Oxen Project and Oxen Project owners, partners, employees, contributors, and any affiliates will not be responsible for any losses, damages or claims arising from events falling within the scope of the following five categories:
|
||||
1. (1) Mistakes made by the user of any Oxen-related software or service, e.g., forgotten passwords, payments sent to wrong Oxen addresses, and accidental deletion of wallets.
|
||||
2. (2) Software problems of the App and/or any Oxen-related software or service, e.g., corrupted wallet file, incorrectly constructed transactions, unsafe cryptographic libraries, malware affecting the App and/or any Oxen-related software or service.
|
||||
3. (3) Technical failures in the hardware of the user of any Oxen-related software or service, e.g., data loss due to a faulty or damaged storage device.
|
||||
4. (4) Security problems experienced by the user of any Oxen-related software or service, e.g., unauthorized access to users' wallets and/or accounts.
|
||||
5. (5) Actions or inaction of third parties and/or events experienced by third parties, e.g., bankruptcy of service providers, information security attacks on service providers, and fraud conducted by third parties.
|
||||
4. Investment risks
|
||||
The investment in Monero can lead to loss of money over short or even long periods. The investors in Monero should expect prices to have large range fluctuations.
|
||||
The investment in Oxen can lead to loss of money over short or even long periods. The investors in Oxen should expect prices to have large range fluctuations.
|
||||
5. Compliance with tax obligations
|
||||
The users of the App are solely responsible to determinate what, if any, taxes apply to their Monero transactions. The owners of, or contributors to, the App are NOT responsible for determining the taxes that apply to Monero transactions.
|
||||
6. The App does not store, send, or receive Moneros
|
||||
The App does not store, send or receive Monero. This is because Monero exists only by virtue of the ownership record maintained in the Monero network. Any transfer of title in Moneros occurs within a decentralized Monero network, and not on the App.
|
||||
The users of the App are solely responsible to determinate what, if any, taxes apply to their Oxen transactions. The owners of, or contributors to, the App are NOT responsible for determining the taxes that apply to Oxen transactions.
|
||||
6. The App does not store, send, or receive Oxen
|
||||
The App does not store, send or receive Oxen. This is because Oxen exists only by virtue of the ownership record maintained in the Oxen network. Any transfer of title in Oxen occurs within a decentralized Oxen network, and not on the App.
|
||||
7. No warranties
|
||||
The App is provided on an "as is" basis without any warranties of any kind regarding the App and/or any content, data, materials and/or services provided on the App.
|
||||
8. Limitation of liability
|
||||
|
@ -22,4 +22,4 @@ Unless otherwise required by law, in no event shall the owners of, or contributo
|
|||
9. Arbitration
|
||||
The user of the App agrees to arbitrate any dispute arising from or in connection with the App or this disclaimer, except for disputes related to copyrights, logos, trademarks, trade names, trade secrets or patents.
|
||||
10. Last amendment
|
||||
This disclaimer was amended for the last time on January 15, 2018.
|
||||
This disclaimer was amended for the last time on November 10, 2020.
|
|
@ -1,11 +0,0 @@
|
|||
.DS_Store
|
||||
.dart_tool/
|
||||
|
||||
.packages
|
||||
.pub/
|
||||
|
||||
build/
|
||||
|
||||
ios/External/
|
||||
android/.externalNativeBuild/
|
||||
android/.cxx/
|
|
@ -1,10 +0,0 @@
|
|||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 798e4272a2e43d7daab75f225a13442e384ee0cd
|
||||
channel: dev
|
||||
|
||||
project_type: plugin
|
|
@ -1,3 +0,0 @@
|
|||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Cake Technologies LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,5 +0,0 @@
|
|||
# cw_monero
|
||||
|
||||
This project is part of Cake Wallet app.
|
||||
|
||||
Copyright (c) 2020 Cake Technologies LLC.
|
|
@ -1,8 +0,0 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
|
@ -1,19 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
|
||||
add_library( cw_monero
|
||||
SHARED
|
||||
./jni/monero_jni.cpp)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/../ios/External/android)
|
||||
|
||||
add_library(wallet_api STATIC IMPORTED)
|
||||
set_target_properties(wallet_api PROPERTIES IMPORTED_LOCATION
|
||||
${EXTERNAL_LIBS_DIR}/monero/lib/${ANDROID_ABI}/libwallet_api.a)
|
||||
|
||||
include_directories( ${EXTERNAL_LIBS_DIR}/monero/include )
|
||||
|
||||
target_link_libraries( cw_monero PRIVATE wallet_api )
|
||||
target_include_directories( cw_monero PRIVATE wallet_api )
|
|
@ -1,61 +0,0 @@
|
|||
group 'com.cakewallet.monero'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.50'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
externalNativeBuild {
|
||||
// Encapsulates your CMake build configurations.
|
||||
cmake {
|
||||
//version "3.10.0+"
|
||||
cppFlags "-std=c++17"
|
||||
arguments '-DANDROID_STL=c++_shared'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
externalNativeBuild {
|
||||
// Encapsulates your CMake build configurations.
|
||||
cmake {
|
||||
// Provides a relative path to your CMake build script.
|
||||
version "3.10.0+"
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
org.gradle.jvmargs=-Xmx1536M
|
||||
android.enableR8=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
|
@ -1,5 +0,0 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
|
@ -1,136 +0,0 @@
|
|||
#include <string.h>
|
||||
#include <jni.h>
|
||||
#include "../../ios/Classes/monero_api.cpp"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static JavaVM *jvm = NULL;
|
||||
static jclass listener_class;
|
||||
|
||||
std::mutex _listenerMutex;
|
||||
|
||||
int attachJVM(JNIEnv **jenv) {
|
||||
int envStat = jvm->GetEnv((void **) jenv, JNI_VERSION_1_6);
|
||||
if (envStat == JNI_EDETACHED) {
|
||||
if (jvm->AttachCurrentThread(jenv, nullptr) != 0) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
} else if (envStat == JNI_EVERSION) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
return envStat;
|
||||
}
|
||||
|
||||
void detachJVM(JNIEnv *jenv, int envStat) {
|
||||
if (jenv->ExceptionCheck()) {
|
||||
jenv->ExceptionDescribe();
|
||||
}
|
||||
|
||||
if (envStat == JNI_EDETACHED) {
|
||||
jvm->DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
struct MoneroWalletListenerWrapper: Loki::WalletListener {
|
||||
jobject listener;
|
||||
|
||||
MoneroWalletListenerWrapper(JNIEnv *env, jobject aListener) {
|
||||
listener = env->NewGlobalRef(aListener);
|
||||
}
|
||||
|
||||
void moneySpent(const std::string &txId, uint64_t amount) {
|
||||
std::lock_guard<std::mutex> lock(_listenerMutex);
|
||||
JNIEnv *jenv;
|
||||
int envStat = attachJVM(&jenv);
|
||||
if (envStat == JNI_ERR) return;
|
||||
|
||||
jmethodID mid = jenv->GetMethodID(listener_class, "moneySpent", "()V");
|
||||
jenv->CallVoidMethod(listener, mid);
|
||||
detachJVM(jenv, envStat);
|
||||
}
|
||||
|
||||
void moneyReceived(const std::string &txId, uint64_t amount) {
|
||||
std::lock_guard<std::mutex> lock(_listenerMutex);
|
||||
JNIEnv *jenv;
|
||||
int envStat = attachJVM(&jenv);
|
||||
if (envStat == JNI_ERR) return;
|
||||
|
||||
jmethodID mid = jenv->GetMethodID(listener_class, "moneyReceived", "()V");
|
||||
jenv->CallVoidMethod(listener, mid);
|
||||
detachJVM(jenv, envStat);
|
||||
}
|
||||
|
||||
void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) {
|
||||
std::lock_guard<std::mutex> lock(_listenerMutex);
|
||||
JNIEnv *jenv;
|
||||
int envStat = attachJVM(&jenv);
|
||||
if (envStat == JNI_ERR) return;
|
||||
|
||||
jmethodID mid = jenv->GetMethodID(listener_class, "unconfirmedMoneyReceived", "()V");
|
||||
jenv->CallVoidMethod(listener, mid);
|
||||
detachJVM(jenv, envStat);
|
||||
}
|
||||
|
||||
void newBlock(uint64_t height) {
|
||||
std::lock_guard<std::mutex> lock(_listenerMutex);
|
||||
JNIEnv *jenv;
|
||||
int envStat = attachJVM(&jenv);
|
||||
if (envStat == JNI_ERR) return;
|
||||
|
||||
jmethodID mid = jenv->GetMethodID(listener_class, "newBlock", "(J)V");
|
||||
jlong height_as_long = static_cast<jlong>(height);
|
||||
jenv->CallVoidMethod(listener, mid, height_as_long);
|
||||
detachJVM(jenv, envStat);
|
||||
}
|
||||
|
||||
void updated() {
|
||||
std::lock_guard<std::mutex> lock(_listenerMutex);
|
||||
JNIEnv *jenv;
|
||||
int envStat = attachJVM(&jenv);
|
||||
if (envStat == JNI_ERR) return;
|
||||
|
||||
jmethodID mid = jenv->GetMethodID(listener_class, "updated", "()V");
|
||||
jenv->CallVoidMethod(listener, mid);
|
||||
detachJVM(jenv, envStat);
|
||||
}
|
||||
|
||||
void refreshed() {
|
||||
std::lock_guard<std::mutex> lock(_listenerMutex);
|
||||
JNIEnv *jenv;
|
||||
int envStat = attachJVM(&jenv);
|
||||
if (envStat == JNI_ERR) return;
|
||||
|
||||
jmethodID mid = jenv->GetMethodID(listener_class, "refreshed", "()V");
|
||||
jenv->CallVoidMethod(listener, mid);
|
||||
detachJVM(jenv, envStat);
|
||||
}
|
||||
};
|
||||
|
||||
static MoneroWalletListenerWrapper *listenerWrapper = NULL;
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *_jvm, void *reserved) {
|
||||
jvm = _jvm;
|
||||
JNIEnv *jenv;
|
||||
|
||||
if (jvm->GetEnv(reinterpret_cast<void **>(&jenv), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
listener_class = static_cast<jclass>(jenv->NewGlobalRef(jenv->FindClass("com/cakewallet/monero/MoneroWalletSyncStatusListener")));
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_cakewallet_monero_MoneroApi_setupListenerJNI(JNIEnv *env, jobject inst, jobject listener) {
|
||||
listenerWrapper = new MoneroWalletListenerWrapper(env, listener);
|
||||
get_current_wallet()->setListener(listenerWrapper);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1 +0,0 @@
|
|||
rootProject.name = 'cw_monero'
|
|
@ -1,4 +0,0 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cakewallet.monero">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
|
@ -1,97 +0,0 @@
|
|||
package com.cakewallet.monero
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Looper
|
||||
import android.os.Handler
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.plugin.common.*
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||
import io.flutter.plugin.common.MethodChannel.Result
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar
|
||||
|
||||
import com.cakewallet.monero.FlutterMethodHandler
|
||||
|
||||
|
||||
public class CwMoneroPlugin : FlutterPlugin, MethodCallHandler {
|
||||
private lateinit var channel : MethodChannel
|
||||
|
||||
companion object {
|
||||
var syncListenerChannel: BasicMessageChannel<ByteBuffer>? = null
|
||||
val moneroApi = MoneroApi()
|
||||
val main = Handler(Looper.getMainLooper());
|
||||
val handlers = listOf(FlutterMethodHandler("setupSyncStatusListener", { call: MethodCall, result: Result ->
|
||||
moneroApi.setupListener(MoneroWalletSyncStatusListener({ block: Long ->
|
||||
main.post() {
|
||||
val buffer = ByteBuffer.allocateDirect(9)
|
||||
buffer.put(0.toByte())
|
||||
buffer.putLong(block)
|
||||
syncListenerChannel?.send(buffer)
|
||||
}
|
||||
}, {
|
||||
main.post() {
|
||||
val buffer = ByteBuffer.allocateDirect(1)
|
||||
buffer.put(1.toByte())
|
||||
syncListenerChannel?.send(buffer)
|
||||
}
|
||||
}, {
|
||||
main.post() {
|
||||
val buffer = ByteBuffer.allocateDirect(1)
|
||||
buffer.put(2.toByte())
|
||||
syncListenerChannel?.send(buffer)
|
||||
}
|
||||
}, {
|
||||
main.post() {
|
||||
val buffer = ByteBuffer.allocateDirect(1)
|
||||
buffer.put(3.toByte())
|
||||
syncListenerChannel?.send(buffer)
|
||||
}
|
||||
}, {
|
||||
main.post() {
|
||||
val buffer = ByteBuffer.allocateDirect(1)
|
||||
buffer.put(4.toByte())
|
||||
syncListenerChannel?.send(buffer)
|
||||
}
|
||||
}, {
|
||||
main.post() {
|
||||
val buffer = ByteBuffer.allocateDirect(1)
|
||||
buffer.put(5.toByte())
|
||||
syncListenerChannel?.send(buffer)
|
||||
}
|
||||
}))
|
||||
|
||||
result.success(true)
|
||||
}))
|
||||
|
||||
@JvmStatic
|
||||
fun registerWith(registrar: Registrar) {
|
||||
val channel = MethodChannel(registrar.messenger(), "cw_monero")
|
||||
syncListenerChannel = syncListenerChannel ?: BasicMessageChannel<ByteBuffer>(registrar.messenger(), "cw_monero.sync_listener", BinaryCodec.INSTANCE)
|
||||
channel.setMethodCallHandler(CwMoneroPlugin())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel = MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "cw_monero")
|
||||
syncListenerChannel = syncListenerChannel ?: BasicMessageChannel<ByteBuffer>(flutterPluginBinding.getBinaryMessenger(), "cw_monero.sync_listener", BinaryCodec.INSTANCE)
|
||||
channel.setMethodCallHandler(this);
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel.setMethodCallHandler(null)
|
||||
}
|
||||
|
||||
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
|
||||
moneroApi.load()
|
||||
|
||||
handlers.forEach {
|
||||
it.handle(call, result)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.cakewallet.monero
|
||||
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel.Result
|
||||
|
||||
class FlutterMethodHandler(val name: String, val handler: (MethodCall, Result) -> Unit) {
|
||||
fun handle(call: MethodCall, result: Result) {
|
||||
if (name == call.method) {
|
||||
handler(call, result)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package com.cakewallet.monero
|
||||
|
||||
import com.cakewallet.monero.MoneroWalletSyncStatusListener
|
||||
|
||||
class MoneroApi {
|
||||
private var isLoaded = false
|
||||
|
||||
fun load() : Unit {
|
||||
if (isLoaded) {
|
||||
return
|
||||
}
|
||||
|
||||
System.loadLibrary("cw_monero")
|
||||
isLoaded = true
|
||||
}
|
||||
|
||||
fun setupListener(listener: MoneroWalletSyncStatusListener) {
|
||||
setupListenerJNI(listener)
|
||||
}
|
||||
|
||||
external fun setupListenerJNI(listener: MoneroWalletSyncStatusListener)
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.cakewallet.monero
|
||||
|
||||
class MoneroWalletSyncStatusListener(val onNewBlock: (Long) -> Unit,
|
||||
val onRefreshed: () -> Unit,
|
||||
val onUpdated: () -> Unit,
|
||||
val onMoneySpent: () -> Unit,
|
||||
val onMoneyReceived: () -> Unit,
|
||||
val onUnconfirmedMoneyReceived: () -> Unit) {
|
||||
fun newBlock(block: Long) {
|
||||
onNewBlock(block)
|
||||
}
|
||||
|
||||
fun refreshed() {
|
||||
onRefreshed()
|
||||
}
|
||||
|
||||
fun updated() {
|
||||
onUpdated()
|
||||
}
|
||||
|
||||
fun moneyReceived() {
|
||||
onMoneyReceived()
|
||||
}
|
||||
|
||||
fun moneySpent() {
|
||||
onMoneySpent()
|
||||
}
|
||||
|
||||
fun unconfirmedMoneyReceived() {
|
||||
onUnconfirmedMoneyReceived()
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
.idea/
|
||||
.vagrant/
|
||||
.sconsign.dblite
|
||||
.svn/
|
||||
|
||||
.DS_Store
|
||||
*.swp
|
||||
profile
|
||||
|
||||
DerivedData/
|
||||
build/
|
||||
GeneratedPluginRegistrant.h
|
||||
GeneratedPluginRegistrant.m
|
||||
|
||||
.generated/
|
||||
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspectivev3
|
||||
|
||||
!default.pbxuser
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.perspectivev3
|
||||
|
||||
xcuserdata
|
||||
|
||||
*.moved-aside
|
||||
|
||||
*.pyc
|
||||
*sync/
|
||||
Icon?
|
||||
.tags*
|
||||
|
||||
/Flutter/Generated.xcconfig
|
||||
/Flutter/flutter_export_environment.sh
|
|
@ -1,4 +0,0 @@
|
|||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface CwMoneroPlugin : NSObject<FlutterPlugin>
|
||||
@end
|
|
@ -1,9 +0,0 @@
|
|||
#import "CwMoneroPlugin.h"
|
||||
#import <cw_monero/cw_monero-Swift.h>
|
||||
//#include "../External/android/monero/include/wallet2_api.h"
|
||||
|
||||
@implementation CwMoneroPlugin
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||
[SwiftCwMoneroPlugin registerWithRegistrar:registrar];
|
||||
}
|
||||
@end
|
|
@ -1,12 +0,0 @@
|
|||
import Foundation
|
||||
|
||||
struct FlutterMethodHandler {
|
||||
let name: String
|
||||
let handler: (FlutterMethodCall, @escaping FlutterResult) -> Void
|
||||
|
||||
func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
if name == call.method {
|
||||
handler(call, result)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "MoneroWalletListener.h"
|
||||
#include "monero_api.cpp"
|
||||
|
||||
struct MonerWalletListenerWapper: Monero::WalletListener {
|
||||
MoneroWalletListener *listener;
|
||||
|
||||
void moneySpent(const std::string &txId, uint64_t amount) {
|
||||
[listener moneySpent: [NSString stringWithUTF8String: txId.c_str()] amount: amount];
|
||||
}
|
||||
|
||||
void moneyReceived(const std::string &txId, uint64_t amount) {
|
||||
[listener moneyReceived: [NSString stringWithUTF8String: txId.c_str()] amount: amount];
|
||||
}
|
||||
|
||||
void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) {
|
||||
[listener unconfirmedMoneyReceived: [NSString stringWithUTF8String: txId.c_str()] amount: amount];
|
||||
}
|
||||
|
||||
void newBlock(uint64_t height) {
|
||||
[listener newBlock: height];
|
||||
}
|
||||
|
||||
void updated() {
|
||||
[listener updated];
|
||||
}
|
||||
|
||||
void refreshed() {
|
||||
[listener refreshed];
|
||||
}
|
||||
};
|
|
@ -1,18 +0,0 @@
|
|||
@interface MoneroWalletListener : NSObject
|
||||
|
||||
@property(nonatomic) void (*onNewBlock)(uint64_t);
|
||||
@property(nonatomic) void (*onUpdated)(void *);
|
||||
@property(nonatomic) void (*onRefreshed)(void *);
|
||||
@property(nonatomic) void (*onMoneyReceived) (NSString *, uint64_t);
|
||||
@property(nonatomic) void (*onMoneySpent) (NSString *, uint64_t);
|
||||
@property(nonatomic) void (*onUnconfirmedMoneyReceived) (NSString *, uint64_t);
|
||||
|
||||
- (void)setup;
|
||||
- (void)newBlock:(uint64_t) block;
|
||||
- (void)updated;
|
||||
- (void)refreshed;
|
||||
- (void)moneyReceived:(NSString *) txId amount:(uint64_t) amount;
|
||||
- (void)moneySpent:(NSString *) txId amount:(uint64_t) amount;
|
||||
- (void)unconfirmedMoneyReceived:(NSString *) txId amount:(uint64_t) amount;
|
||||
|
||||
@end
|
|
@ -1,42 +0,0 @@
|
|||
#import "MoneroWalletListener.h"
|
||||
#import "MonerWalletListenerWapper.mm"
|
||||
|
||||
@implementation MoneroWalletListener
|
||||
- (void)setup
|
||||
{
|
||||
MonerWalletListenerWapper *listener = new MonerWalletListenerWapper();
|
||||
listener->listener = self;
|
||||
get_current_wallet()->setListener(listener);
|
||||
}
|
||||
|
||||
- (void)newBlock:(uint64_t) block
|
||||
{
|
||||
self.onNewBlock(block);
|
||||
}
|
||||
|
||||
- (void)updated
|
||||
{
|
||||
self.onUpdated(nullptr);
|
||||
}
|
||||
|
||||
- (void)refreshed
|
||||
{
|
||||
self.onRefreshed(nullptr);
|
||||
}
|
||||
|
||||
- (void)moneyReceived:(NSString *) txId amount:(uint64_t) amount
|
||||
{
|
||||
self.onMoneyReceived(txId, amount);
|
||||
}
|
||||
|
||||
- (void)moneySpent:(NSString *) txId amount:(uint64_t) amount
|
||||
{
|
||||
self.onMoneySpent(txId, amount);
|
||||
}
|
||||
|
||||
- (void)unconfirmedMoneyReceived:(NSString *) txId amount:(uint64_t) amount
|
||||
{
|
||||
self.onUnconfirmedMoneyReceived(txId, amount);
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,58 +0,0 @@
|
|||
import Flutter
|
||||
import UIKit
|
||||
|
||||
public class SwiftCwMoneroPlugin: NSObject, FlutterPlugin {
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(name: "cw_monero", binaryMessenger: registrar.messenger())
|
||||
syncListenerChannel = FlutterBasicMessageChannel(name: "cw_monero.sync_listener", binaryMessenger: registrar.messenger(), codec: FlutterBinaryCodec())
|
||||
let instance = SwiftCwMoneroPlugin()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
}
|
||||
|
||||
private static var syncListenerChannel: FlutterBasicMessageChannel?
|
||||
private static var moneroWalletListener: MoneroWalletListener?
|
||||
private let handlers = [FlutterMethodHandler(name: "setupSyncStatusListener", handler: { (call, result) in
|
||||
let listener = MoneroWalletListener()
|
||||
listener.onNewBlock = { block in
|
||||
var _block = block.bigEndian
|
||||
let blockAsData = Data(bytes: &_block, count: MemoryLayout.size(ofValue: _block))
|
||||
var message = Data()
|
||||
message.append(0)
|
||||
message.append(blockAsData)
|
||||
syncListenerChannel?.sendMessage(message)
|
||||
}
|
||||
listener.onRefreshed = { _ in
|
||||
var message = Data()
|
||||
message.append(1)
|
||||
syncListenerChannel?.sendMessage(message)
|
||||
}
|
||||
listener.onUpdated = { _ in
|
||||
var message = Data()
|
||||
message.append(2)
|
||||
syncListenerChannel?.sendMessage(message)
|
||||
}
|
||||
listener.onMoneyReceived = { _, _ in
|
||||
var message = Data()
|
||||
message.append(3)
|
||||
syncListenerChannel?.sendMessage(message)
|
||||
}
|
||||
listener.onMoneySpent = { _, _ in
|
||||
var message = Data()
|
||||
message.append(4)
|
||||
syncListenerChannel?.sendMessage(message)
|
||||
}
|
||||
listener.onUnconfirmedMoneyReceived = { _, _ in
|
||||
var message = Data()
|
||||
message.append(5)
|
||||
syncListenerChannel?.sendMessage(message)
|
||||
}
|
||||
|
||||
listener.setup()
|
||||
moneroWalletListener = listener
|
||||
result(true)
|
||||
})]
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
handlers.forEach { $0.handle(call, result: result) }
|
||||
}
|
||||
}
|
|
@ -1,546 +0,0 @@
|
|||
#include <stdint.h>
|
||||
#include "cstdlib"
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include "thread"
|
||||
#include "../External/android/monero/include/wallet2_api.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace Loki = Wallet;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct Utf8Box
|
||||
{
|
||||
char *value;
|
||||
|
||||
Utf8Box(char *_value)
|
||||
{
|
||||
value = _value;
|
||||
}
|
||||
};
|
||||
|
||||
struct SubaddressRow
|
||||
{
|
||||
uint64_t id;
|
||||
char *address;
|
||||
char *label;
|
||||
|
||||
SubaddressRow(std::size_t _id, char *_address, char *_label)
|
||||
{
|
||||
id = static_cast<uint64_t>(_id);
|
||||
address = _address;
|
||||
label = _label;
|
||||
}
|
||||
};
|
||||
|
||||
struct AccountRow
|
||||
{
|
||||
uint64_t id;
|
||||
char *label;
|
||||
|
||||
AccountRow(std::size_t _id, char *_label)
|
||||
{
|
||||
id = static_cast<uint64_t>(_id);
|
||||
label = _label;
|
||||
}
|
||||
};
|
||||
|
||||
struct TransactionInfoRow
|
||||
{
|
||||
uint64_t amount;
|
||||
uint64_t fee;
|
||||
uint64_t blockHeight;
|
||||
uint64_t confirmations;
|
||||
uint32_t subaddrAccount;
|
||||
int8_t direction;
|
||||
int8_t isPending;
|
||||
|
||||
char *hash;
|
||||
char *paymentId;
|
||||
|
||||
int64_t datetime;
|
||||
|
||||
TransactionInfoRow(Loki::TransactionInfo *transaction)
|
||||
{
|
||||
amount = transaction->amount();
|
||||
fee = transaction->fee();
|
||||
blockHeight = transaction->blockHeight();
|
||||
subaddrAccount = transaction->subaddrAccount();
|
||||
confirmations = transaction->confirmations();
|
||||
datetime = static_cast<int64_t>(transaction->timestamp());
|
||||
direction = transaction->direction();
|
||||
isPending = static_cast<int8_t>(transaction->isPending());
|
||||
std::string *hash_str = new std::string(transaction->hash());
|
||||
hash = strdup(hash_str->c_str());
|
||||
paymentId = strdup(transaction->paymentId().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
struct PendingTransactionRaw
|
||||
{
|
||||
uint64_t amount;
|
||||
uint64_t fee;
|
||||
char *hash;
|
||||
Loki::PendingTransaction *transaction;
|
||||
|
||||
PendingTransactionRaw(Loki::PendingTransaction *_transaction)
|
||||
{
|
||||
transaction = _transaction;
|
||||
amount = _transaction->amount();
|
||||
fee = _transaction->fee();
|
||||
hash = strdup(_transaction->txid()[0].c_str());
|
||||
}
|
||||
};
|
||||
|
||||
Loki::Wallet *m_wallet;
|
||||
Loki::TransactionHistory *m_transaction_history;
|
||||
Loki::Subaddress *m_subaddress;
|
||||
Loki::SubaddressAccount *m_account;
|
||||
uint64_t m_last_known_wallet_height;
|
||||
std::mutex m_store_mtx;
|
||||
|
||||
void change_current_wallet(Loki::Wallet *wallet)
|
||||
{
|
||||
m_wallet = wallet;
|
||||
m_transaction_history = nullptr;
|
||||
m_account = nullptr;
|
||||
m_subaddress = nullptr;
|
||||
|
||||
|
||||
if (wallet != nullptr)
|
||||
{
|
||||
m_transaction_history = wallet->history();
|
||||
}
|
||||
|
||||
if (wallet != nullptr)
|
||||
{
|
||||
m_account = wallet->subaddressAccount();
|
||||
}
|
||||
|
||||
if (wallet != nullptr)
|
||||
{
|
||||
m_subaddress = wallet->subaddress();
|
||||
}
|
||||
}
|
||||
|
||||
Loki::Wallet *get_current_wallet()
|
||||
{
|
||||
return m_wallet;
|
||||
}
|
||||
|
||||
bool create_wallet(char *path, char *password, char *language, int32_t networkType, char *error)
|
||||
{
|
||||
Loki::NetworkType _networkType = static_cast<Loki::NetworkType>(networkType);
|
||||
Loki::WalletManagerBase *walletManager = Loki::WalletManagerFactory::getWalletManager();
|
||||
Loki::Wallet *wallet = walletManager->createWallet(path, password, language, _networkType);
|
||||
|
||||
// int status;
|
||||
// std::string errorString;
|
||||
|
||||
auto stat = wallet->status();
|
||||
|
||||
auto& [status, errorString] = stat;
|
||||
|
||||
if (status != Loki::Wallet::Status_Ok)
|
||||
{
|
||||
error = strdup(errorString.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
walletManager->closeWallet(wallet);
|
||||
wallet = walletManager->openWallet(std::string(path), std::string(password), _networkType);
|
||||
|
||||
stat = wallet->status();
|
||||
|
||||
if (status != Loki::Wallet::Status_Ok)
|
||||
{
|
||||
error = strdup(errorString.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
change_current_wallet(wallet);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool restore_wallet_from_seed(char *path, char *password, char *seed, int32_t networkType, uint64_t restoreHeight, char *error)
|
||||
{
|
||||
Loki::NetworkType _networkType = static_cast<Loki::NetworkType>(networkType);
|
||||
Loki::Wallet *wallet = Loki::WalletManagerFactory::getWalletManager()->recoveryWallet(
|
||||
std::string(path),
|
||||
std::string(password),
|
||||
std::string(seed),
|
||||
_networkType,
|
||||
(uint64_t)restoreHeight);
|
||||
|
||||
// int status;
|
||||
// std::string errorString;
|
||||
|
||||
auto [status, errorString] = wallet->status();
|
||||
|
||||
if (status != Loki::Wallet::Status_Ok)
|
||||
{
|
||||
error = strdup(errorString.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
change_current_wallet(wallet);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool restore_wallet_from_keys(char *path, char *password, char *language, char *address, char *viewKey, char *spendKey, int32_t networkType, uint64_t restoreHeight, char *error)
|
||||
{
|
||||
Loki::NetworkType _networkType = static_cast<Loki::NetworkType>(networkType);
|
||||
Loki::Wallet *wallet = Loki::WalletManagerFactory::getWalletManager()->createWalletFromKeys(
|
||||
std::string(path),
|
||||
std::string(password),
|
||||
std::string(language),
|
||||
_networkType,
|
||||
(uint64_t)restoreHeight,
|
||||
std::string(address),
|
||||
std::string(viewKey),
|
||||
std::string(spendKey));
|
||||
|
||||
// int status;
|
||||
// std::string errorString;
|
||||
|
||||
auto [status, errorString] = wallet->status();
|
||||
|
||||
if (status != Loki::Wallet::Status_Ok)
|
||||
{
|
||||
error = strdup(errorString.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
change_current_wallet(wallet);
|
||||
return true;
|
||||
}
|
||||
|
||||
void load_wallet(char *path, char *password, int32_t nettype)
|
||||
{
|
||||
Loki::NetworkType networkType = static_cast<Loki::NetworkType>(nettype);
|
||||
Loki::WalletManagerBase *walletManager = Loki::WalletManagerFactory::getWalletManager();
|
||||
Loki::Wallet *wallet = walletManager->openWallet(std::string(path), std::string(password), networkType);
|
||||
change_current_wallet(wallet);
|
||||
}
|
||||
|
||||
bool is_wallet_exist(char *path)
|
||||
{
|
||||
return Loki::WalletManagerFactory::getWalletManager()->walletExists(std::string(path));
|
||||
}
|
||||
|
||||
void close_current_wallet()
|
||||
{
|
||||
Loki::WalletManagerFactory::getWalletManager()->closeWallet(get_current_wallet());
|
||||
change_current_wallet(nullptr);
|
||||
}
|
||||
|
||||
char *get_filename()
|
||||
{
|
||||
return strdup(get_current_wallet()->filename().c_str());
|
||||
}
|
||||
|
||||
char *secret_view_key()
|
||||
{
|
||||
return strdup(get_current_wallet()->secretViewKey().c_str());
|
||||
}
|
||||
|
||||
char *public_view_key()
|
||||
{
|
||||
return strdup(get_current_wallet()->publicViewKey().c_str());
|
||||
}
|
||||
|
||||
char *secret_spend_key()
|
||||
{
|
||||
return strdup(get_current_wallet()->secretSpendKey().c_str());
|
||||
}
|
||||
|
||||
char *public_spend_key()
|
||||
{
|
||||
return strdup(get_current_wallet()->publicSpendKey().c_str());
|
||||
}
|
||||
|
||||
char *get_address(uint32_t account_index, uint32_t address_index)
|
||||
{
|
||||
return strdup(get_current_wallet()->address(account_index, address_index).c_str());
|
||||
}
|
||||
|
||||
|
||||
const char *seed()
|
||||
{
|
||||
return strdup(get_current_wallet()->seed().c_str());
|
||||
}
|
||||
|
||||
uint64_t get_full_balance(uint32_t account_index)
|
||||
{
|
||||
return get_current_wallet()->balance(account_index);
|
||||
}
|
||||
|
||||
uint64_t get_unlocked_balance(uint32_t account_index)
|
||||
{
|
||||
return get_current_wallet()->unlockedBalance(account_index);
|
||||
}
|
||||
|
||||
uint64_t get_current_height()
|
||||
{
|
||||
return get_current_wallet()->blockChainHeight();
|
||||
}
|
||||
|
||||
uint64_t get_node_height()
|
||||
{
|
||||
return get_current_wallet()->daemonBlockChainHeight();
|
||||
}
|
||||
|
||||
bool connect_to_node(char *error)
|
||||
{
|
||||
bool is_connected = get_current_wallet()->connectToDaemon();
|
||||
|
||||
if (!is_connected)
|
||||
{
|
||||
error = strdup(get_current_wallet()->status().second.c_str());
|
||||
}
|
||||
|
||||
return is_connected;
|
||||
}
|
||||
|
||||
bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *error)
|
||||
{
|
||||
nice(19);
|
||||
Loki::Wallet *wallet = get_current_wallet();
|
||||
|
||||
std::string _login = "";
|
||||
std::string _password = "";
|
||||
|
||||
if (login != nullptr)
|
||||
{
|
||||
_login = std::string(login);
|
||||
}
|
||||
|
||||
if (password != nullptr)
|
||||
{
|
||||
_password = std::string(password);
|
||||
}
|
||||
|
||||
bool inited = wallet->init(std::string(address), 0, _login, _password, use_ssl, is_light_wallet);
|
||||
|
||||
if (!inited)
|
||||
{
|
||||
error = strdup(wallet->status().second.c_str());
|
||||
} else if (!wallet->connectToDaemon()) {
|
||||
inited = false;
|
||||
error = strdup(wallet->status().second.c_str());
|
||||
}
|
||||
|
||||
return inited;
|
||||
}
|
||||
|
||||
bool is_connected()
|
||||
{
|
||||
return get_current_wallet()->connected();
|
||||
}
|
||||
|
||||
void start_refresh()
|
||||
{
|
||||
get_current_wallet()->refreshAsync();
|
||||
get_current_wallet()->startRefresh();
|
||||
}
|
||||
|
||||
void set_refresh_from_block_height(uint64_t height)
|
||||
{
|
||||
get_current_wallet()->setRefreshFromBlockHeight(height);
|
||||
}
|
||||
|
||||
void set_recovering_from_seed(bool is_recovery)
|
||||
{
|
||||
get_current_wallet()->setRecoveringFromSeed(is_recovery);
|
||||
}
|
||||
|
||||
void store()
|
||||
{
|
||||
m_store_mtx.lock();
|
||||
get_current_wallet()->store("");
|
||||
m_store_mtx.unlock();
|
||||
}
|
||||
|
||||
bool transaction_create(char *address, char *payment_id, char *amount,
|
||||
uint8_t priority, uint32_t subaddr_account, Utf8Box &error, PendingTransactionRaw &pendingTransaction)
|
||||
{
|
||||
nice(19);
|
||||
|
||||
//auto priority = static_cast<Loki::PendingTransaction::Priority>(priority_raw);
|
||||
std::string _payment_id;
|
||||
Loki::PendingTransaction *transaction;
|
||||
|
||||
if (payment_id != nullptr)
|
||||
{
|
||||
_payment_id = std::string(payment_id);
|
||||
}
|
||||
|
||||
if (amount != nullptr)
|
||||
{
|
||||
uint64_t _amount = Loki::Wallet::amountFromString(std::string(amount));
|
||||
transaction = m_wallet->createTransaction(std::string(address), _amount, priority, subaddr_account);
|
||||
}
|
||||
else
|
||||
{
|
||||
transaction = m_wallet->createTransaction(std::string(address), std::optional<uint64_t>(), priority, subaddr_account);
|
||||
}
|
||||
|
||||
int status = transaction->status().first;
|
||||
|
||||
if (status == Loki::PendingTransaction::Status::Status_Error || status == Loki::PendingTransaction::Status::Status_Critical)
|
||||
{
|
||||
error = Utf8Box(strdup(transaction->status().second.c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
pendingTransaction = PendingTransactionRaw(transaction);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool transaction_commit(PendingTransactionRaw *transaction, Utf8Box &error)
|
||||
{
|
||||
bool committed = transaction->transaction->commit();
|
||||
|
||||
if (!committed)
|
||||
{
|
||||
error = Utf8Box(strdup(transaction->transaction->status().second.c_str()));
|
||||
}
|
||||
|
||||
return committed;
|
||||
}
|
||||
|
||||
int64_t *subaddrress_get_all()
|
||||
{
|
||||
std::vector<Loki::SubaddressRow *> _subaddresses = m_subaddress->getAll();
|
||||
size_t size = _subaddresses.size();
|
||||
int64_t *subaddresses = (int64_t *)malloc(size * sizeof(int64_t));
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
Loki::SubaddressRow *row = _subaddresses[i];
|
||||
SubaddressRow *_row = new SubaddressRow(row->getRowId(), strdup(row->getAddress().c_str()), strdup(row->getLabel().c_str()));
|
||||
subaddresses[i] = reinterpret_cast<int64_t>(_row);
|
||||
}
|
||||
|
||||
return subaddresses;
|
||||
}
|
||||
|
||||
int32_t subaddrress_size()
|
||||
{
|
||||
std::vector<Loki::SubaddressRow *> _subaddresses = m_subaddress->getAll();
|
||||
return _subaddresses.size();
|
||||
}
|
||||
|
||||
void subaddress_add_row(uint32_t accountIndex, char *label)
|
||||
{
|
||||
m_subaddress->addRow(accountIndex, std::string(label));
|
||||
}
|
||||
|
||||
void subaddress_set_label(uint32_t accountIndex, uint32_t addressIndex, char *label)
|
||||
{
|
||||
m_subaddress->setLabel(accountIndex, addressIndex, std::string(label));
|
||||
}
|
||||
|
||||
void subaddress_refresh(uint32_t accountIndex)
|
||||
{
|
||||
m_subaddress->refresh(accountIndex);
|
||||
}
|
||||
|
||||
int32_t account_size()
|
||||
{
|
||||
std::vector<Loki::SubaddressAccountRow *> _accocunts = m_account->getAll();
|
||||
return _accocunts.size();
|
||||
}
|
||||
|
||||
int64_t *account_get_all()
|
||||
{
|
||||
std::vector<Loki::SubaddressAccountRow *> _accocunts = m_account->getAll();
|
||||
size_t size = _accocunts.size();
|
||||
int64_t *accocunts = (int64_t *)malloc(size * sizeof(int64_t));
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
Loki::SubaddressAccountRow *row = _accocunts[i];
|
||||
AccountRow *_row = new AccountRow(row->getRowId(), strdup(row->getLabel().c_str()));
|
||||
accocunts[i] = reinterpret_cast<int64_t>(_row);
|
||||
}
|
||||
|
||||
return accocunts;
|
||||
}
|
||||
|
||||
void account_add_row(char *label)
|
||||
{
|
||||
m_account->addRow(std::string(label));
|
||||
}
|
||||
|
||||
void account_set_label_row(uint32_t account_index, char *label)
|
||||
{
|
||||
m_account->setLabel(account_index, label);
|
||||
}
|
||||
|
||||
void account_refresh()
|
||||
{
|
||||
m_account->refresh();
|
||||
}
|
||||
|
||||
int64_t *transactions_get_all()
|
||||
{
|
||||
std::vector<Loki::TransactionInfo *> transactions = m_transaction_history->getAll();
|
||||
size_t size = transactions.size();
|
||||
int64_t *transactionAddresses = (int64_t *)malloc(size * sizeof(int64_t));
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
Loki::TransactionInfo *row = transactions[i];
|
||||
TransactionInfoRow *tx = new TransactionInfoRow(row);
|
||||
transactionAddresses[i] = reinterpret_cast<int64_t>(tx);
|
||||
}
|
||||
|
||||
return transactionAddresses;
|
||||
}
|
||||
|
||||
void transactions_refresh()
|
||||
{
|
||||
m_transaction_history->refresh();
|
||||
}
|
||||
|
||||
int64_t transactions_count()
|
||||
{
|
||||
return m_transaction_history->count();
|
||||
}
|
||||
|
||||
int LedgerExchange(
|
||||
unsigned char *command,
|
||||
unsigned int cmd_len,
|
||||
unsigned char *response,
|
||||
unsigned int max_resp_len)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int LedgerFind(char *buffer, size_t len)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void on_startup()
|
||||
{
|
||||
Loki::Utils::onStartup();
|
||||
}
|
||||
|
||||
void rescan_blockchain()
|
||||
{
|
||||
m_wallet->rescanBlockchainAsync();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,2 +0,0 @@
|
|||
@interface MoneroWalletListener
|
||||
@end
|
|
@ -1,4 +0,0 @@
|
|||
#include "../External/android/monero/include/wallet2_api.h"
|
||||
|
||||
@implementation MoneroWalletListener
|
||||
@end
|
|
@ -1,57 +0,0 @@
|
|||
#
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
|
||||
# Run `pod lib lint cw_monero.podspec' to validate before publishing.
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'cw_monero'
|
||||
s.version = '0.0.2'
|
||||
s.summary = 'A new flutter plugin project.'
|
||||
s.description = <<-DESC
|
||||
A new flutter plugin project.
|
||||
DESC
|
||||
s.homepage = 'http://example.com'
|
||||
s.license = { :file => '../LICENSE' }
|
||||
s.author = { 'Your Company' => 'email@example.com' }
|
||||
s.source = { :path => '.' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.exclude_files = ['Classes/monero_api.cpp', 'Classes/MonerWalletListenerWapper.mm']
|
||||
s.public_header_files = 'Classes/**/*.h, Classes/*.h, External/ios/libs/monero/include/src/**/*.h, External/ios/libs/monero/include/contrib/**/*.h, External/ios/libs/monero/include/External/ios/**/*.h'
|
||||
s.dependency 'Flutter'
|
||||
s.platform = :ios, '9.0'
|
||||
s.swift_version = '4.0'
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'arm64' }
|
||||
s.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/Classes/*.h" }
|
||||
|
||||
s.subspec 'OpenSSL' do |openssl|
|
||||
openssl.preserve_paths = 'External/ios/libs/OpenSSL/include/openssl/*.h', 'External/ios/libs/OpenSSL/include/LICENSE'
|
||||
openssl.vendored_libraries = 'External/ios/libs/OpenSSL/lib/libcrypto.a', 'External/ios/libs/OpenSSL/lib/libssl.a'
|
||||
openssl.libraries = 'ssl', 'crypto'
|
||||
openssl.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/libs/OpenSSL/include/**" }
|
||||
end
|
||||
|
||||
s.subspec 'Monero' do |monero|
|
||||
monero.preserve_paths = 'External/ios/libs/monero/include/src/**/*.h', 'External/ios/libs/monero/include/External/ios/**/*.h', 'External/ios/libs/monero/include/contrib/**/*.h'
|
||||
monero.vendored_libraries = 'External/ios/libs/monero/libs/lib-ios/*.a'
|
||||
monero.libraries = 'easylogging', 'epee', 'unbound', 'wallet_merged', 'lmdb', 'randomx'
|
||||
monero.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/libs/monero/include/src/**" }
|
||||
end
|
||||
|
||||
s.subspec 'Boost' do |boost|
|
||||
boost.preserve_paths = 'External/ios/libs/boost/include/**/*.h', 'External/ios/libs/boost/include/**/*.h'
|
||||
boost.vendored_libraries = 'External/ios/libs/boost/build/libs/universal/*.a'
|
||||
boost.libraries = 'boost', 'boost_wserialization', 'boost_thread', 'boost_system', 'boost_signals', 'boost_serialization', 'boost_regex', 'boost_random', 'boost_program_options', 'boost_locale', 'boost_graph', 'boost_filesystem', 'boost_date_time', 'boost_chrono'
|
||||
boost.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/libs/boost/include/**" }
|
||||
end
|
||||
|
||||
s.subspec 'Sodium' do |sodium|
|
||||
sodium.preserve_paths = 'External/ios/libs/sodium/include/**/*.h'
|
||||
sodium.vendored_libraries = 'External/ios/libs/sodium/lib/libsodium.a'
|
||||
sodium.libraries = 'sodium'
|
||||
sodium.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/libs/sodium/include/**" }
|
||||
end
|
||||
|
||||
s.subspec 'lmdb' do |lmdb|
|
||||
lmdb.vendored_libraries = 'External/ios/libs/lmdb/liblmdb.a'
|
||||
lmdb.libraries = 'lmdb'
|
||||
end
|
||||
end
|
|
@ -1,66 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:cw_monero/signatures.dart';
|
||||
import 'package:cw_monero/types.dart';
|
||||
import 'package:cw_monero/monero_api.dart';
|
||||
import 'package:cw_monero/structs/account_row.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
final accountSizeNative = moneroApi
|
||||
.lookup<NativeFunction<account_size>>('account_size')
|
||||
.asFunction<SubaddressSize>();
|
||||
|
||||
final accountRefreshNative = moneroApi
|
||||
.lookup<NativeFunction<account_refresh>>('account_refresh')
|
||||
.asFunction<AccountRefresh>();
|
||||
|
||||
final accountGetAllNative = moneroApi
|
||||
.lookup<NativeFunction<account_get_all>>('account_get_all')
|
||||
.asFunction<AccountGetAll>();
|
||||
|
||||
final accountAddNewNative = moneroApi
|
||||
.lookup<NativeFunction<account_add_new>>('account_add_row')
|
||||
.asFunction<AccountAddNew>();
|
||||
|
||||
final accountSetLabelNative = moneroApi
|
||||
.lookup<NativeFunction<account_set_label>>('account_set_label_row')
|
||||
.asFunction<AccountSetLabel>();
|
||||
|
||||
void refreshAccounts() => accountRefreshNative();
|
||||
|
||||
List<AccountRow> getAllAccount() {
|
||||
final size = accountSizeNative();
|
||||
final accountAddressesPointer = accountGetAllNative();
|
||||
final accountAddresses = accountAddressesPointer.asTypedList(size);
|
||||
|
||||
return accountAddresses
|
||||
.map((addr) => Pointer<AccountRow>.fromAddress(addr).ref)
|
||||
.toList();
|
||||
}
|
||||
|
||||
void addAccountSync({String label}) {
|
||||
final labelPointer = Utf8.toUtf8(label);
|
||||
accountAddNewNative(labelPointer);
|
||||
free(labelPointer);
|
||||
}
|
||||
|
||||
void setLabelForAccountSync({int accountIndex, String label}) {
|
||||
final labelPointer = Utf8.toUtf8(label);
|
||||
accountSetLabelNative(accountIndex, labelPointer);
|
||||
free(labelPointer);
|
||||
}
|
||||
|
||||
void _addAccount(String label) => addAccountSync(label: label);
|
||||
|
||||
void _setLabelForAccount(Map<String, dynamic> args) {
|
||||
final label = args['label'] as String;
|
||||
final accountIndex = args['accountIndex'] as int;
|
||||
|
||||
setLabelForAccountSync(label: label, accountIndex: accountIndex);
|
||||
}
|
||||
|
||||
Future<void> addAccount({String label}) async => compute(_addAccount, label);
|
||||
|
||||
Future<void> setLabelForAccount({int accountIndex, String label}) async =>
|
||||
compute(
|
||||
_setLabelForAccount, {'accountIndex': accountIndex, 'label': label});
|
|
@ -1,8 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
String convertUTF8ToString({Pointer<Utf8> pointer}) {
|
||||
final str = Utf8.fromUtf8(pointer);
|
||||
free(pointer);
|
||||
return str;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
class ConnectionToNodeException implements Exception {
|
||||
ConnectionToNodeException({this.message});
|
||||
|
||||
final String message;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
class CreationTransactionException implements Exception {
|
||||
CreationTransactionException({this.message});
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
class SetupWalletException implements Exception {
|
||||
SetupWalletException({this.message});
|
||||
|
||||
final String message;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
class WalletCreationException implements Exception {
|
||||
WalletCreationException({this.message});
|
||||
|
||||
final String message;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
class WalletRestoreFromKeysException implements Exception {
|
||||
WalletRestoreFromKeysException({this.message});
|
||||
|
||||
final String message;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
class WalletRestoreFromSeedException implements Exception {
|
||||
WalletRestoreFromSeedException({this.message});
|
||||
|
||||
final String message;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
final DynamicLibrary moneroApi = Platform.isAndroid
|
||||
? DynamicLibrary.open('libcw_monero.so')
|
||||
: DynamicLibrary.open('cw_monero.framework/cw_monero');
|
|
@ -1,108 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:cw_monero/structs/pending_transaction.dart';
|
||||
import 'package:cw_monero/structs/ut8_box.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
typedef create_wallet = Int8 Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Int32, Pointer<Utf8>);
|
||||
|
||||
typedef restore_wallet_from_seed = Int8 Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Int32, Int64, Pointer<Utf8>);
|
||||
|
||||
typedef restore_wallet_from_keys = Int8 Function(Pointer<Utf8>, Pointer<Utf8>,
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Int32, Int64, Pointer<Utf8>);
|
||||
|
||||
typedef is_wallet_exist = Int8 Function(Pointer<Utf8>);
|
||||
|
||||
typedef load_wallet = Void Function(Pointer<Utf8>, Pointer<Utf8>, Int8);
|
||||
|
||||
typedef get_filename = Pointer<Utf8> Function();
|
||||
|
||||
typedef get_seed = Pointer<Utf8> Function();
|
||||
|
||||
typedef get_address = Pointer<Utf8> Function(Int32, Int32);
|
||||
|
||||
typedef get_full_balanace = Int64 Function(Int32);
|
||||
|
||||
typedef get_unlocked_balanace = Int64 Function(Int32);
|
||||
|
||||
typedef get_current_height = Int64 Function();
|
||||
|
||||
typedef get_node_height = Int64 Function();
|
||||
|
||||
typedef is_connected = Int8 Function();
|
||||
|
||||
typedef setup_node = Int8 Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Int8, Int8, Pointer<Utf8>);
|
||||
|
||||
typedef start_refresh = Void Function();
|
||||
|
||||
typedef connect_to_node = Int8 Function();
|
||||
|
||||
typedef set_refresh_from_block_height = Void Function(Int64);
|
||||
|
||||
typedef set_recovering_from_seed = Void Function(Int8);
|
||||
|
||||
typedef store_c = Void Function();
|
||||
|
||||
typedef set_listener = Void Function();
|
||||
|
||||
typedef get_syncing_height = Int64 Function();
|
||||
|
||||
typedef is_needed_to_refresh = Int8 Function();
|
||||
|
||||
typedef is_new_transaction_exist = Int8 Function();
|
||||
|
||||
typedef subaddrress_size = Int32 Function();
|
||||
|
||||
typedef subaddrress_refresh = Void Function(Int32);
|
||||
|
||||
typedef subaddress_get_all = Pointer<Int64> Function();
|
||||
|
||||
typedef subaddress_add_new = Void Function(
|
||||
Int32 accountIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef subaddress_set_label = Void Function(
|
||||
Int32 accountIndex, Int32 addressIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef account_size = Int32 Function();
|
||||
|
||||
typedef account_refresh = Void Function();
|
||||
|
||||
typedef account_get_all = Pointer<Int64> Function();
|
||||
|
||||
typedef account_add_new = Void Function(Pointer<Utf8> label);
|
||||
|
||||
typedef account_set_label = Void Function(
|
||||
Int32 accountIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef transactions_refresh = Void Function();
|
||||
|
||||
typedef transactions_count = Int64 Function();
|
||||
|
||||
typedef transactions_get_all = Pointer<Int64> Function();
|
||||
|
||||
typedef transaction_create = Int8 Function(
|
||||
Pointer<Utf8> address,
|
||||
Pointer<Utf8> paymentId,
|
||||
Pointer<Utf8> amount,
|
||||
Int8 priorityRaw,
|
||||
Int32 subaddrAccount,
|
||||
Pointer<Utf8Box> error,
|
||||
Pointer<PendingTransactionRaw> pendingTransaction);
|
||||
|
||||
typedef transaction_commit = Int8 Function(Pointer<PendingTransactionRaw>, Pointer<Utf8Box>);
|
||||
|
||||
typedef secret_view_key = Pointer<Utf8> Function();
|
||||
|
||||
typedef public_view_key = Pointer<Utf8> Function();
|
||||
|
||||
typedef secret_spend_key = Pointer<Utf8> Function();
|
||||
|
||||
typedef public_spend_key = Pointer<Utf8> Function();
|
||||
|
||||
typedef close_current_wallet = Void Function();
|
||||
|
||||
typedef on_startup = Void Function();
|
||||
|
||||
typedef rescan_blockchain = Void Function();
|
|
@ -1,11 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
class AccountRow extends Struct {
|
||||
@Int64()
|
||||
int id;
|
||||
Pointer<Utf8> label;
|
||||
|
||||
String getLabel() => Utf8.fromUtf8(label);
|
||||
int getId() => id;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
class PendingTransactionRaw extends Struct {
|
||||
@Int64()
|
||||
int amount;
|
||||
|
||||
@Int64()
|
||||
int fee;
|
||||
|
||||
Pointer<Utf8> hash;
|
||||
|
||||
String getHash() => Utf8.fromUtf8(hash);
|
||||
}
|
||||
|
||||
class PendingTransactionDescription {
|
||||
PendingTransactionDescription({this.amount, this.fee, this.hash, this.pointerAddress});
|
||||
|
||||
final int amount;
|
||||
final int fee;
|
||||
final String hash;
|
||||
final int pointerAddress;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
class SubaddressRow extends Struct {
|
||||
@Int64()
|
||||
int id;
|
||||
Pointer<Utf8> address;
|
||||
Pointer<Utf8> label;
|
||||
|
||||
String getLabel() => Utf8.fromUtf8(label);
|
||||
String getAddress() => Utf8.fromUtf8(address);
|
||||
int getId() => id;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
class TransactionInfoRow extends Struct {
|
||||
@Uint64()
|
||||
int amount;
|
||||
|
||||
@Uint64()
|
||||
int fee;
|
||||
|
||||
@Uint64()
|
||||
int blockHeight;
|
||||
|
||||
@Uint64()
|
||||
int confirmations;
|
||||
|
||||
@Uint32()
|
||||
int subaddrAccount;
|
||||
|
||||
@Int8()
|
||||
int direction;
|
||||
|
||||
@Int8()
|
||||
int isPending;
|
||||
|
||||
Pointer<Utf8> hash;
|
||||
|
||||
Pointer<Utf8> paymentId;
|
||||
|
||||
@Int64()
|
||||
int datetime;
|
||||
|
||||
int getDatetime() => datetime;
|
||||
int getAmount() => amount >= 0 ? amount : amount * -1;
|
||||
bool getIsPending() => isPending != 0;
|
||||
String getHash() => Utf8.fromUtf8(hash);
|
||||
String getPaymentId() => Utf8.fromUtf8(paymentId);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
class Utf8Box extends Struct {
|
||||
Pointer<Utf8> value;
|
||||
|
||||
String getValue() => Utf8.fromUtf8(value);
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cw_monero/signatures.dart';
|
||||
import 'package:cw_monero/types.dart';
|
||||
import 'package:cw_monero/monero_api.dart';
|
||||
import 'package:cw_monero/structs/subaddress_row.dart';
|
||||
|
||||
final subaddressSizeNative = moneroApi
|
||||
.lookup<NativeFunction<subaddrress_size>>('subaddrress_size')
|
||||
.asFunction<SubaddressSize>();
|
||||
|
||||
final subaddressRefreshNative = moneroApi
|
||||
.lookup<NativeFunction<subaddrress_refresh>>('subaddress_refresh')
|
||||
.asFunction<SubaddressRefresh>();
|
||||
|
||||
final subaddrressGetAllNative = moneroApi
|
||||
.lookup<NativeFunction<subaddress_get_all>>('subaddrress_get_all')
|
||||
.asFunction<SubaddressGetAll>();
|
||||
|
||||
final subaddrressAddNewNative = moneroApi
|
||||
.lookup<NativeFunction<subaddress_add_new>>('subaddress_add_row')
|
||||
.asFunction<SubaddressAddNew>();
|
||||
|
||||
final subaddrressSetLabelNative = moneroApi
|
||||
.lookup<NativeFunction<subaddress_set_label>>('subaddress_set_label')
|
||||
.asFunction<SubaddressSetLabel>();
|
||||
|
||||
void refreshSubaddresses({int accountIndex}) =>
|
||||
subaddressRefreshNative(accountIndex);
|
||||
|
||||
List<SubaddressRow> getAllSubaddresses() {
|
||||
final size = subaddressSizeNative();
|
||||
final subaddressAddressesPointer = subaddrressGetAllNative();
|
||||
final subaddressAddresses = subaddressAddressesPointer.asTypedList(size);
|
||||
|
||||
return subaddressAddresses
|
||||
.map((addr) => Pointer<SubaddressRow>.fromAddress(addr).ref)
|
||||
.toList();
|
||||
}
|
||||
|
||||
void addSubaddressSync({int accountIndex, String label}) {
|
||||
final labelPointer = Utf8.toUtf8(label);
|
||||
subaddrressAddNewNative(accountIndex, labelPointer);
|
||||
free(labelPointer);
|
||||
}
|
||||
|
||||
void setLabelForSubaddressSync(
|
||||
{int accountIndex, int addressIndex, String label}) {
|
||||
final labelPointer = Utf8.toUtf8(label);
|
||||
|
||||
subaddrressSetLabelNative(accountIndex, addressIndex, labelPointer);
|
||||
free(labelPointer);
|
||||
}
|
||||
|
||||
void _addSubaddress(Map<String, dynamic> args) {
|
||||
final label = args['label'] as String;
|
||||
final accountIndex = args['accountIndex'] as int;
|
||||
|
||||
addSubaddressSync(accountIndex: accountIndex, label: label);
|
||||
}
|
||||
|
||||
void _setLabelForSubaddress(Map<String, dynamic> args) {
|
||||
final label = args['label'] as String;
|
||||
final accountIndex = args['accountIndex'] as int;
|
||||
final addressIndex = args['addressIndex'] as int;
|
||||
|
||||
setLabelForSubaddressSync(
|
||||
accountIndex: accountIndex, addressIndex: addressIndex, label: label);
|
||||
}
|
||||
|
||||
Future addSubaddress({int accountIndex, String label}) async =>
|
||||
compute<Map<String, Object>, void>(_addSubaddress, {'accountIndex': accountIndex, 'label': label});
|
||||
|
||||
Future setLabelForSubaddress(
|
||||
{int accountIndex, int addressIndex, String label}) =>
|
||||
compute<Map<String, Object>, void>(_setLabelForSubaddress, {
|
||||
'accountIndex': accountIndex,
|
||||
'addressIndex': addressIndex,
|
||||
'label': label
|
||||
});
|
|
@ -1,129 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:cw_monero/structs/ut8_box.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cw_monero/signatures.dart';
|
||||
import 'package:cw_monero/types.dart';
|
||||
import 'package:cw_monero/monero_api.dart';
|
||||
import 'package:cw_monero/structs/transaction_info_row.dart';
|
||||
import 'package:cw_monero/structs/pending_transaction.dart';
|
||||
import 'package:cw_monero/exceptions/creation_transaction_exception.dart';
|
||||
|
||||
final transactionsRefreshNative = moneroApi
|
||||
.lookup<NativeFunction<transactions_refresh>>('transactions_refresh')
|
||||
.asFunction<TransactionsRefresh>();
|
||||
|
||||
final transactionsCountNative = moneroApi
|
||||
.lookup<NativeFunction<transactions_count>>('transactions_count')
|
||||
.asFunction<TransactionsCount>();
|
||||
|
||||
final transactionsGetAllNative = moneroApi
|
||||
.lookup<NativeFunction<transactions_get_all>>('transactions_get_all')
|
||||
.asFunction<TransactionsGetAll>();
|
||||
|
||||
final transactionCreateNative = moneroApi
|
||||
.lookup<NativeFunction<transaction_create>>('transaction_create')
|
||||
.asFunction<TransactionCreate>();
|
||||
|
||||
final transactionCommitNative = moneroApi
|
||||
.lookup<NativeFunction<transaction_commit>>('transaction_commit')
|
||||
.asFunction<TransactionCommit>();
|
||||
|
||||
void refreshTransactions() => transactionsRefreshNative();
|
||||
|
||||
int countOfTransactions() => transactionsCountNative();
|
||||
|
||||
List<TransactionInfoRow> getAllTransations() {
|
||||
final size = transactionsCountNative();
|
||||
final transactionsPointer = transactionsGetAllNative();
|
||||
final transactionsAddresses = transactionsPointer.asTypedList(size);
|
||||
|
||||
return transactionsAddresses
|
||||
.map((addr) => Pointer<TransactionInfoRow>.fromAddress(addr).ref)
|
||||
.toList();
|
||||
}
|
||||
|
||||
PendingTransactionDescription createTransactionSync(
|
||||
{String address,
|
||||
String paymentId,
|
||||
String amount,
|
||||
int priorityRaw,
|
||||
int accountIndex = 0}) {
|
||||
final addressPointer = Utf8.toUtf8(address);
|
||||
final paymentIdPointer = Utf8.toUtf8(paymentId);
|
||||
final amountPointer = amount != null ? Utf8.toUtf8(amount) : nullptr;
|
||||
final errorMessagePointer = allocate<Utf8Box>();
|
||||
final pendingTransactionRawPointer = allocate<PendingTransactionRaw>();
|
||||
final created = transactionCreateNative(
|
||||
addressPointer,
|
||||
paymentIdPointer,
|
||||
amountPointer,
|
||||
priorityRaw,
|
||||
accountIndex,
|
||||
errorMessagePointer,
|
||||
pendingTransactionRawPointer) !=
|
||||
0;
|
||||
|
||||
free(addressPointer);
|
||||
free(paymentIdPointer);
|
||||
|
||||
if (amountPointer != nullptr) {
|
||||
free(amountPointer);
|
||||
}
|
||||
|
||||
if (!created) {
|
||||
final message = errorMessagePointer.ref.getValue();
|
||||
free(errorMessagePointer);
|
||||
throw CreationTransactionException(message: message);
|
||||
}
|
||||
|
||||
return PendingTransactionDescription(
|
||||
amount: pendingTransactionRawPointer.ref.amount,
|
||||
fee: pendingTransactionRawPointer.ref.fee,
|
||||
hash: pendingTransactionRawPointer.ref.getHash(),
|
||||
pointerAddress: pendingTransactionRawPointer.address);
|
||||
}
|
||||
|
||||
void commitTransactionFromPointerAddress({int address}) => commitTransaction(
|
||||
transactionPointer: Pointer<PendingTransactionRaw>.fromAddress(address));
|
||||
|
||||
void commitTransaction({Pointer<PendingTransactionRaw> transactionPointer}) {
|
||||
final errorMessagePointer = allocate<Utf8Box>();
|
||||
final isCommited =
|
||||
transactionCommitNative(transactionPointer, errorMessagePointer) != 0;
|
||||
|
||||
if (!isCommited) {
|
||||
final message = errorMessagePointer.ref.getValue();
|
||||
free(errorMessagePointer);
|
||||
throw CreationTransactionException(message: message);
|
||||
}
|
||||
}
|
||||
|
||||
PendingTransactionDescription _createTransactionSync(Map args) {
|
||||
final address = args['address'] as String;
|
||||
final paymentId = args['paymentId'] as String;
|
||||
final amount = args['amount'] as String;
|
||||
final priorityRaw = args['priorityRaw'] as int;
|
||||
final accountIndex = args['accountIndex'] as int;
|
||||
|
||||
return createTransactionSync(
|
||||
address: address,
|
||||
paymentId: paymentId,
|
||||
amount: amount,
|
||||
priorityRaw: priorityRaw,
|
||||
accountIndex: accountIndex);
|
||||
}
|
||||
|
||||
Future<PendingTransactionDescription> createTransaction(
|
||||
{String address,
|
||||
String paymentId,
|
||||
String amount,
|
||||
int priorityRaw,
|
||||
int accountIndex = 0}) =>
|
||||
compute(_createTransactionSync, {
|
||||
'address': address,
|
||||
'paymentId': paymentId,
|
||||
'amount': amount,
|
||||
'priorityRaw': priorityRaw,
|
||||
'accountIndex': accountIndex
|
||||
});
|
|
@ -1,106 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:cw_monero/structs/pending_transaction.dart';
|
||||
import 'package:cw_monero/structs/ut8_box.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
typedef CreateWallet = int Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Utf8>);
|
||||
|
||||
typedef RestoreWalletFromSeed = int Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, int, Pointer<Utf8>);
|
||||
|
||||
typedef RestoreWalletFromKeys = int Function(Pointer<Utf8>, Pointer<Utf8>,
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, int, Pointer<Utf8>);
|
||||
|
||||
typedef IsWalletExist = int Function(Pointer<Utf8>);
|
||||
|
||||
typedef LoadWallet = void Function(Pointer<Utf8>, Pointer<Utf8>, int);
|
||||
|
||||
typedef GetFilename = Pointer<Utf8> Function();
|
||||
|
||||
typedef GetSeed = Pointer<Utf8> Function();
|
||||
|
||||
typedef GetAddress = Pointer<Utf8> Function(int, int);
|
||||
|
||||
typedef GetFullBalance = int Function(int);
|
||||
|
||||
typedef GetUnlockedBalance = int Function(int);
|
||||
|
||||
typedef GetCurrentHeight = int Function();
|
||||
|
||||
typedef GetNodeHeight = int Function();
|
||||
|
||||
typedef IsConnected = int Function();
|
||||
|
||||
typedef SetupNode = int Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, int, Pointer<Utf8>);
|
||||
|
||||
typedef StartRefresh = void Function();
|
||||
|
||||
typedef ConnectToNode = int Function();
|
||||
|
||||
typedef SetRefreshFromBlockHeight = void Function(int);
|
||||
|
||||
typedef SetRecoveringFromSeed = void Function(int);
|
||||
|
||||
typedef Store = void Function();
|
||||
|
||||
typedef SetListener = void Function();
|
||||
|
||||
typedef GetSyncingHeight = int Function();
|
||||
|
||||
typedef IsNeededToRefresh = int Function();
|
||||
|
||||
typedef IsNewTransactionExist = int Function();
|
||||
|
||||
typedef SubaddressSize = int Function();
|
||||
|
||||
typedef SubaddressRefresh = void Function(int);
|
||||
|
||||
typedef SubaddressGetAll = Pointer<Int64> Function();
|
||||
|
||||
typedef SubaddressAddNew = void Function(int accountIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef SubaddressSetLabel = void Function(
|
||||
int accountIndex, int addressIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef AccountSize = int Function();
|
||||
|
||||
typedef AccountRefresh = void Function();
|
||||
|
||||
typedef AccountGetAll = Pointer<Int64> Function();
|
||||
|
||||
typedef AccountAddNew = void Function(Pointer<Utf8> label);
|
||||
|
||||
typedef AccountSetLabel = void Function(int accountIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef TransactionsRefresh = void Function();
|
||||
|
||||
typedef TransactionsCount = int Function();
|
||||
|
||||
typedef TransactionsGetAll = Pointer<Int64> Function();
|
||||
|
||||
typedef TransactionCreate = int Function(
|
||||
Pointer<Utf8> address,
|
||||
Pointer<Utf8> paymentId,
|
||||
Pointer<Utf8> amount,
|
||||
int priorityRaw,
|
||||
int subaddrAccount,
|
||||
Pointer<Utf8Box> error,
|
||||
Pointer<PendingTransactionRaw> pendingTransaction);
|
||||
|
||||
typedef TransactionCommit = int Function(Pointer<PendingTransactionRaw>, Pointer<Utf8Box>);
|
||||
|
||||
typedef SecretViewKey = Pointer<Utf8> Function();
|
||||
|
||||
typedef PublicViewKey = Pointer<Utf8> Function();
|
||||
|
||||
typedef SecretSpendKey = Pointer<Utf8> Function();
|
||||
|
||||
typedef PublicSpendKey = Pointer<Utf8> Function();
|
||||
|
||||
typedef CloseCurrentWallet = void Function();
|
||||
|
||||
typedef OnStartup = void Function();
|
||||
|
||||
typedef RescanBlockchainAsync = void Function();
|
|
@ -1,300 +0,0 @@
|
|||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
import 'dart:typed_data';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:cw_monero/convert_utf8_to_string.dart';
|
||||
import 'package:cw_monero/signatures.dart';
|
||||
import 'package:cw_monero/types.dart';
|
||||
import 'package:cw_monero/monero_api.dart';
|
||||
import 'package:cw_monero/exceptions/setup_wallet_exception.dart';
|
||||
|
||||
// Listener event types constants
|
||||
|
||||
const newBlockEvent = 0;
|
||||
const refreshedEvent = 1;
|
||||
const updatedEvent = 2;
|
||||
const moneyReceivedEvent = 3;
|
||||
const moneySpentEvent = 4;
|
||||
const unconfirmedMoneyReceivedEvent = 5;
|
||||
|
||||
int _boolToInt(bool value) => value ? 1 : 0;
|
||||
|
||||
final statusSyncChannel =
|
||||
BasicMessageChannel<ByteData>('cw_monero.sync_listener', BinaryCodec());
|
||||
|
||||
final moneroMethodChannel = MethodChannel('cw_monero');
|
||||
|
||||
final getFileNameNative = moneroApi
|
||||
.lookup<NativeFunction<get_filename>>('get_filename')
|
||||
.asFunction<GetFilename>();
|
||||
|
||||
final getSeedNative =
|
||||
moneroApi.lookup<NativeFunction<get_seed>>('seed').asFunction<GetSeed>();
|
||||
|
||||
final getAddressNative = moneroApi
|
||||
.lookup<NativeFunction<get_address>>('get_address')
|
||||
.asFunction<GetAddress>();
|
||||
|
||||
final getFullBalanceNative = moneroApi
|
||||
.lookup<NativeFunction<get_full_balanace>>('get_full_balance')
|
||||
.asFunction<GetFullBalance>();
|
||||
|
||||
final getUnlockedBalanceNative = moneroApi
|
||||
.lookup<NativeFunction<get_unlocked_balanace>>('get_unlocked_balance')
|
||||
.asFunction<GetUnlockedBalance>();
|
||||
|
||||
final getCurrentHeightNative = moneroApi
|
||||
.lookup<NativeFunction<get_current_height>>('get_current_height')
|
||||
.asFunction<GetCurrentHeight>();
|
||||
|
||||
final getNodeHeightNative = moneroApi
|
||||
.lookup<NativeFunction<get_node_height>>('get_node_height')
|
||||
.asFunction<GetNodeHeight>();
|
||||
|
||||
final isConnectedNative = moneroApi
|
||||
.lookup<NativeFunction<is_connected>>('is_connected')
|
||||
.asFunction<IsConnected>();
|
||||
|
||||
final setupNodeNative = moneroApi
|
||||
.lookup<NativeFunction<setup_node>>('setup_node')
|
||||
.asFunction<SetupNode>();
|
||||
|
||||
final startRefreshNative = moneroApi
|
||||
.lookup<NativeFunction<start_refresh>>('start_refresh')
|
||||
.asFunction<StartRefresh>();
|
||||
|
||||
final connecToNodeNative = moneroApi
|
||||
.lookup<NativeFunction<connect_to_node>>('connect_to_node')
|
||||
.asFunction<ConnectToNode>();
|
||||
|
||||
final setRefreshFromBlockHeightNative = moneroApi
|
||||
.lookup<NativeFunction<set_refresh_from_block_height>>(
|
||||
'set_refresh_from_block_height')
|
||||
.asFunction<SetRefreshFromBlockHeight>();
|
||||
|
||||
final setRecoveringFromSeedNative = moneroApi
|
||||
.lookup<NativeFunction<set_recovering_from_seed>>(
|
||||
'set_recovering_from_seed')
|
||||
.asFunction<SetRecoveringFromSeed>();
|
||||
|
||||
final storeNative =
|
||||
moneroApi.lookup<NativeFunction<store_c>>('store').asFunction<Store>();
|
||||
|
||||
final setListenerNative = moneroApi.lookupFunction<
|
||||
Void Function(Int64 sendPort), void Function(int sendPort)>('set_listener');
|
||||
|
||||
final getSyncingHeightNative = moneroApi
|
||||
.lookup<NativeFunction<get_syncing_height>>('get_syncing_height')
|
||||
.asFunction<GetSyncingHeight>();
|
||||
|
||||
final isNeededToRefreshNative = moneroApi
|
||||
.lookup<NativeFunction<is_needed_to_refresh>>('is_needed_to_refresh')
|
||||
.asFunction<IsNeededToRefresh>();
|
||||
|
||||
final isNewTransactionExistNative = moneroApi
|
||||
.lookup<NativeFunction<is_new_transaction_exist>>(
|
||||
'is_new_transaction_exist')
|
||||
.asFunction<IsNewTransactionExist>();
|
||||
|
||||
final getSecretViewKeyNative = moneroApi
|
||||
.lookup<NativeFunction<secret_view_key>>('secret_view_key')
|
||||
.asFunction<SecretViewKey>();
|
||||
|
||||
final getPublicViewKeyNative = moneroApi
|
||||
.lookup<NativeFunction<public_view_key>>('public_view_key')
|
||||
.asFunction<PublicViewKey>();
|
||||
|
||||
final getSecretSpendKeyNative = moneroApi
|
||||
.lookup<NativeFunction<secret_spend_key>>('secret_spend_key')
|
||||
.asFunction<SecretSpendKey>();
|
||||
|
||||
final getPublicSpendKeyNative = moneroApi
|
||||
.lookup<NativeFunction<secret_view_key>>('public_spend_key')
|
||||
.asFunction<PublicSpendKey>();
|
||||
|
||||
final closeCurrentWalletNative = moneroApi
|
||||
.lookup<NativeFunction<close_current_wallet>>('close_current_wallet')
|
||||
.asFunction<CloseCurrentWallet>();
|
||||
|
||||
final onStartupNative = moneroApi
|
||||
.lookup<NativeFunction<on_startup>>('on_startup')
|
||||
.asFunction<OnStartup>();
|
||||
|
||||
final rescanBlockchainAsyncNative = moneroApi
|
||||
.lookup<NativeFunction<rescan_blockchain>>('rescan_blockchain')
|
||||
.asFunction<RescanBlockchainAsync>();
|
||||
|
||||
int getSyncingHeight() => getSyncingHeightNative();
|
||||
|
||||
bool isNeededToRefresh() => isNeededToRefreshNative() != 0;
|
||||
|
||||
bool isNewTransactionExist() => isNewTransactionExistNative() != 0;
|
||||
|
||||
String getFilename() => convertUTF8ToString(pointer: getFileNameNative());
|
||||
|
||||
String getSeed() => convertUTF8ToString(pointer: getSeedNative());
|
||||
|
||||
String getAddress({int accountIndex = 0, int addressIndex = 0}) =>
|
||||
convertUTF8ToString(pointer: getAddressNative(accountIndex, addressIndex));
|
||||
|
||||
int getFullBalance({int accountIndex = 0}) =>
|
||||
getFullBalanceNative(accountIndex);
|
||||
|
||||
int getUnlockedBalance({int accountIndex = 0}) =>
|
||||
getUnlockedBalanceNative(accountIndex);
|
||||
|
||||
int getCurrentHeight() => getCurrentHeightNative();
|
||||
|
||||
int getNodeHeightSync() => getNodeHeightNative();
|
||||
|
||||
bool isConnectedSync() => isConnectedNative() != 0;
|
||||
|
||||
bool setupNodeSync(
|
||||
{String address,
|
||||
String login,
|
||||
String password,
|
||||
bool useSSL = false,
|
||||
bool isLightWallet = false}) {
|
||||
final addressPointer = Utf8.toUtf8(address);
|
||||
Pointer<Utf8> loginPointer;
|
||||
Pointer<Utf8> passwordPointer;
|
||||
|
||||
if (login != null) {
|
||||
loginPointer = Utf8.toUtf8(login);
|
||||
}
|
||||
|
||||
if (password != null) {
|
||||
passwordPointer = Utf8.toUtf8(password);
|
||||
}
|
||||
|
||||
final errorMessagePointer = allocate<Utf8>();
|
||||
final isSetupNode = setupNodeNative(
|
||||
addressPointer,
|
||||
loginPointer,
|
||||
passwordPointer,
|
||||
_boolToInt(useSSL),
|
||||
_boolToInt(isLightWallet),
|
||||
errorMessagePointer) !=
|
||||
0;
|
||||
|
||||
free(addressPointer);
|
||||
free(loginPointer);
|
||||
free(passwordPointer);
|
||||
|
||||
if (!isSetupNode) {
|
||||
throw SetupWalletException(
|
||||
message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||
}
|
||||
|
||||
return isSetupNode;
|
||||
}
|
||||
|
||||
void startRefreshSync() => startRefreshNative();
|
||||
|
||||
Future<bool> connectToNode() async => connecToNodeNative() != 0;
|
||||
|
||||
void setRefreshFromBlockHeight({int height}) =>
|
||||
setRefreshFromBlockHeightNative(height);
|
||||
|
||||
void setRecoveringFromSeed({bool isRecovery}) =>
|
||||
setRecoveringFromSeedNative(_boolToInt(isRecovery));
|
||||
|
||||
void storeSync() {
|
||||
storeNative();
|
||||
}
|
||||
|
||||
void closeCurrentWallet() => closeCurrentWalletNative();
|
||||
|
||||
String getSecretViewKey() =>
|
||||
convertUTF8ToString(pointer: getSecretViewKeyNative());
|
||||
|
||||
String getPublicViewKey() =>
|
||||
convertUTF8ToString(pointer: getPublicViewKeyNative());
|
||||
|
||||
String getSecretSpendKey() =>
|
||||
convertUTF8ToString(pointer: getSecretSpendKeyNative());
|
||||
|
||||
String getPublicSpendKey() =>
|
||||
convertUTF8ToString(pointer: getPublicSpendKeyNative());
|
||||
|
||||
Future<void> setListeners(
|
||||
Future Function(int) onNewBlock,
|
||||
Future Function() onNeedToRefresh,
|
||||
Future Function() onNewTransaction) async {
|
||||
statusSyncChannel.setMessageHandler((message) async {
|
||||
try {
|
||||
final type = message.buffer.asByteData(0, 1).getUint8(0);
|
||||
|
||||
if (type == newBlockEvent) {
|
||||
final value = message.buffer.asByteData(1).getUint64(0);
|
||||
await onNewBlock(value);
|
||||
}
|
||||
|
||||
if (type == refreshedEvent) {
|
||||
await onNeedToRefresh();
|
||||
}
|
||||
|
||||
if (type == moneyReceivedEvent ||
|
||||
type == moneySpentEvent ||
|
||||
type == unconfirmedMoneyReceivedEvent) {
|
||||
await onNewTransaction();
|
||||
}
|
||||
} catch(e) {
|
||||
print(e.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
await moneroMethodChannel
|
||||
.invokeMethod<bool>('setupSyncStatusListener');
|
||||
}
|
||||
|
||||
void onStartup() => onStartupNative();
|
||||
|
||||
void _storeSync(Object _) => storeSync();
|
||||
|
||||
bool _setupNodeSync(Map args) {
|
||||
final address = args['address'] as String;
|
||||
final login = (args['login'] ?? '') as String;
|
||||
final password = (args['password'] ?? '') as String;
|
||||
final useSSL = args['useSSL'] as bool;
|
||||
final isLightWallet = args['isLightWallet'] as bool;
|
||||
|
||||
return setupNodeSync(
|
||||
address: address,
|
||||
login: login,
|
||||
password: password,
|
||||
useSSL: useSSL,
|
||||
isLightWallet: isLightWallet);
|
||||
}
|
||||
|
||||
bool _isConnected(Object _) => isConnectedSync();
|
||||
|
||||
int _getNodeHeight(Object _) => getNodeHeightSync();
|
||||
|
||||
void startRefresh() => startRefreshSync();
|
||||
|
||||
Future setupNode(
|
||||
{String address,
|
||||
String login,
|
||||
String password,
|
||||
bool useSSL = false,
|
||||
bool isLightWallet = false}) =>
|
||||
compute<Map<String, Object>, void>(_setupNodeSync, {
|
||||
'address': address,
|
||||
'login': login,
|
||||
'password': password,
|
||||
'useSSL': useSSL,
|
||||
'isLightWallet': isLightWallet
|
||||
});
|
||||
|
||||
Future store() => compute<int, void>(_storeSync, 0);
|
||||
|
||||
Future<bool> isConnected() => compute(_isConnected, 0);
|
||||
|
||||
Future<int> getNodeHeight() => compute(_getNodeHeight, 0);
|
||||
|
||||
void rescanBlockchainAsync() => rescanBlockchainAsyncNative();
|
|
@ -1,236 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cw_monero/convert_utf8_to_string.dart';
|
||||
import 'package:cw_monero/signatures.dart';
|
||||
import 'package:cw_monero/types.dart';
|
||||
import 'package:cw_monero/monero_api.dart';
|
||||
import 'package:cw_monero/exceptions/wallet_creation_exception.dart';
|
||||
import 'package:cw_monero/exceptions/wallet_restore_from_keys_exception.dart';
|
||||
import 'package:cw_monero/exceptions/wallet_restore_from_seed_exception.dart';
|
||||
|
||||
final createWalletNative = moneroApi
|
||||
.lookup<NativeFunction<create_wallet>>('create_wallet')
|
||||
.asFunction<CreateWallet>();
|
||||
|
||||
final restoreWalletFromSeedNative = moneroApi
|
||||
.lookup<NativeFunction<restore_wallet_from_seed>>(
|
||||
'restore_wallet_from_seed')
|
||||
.asFunction<RestoreWalletFromSeed>();
|
||||
|
||||
final restoreWalletFromKeysNative = moneroApi
|
||||
.lookup<NativeFunction<restore_wallet_from_keys>>(
|
||||
'restore_wallet_from_keys')
|
||||
.asFunction<RestoreWalletFromKeys>();
|
||||
|
||||
final isWalletExistNative = moneroApi
|
||||
.lookup<NativeFunction<is_wallet_exist>>('is_wallet_exist')
|
||||
.asFunction<IsWalletExist>();
|
||||
|
||||
final loadWalletNative = moneroApi
|
||||
.lookup<NativeFunction<load_wallet>>('load_wallet')
|
||||
.asFunction<LoadWallet>();
|
||||
|
||||
void createWalletSync(
|
||||
{String path, String password, String language, int nettype = 0}) {
|
||||
final pathPointer = Utf8.toUtf8(path);
|
||||
final passwordPointer = Utf8.toUtf8(password);
|
||||
final languagePointer = Utf8.toUtf8(language);
|
||||
final errorMessagePointer = allocate<Utf8>();
|
||||
final isWalletCreated = createWalletNative(pathPointer, passwordPointer,
|
||||
languagePointer, nettype, errorMessagePointer) !=
|
||||
0;
|
||||
|
||||
free(pathPointer);
|
||||
free(passwordPointer);
|
||||
free(languagePointer);
|
||||
|
||||
if (!isWalletCreated) {
|
||||
throw WalletCreationException(
|
||||
message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||
}
|
||||
}
|
||||
|
||||
bool isWalletExistSync({String path}) {
|
||||
final pathPointer = Utf8.toUtf8(path);
|
||||
final isExist = isWalletExistNative(pathPointer) != 0;
|
||||
|
||||
free(pathPointer);
|
||||
|
||||
return isExist;
|
||||
}
|
||||
|
||||
void restoreWalletFromSeedSync(
|
||||
{String path,
|
||||
String password,
|
||||
String seed,
|
||||
int nettype = 0,
|
||||
int restoreHeight = 0}) {
|
||||
final pathPointer = Utf8.toUtf8(path);
|
||||
final passwordPointer = Utf8.toUtf8(password);
|
||||
final seedPointer = Utf8.toUtf8(seed);
|
||||
final errorMessagePointer = allocate<Utf8>();
|
||||
final isWalletRestored = restoreWalletFromSeedNative(
|
||||
pathPointer,
|
||||
passwordPointer,
|
||||
seedPointer,
|
||||
nettype,
|
||||
restoreHeight,
|
||||
errorMessagePointer) !=
|
||||
0;
|
||||
|
||||
free(pathPointer);
|
||||
free(passwordPointer);
|
||||
free(seedPointer);
|
||||
|
||||
if (!isWalletRestored) {
|
||||
throw WalletRestoreFromSeedException(
|
||||
message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||
}
|
||||
}
|
||||
|
||||
void restoreWalletFromKeysSync(
|
||||
{String path,
|
||||
String password,
|
||||
String language,
|
||||
String address,
|
||||
String viewKey,
|
||||
String spendKey,
|
||||
int nettype = 0,
|
||||
int restoreHeight = 0}) {
|
||||
final pathPointer = Utf8.toUtf8(path);
|
||||
final passwordPointer = Utf8.toUtf8(password);
|
||||
final languagePointer = Utf8.toUtf8(language);
|
||||
final addressPointer = Utf8.toUtf8(address);
|
||||
final viewKeyPointer = Utf8.toUtf8(viewKey);
|
||||
final spendKeyPointer = Utf8.toUtf8(spendKey);
|
||||
final errorMessagePointer = allocate<Utf8>();
|
||||
final isWalletRestored = restoreWalletFromKeysNative(
|
||||
pathPointer,
|
||||
passwordPointer,
|
||||
languagePointer,
|
||||
addressPointer,
|
||||
viewKeyPointer,
|
||||
spendKeyPointer,
|
||||
nettype,
|
||||
restoreHeight,
|
||||
errorMessagePointer) !=
|
||||
0;
|
||||
|
||||
free(pathPointer);
|
||||
free(passwordPointer);
|
||||
free(languagePointer);
|
||||
free(addressPointer);
|
||||
free(viewKeyPointer);
|
||||
free(spendKeyPointer);
|
||||
|
||||
if (!isWalletRestored) {
|
||||
throw WalletRestoreFromKeysException(
|
||||
message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||
}
|
||||
}
|
||||
|
||||
void loadWallet({String path, String password, int nettype = 0}) {
|
||||
final pathPointer = Utf8.toUtf8(path);
|
||||
final passwordPointer = Utf8.toUtf8(password);
|
||||
|
||||
loadWalletNative(pathPointer, passwordPointer, nettype);
|
||||
free(pathPointer);
|
||||
free(passwordPointer);
|
||||
}
|
||||
|
||||
void _createWallet(Map<String, dynamic> args) {
|
||||
final path = args['path'] as String;
|
||||
final password = args['password'] as String;
|
||||
final language = args['language'] as String;
|
||||
|
||||
createWalletSync(path: path, password: password, language: language);
|
||||
}
|
||||
|
||||
void _restoreFromSeed(Map<String, dynamic> args) {
|
||||
final path = args['path'] as String;
|
||||
final password = args['password'] as String;
|
||||
final seed = args['seed'] as String;
|
||||
final restoreHeight = args['restoreHeight'] as int;
|
||||
|
||||
restoreWalletFromSeedSync(
|
||||
path: path, password: password, seed: seed, restoreHeight: restoreHeight);
|
||||
}
|
||||
|
||||
void _restoreFromKeys(Map<String, dynamic> args) {
|
||||
final path = args['path'] as String;
|
||||
final password = args['password'] as String;
|
||||
final language = args['language'] as String;
|
||||
final restoreHeight = args['restoreHeight'] as int;
|
||||
final address = args['address'] as String;
|
||||
final viewKey = args['viewKey'] as String;
|
||||
final spendKey = args['spendKey'] as String;
|
||||
|
||||
restoreWalletFromKeysSync(
|
||||
path: path,
|
||||
password: password,
|
||||
language: language,
|
||||
restoreHeight: restoreHeight,
|
||||
address: address,
|
||||
viewKey: viewKey,
|
||||
spendKey: spendKey);
|
||||
}
|
||||
|
||||
Future<void> _openWallet(Map<String, String> args) async =>
|
||||
loadWallet(path: args['path'], password: args['password']);
|
||||
|
||||
bool _isWalletExist(String path) => isWalletExistSync(path: path);
|
||||
|
||||
void openWallet({String path, String password, int nettype = 0}) async =>
|
||||
loadWallet(path: path, password: password);
|
||||
|
||||
Future<void> openWalletAsync(Map<String, String> args) async =>
|
||||
compute(_openWallet, args);
|
||||
|
||||
Future<void> createWallet(
|
||||
{String path,
|
||||
String password,
|
||||
String language,
|
||||
int nettype = 0}) async =>
|
||||
compute(_createWallet, {
|
||||
'path': path,
|
||||
'password': password,
|
||||
'language': language,
|
||||
'nettype': nettype
|
||||
});
|
||||
|
||||
Future restoreFromSeed(
|
||||
{String path,
|
||||
String password,
|
||||
String seed,
|
||||
int nettype = 0,
|
||||
int restoreHeight = 0}) async =>
|
||||
compute<Map<String, Object>, void>(_restoreFromSeed, {
|
||||
'path': path,
|
||||
'password': password,
|
||||
'seed': seed,
|
||||
'nettype': nettype,
|
||||
'restoreHeight': restoreHeight
|
||||
});
|
||||
|
||||
Future restoreFromKeys(
|
||||
{String path,
|
||||
String password,
|
||||
String language,
|
||||
String address,
|
||||
String viewKey,
|
||||
String spendKey,
|
||||
int nettype = 0,
|
||||
int restoreHeight = 0}) async =>
|
||||
compute<Map<String, Object>, void>(_restoreFromKeys, {
|
||||
'path': path,
|
||||
'password': password,
|
||||
'language': language,
|
||||
'address': address,
|
||||
'viewKey': viewKey,
|
||||
'spendKey': spendKey,
|
||||
'nettype': nettype,
|
||||
'restoreHeight': restoreHeight
|
||||
});
|
||||
|
||||
Future<bool> isWalletExist({String path}) => compute(_isWalletExist, path);
|
|
@ -1,24 +0,0 @@
|
|||
name: cw_monero
|
||||
version: 0.0.2
|
||||
|
||||
environment:
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.6 <2.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
ffi: ^0.1.3
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
flutter:
|
||||
plugin:
|
||||
platforms:
|
||||
android:
|
||||
package: com.cakewallet.monero
|
||||
pluginClass: CwMoneroPlugin
|
||||
ios:
|
||||
pluginClass: CwMoneroPlugin
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:loki_wallet/src/domain/common/loki_transaction_priority.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/oxen_transaction_priority.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
@ -7,35 +7,35 @@ import 'package:provider/provider.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cw_monero/wallet.dart' as monero_wallet;
|
||||
import 'package:loki_wallet/router.dart';
|
||||
import 'package:oxen_coin/wallet.dart' as oxen_wallet;
|
||||
import 'package:oxen_wallet/router.dart';
|
||||
import 'theme_changer.dart';
|
||||
import 'themes.dart';
|
||||
import 'package:loki_wallet/src/domain/common/get_encryption_key.dart';
|
||||
import 'package:loki_wallet/src/domain/common/contact.dart';
|
||||
import 'package:loki_wallet/src/domain/common/node.dart';
|
||||
import 'package:loki_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:loki_wallet/src/domain/loki/transaction_description.dart';
|
||||
import 'package:loki_wallet/src/reactions/set_reactions.dart';
|
||||
import 'package:loki_wallet/src/stores/login/login_store.dart';
|
||||
import 'package:loki_wallet/src/stores/balance/balance_store.dart';
|
||||
import 'package:loki_wallet/src/stores/sync/sync_store.dart';
|
||||
import 'package:loki_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:loki_wallet/src/screens/root/root.dart';
|
||||
import 'package:loki_wallet/src/stores/authentication/authentication_store.dart';
|
||||
import 'package:loki_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:loki_wallet/src/stores/price/price_store.dart';
|
||||
import 'package:loki_wallet/src/domain/services/user_service.dart';
|
||||
import 'package:loki_wallet/src/domain/services/wallet_list_service.dart';
|
||||
import 'package:loki_wallet/src/domain/common/balance_display_mode.dart';
|
||||
import 'package:loki_wallet/src/domain/common/default_settings_migration.dart';
|
||||
import 'package:loki_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:loki_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:loki_wallet/src/domain/common/language.dart';
|
||||
import 'package:loki_wallet/src/stores/seed_language/seed_language_store.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/get_encryption_key.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/contact.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/node.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/wallet_info.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:oxen_wallet/src/domain/oxen/transaction_description.dart';
|
||||
import 'package:oxen_wallet/src/reactions/set_reactions.dart';
|
||||
import 'package:oxen_wallet/src/stores/login/login_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/balance/balance_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/sync/sync_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:oxen_wallet/src/screens/root/root.dart';
|
||||
import 'package:oxen_wallet/src/stores/authentication/authentication_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/price/price_store.dart';
|
||||
import 'package:oxen_wallet/src/domain/services/user_service.dart';
|
||||
import 'package:oxen_wallet/src/domain/services/wallet_list_service.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/balance_display_mode.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/default_settings_migration.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:oxen_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/language.dart';
|
||||
import 'package:oxen_wallet/src/stores/seed_language/seed_language_store.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
@ -88,7 +88,7 @@ void main() async {
|
|||
nodes: nodes,
|
||||
sharedPreferences: sharedPreferences,
|
||||
initialFiatCurrency: FiatCurrency.usd,
|
||||
initialTransactionPriority: LokiTransactionPriority.blink,
|
||||
initialTransactionPriority: OxenTransactionPriority.blink,
|
||||
initialBalanceDisplayMode: BalanceDisplayMode.availableBalance);
|
||||
final priceStore = PriceStore();
|
||||
final walletStore =
|
||||
|
@ -136,14 +136,14 @@ Future<void> initialSetup(
|
|||
Box<Node> nodes,
|
||||
AuthenticationStore authStore,
|
||||
int initialMigrationVersion = 1,
|
||||
WalletType initialWalletType = WalletType.loki}) async {
|
||||
WalletType initialWalletType = WalletType.oxen}) async {
|
||||
await walletListService.changeWalletManger(walletType: initialWalletType);
|
||||
await defaultSettingsMigration(
|
||||
version: initialMigrationVersion,
|
||||
sharedPreferences: sharedPreferences,
|
||||
nodes: nodes);
|
||||
await authStore.started();
|
||||
monero_wallet.onStartup();
|
||||
oxen_wallet.onStartup();
|
||||
}
|
||||
|
||||
class CakeWalletApp extends StatelessWidget {
|
||||
|
|
148
lib/router.dart
148
lib/router.dart
|
@ -4,89 +4,89 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:loki_wallet/routes.dart';
|
||||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/routes.dart';
|
||||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
|
||||
// MARK: Import domains
|
||||
|
||||
import 'package:loki_wallet/src/domain/common/contact.dart';
|
||||
import 'package:loki_wallet/src/domain/services/user_service.dart';
|
||||
import 'package:loki_wallet/src/domain/services/wallet_list_service.dart';
|
||||
import 'package:loki_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/changenow/changenow_exchange_provider.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart';
|
||||
import 'package:loki_wallet/src/domain/common/node.dart';
|
||||
import 'package:loki_wallet/src/domain/loki/transaction_description.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:loki_wallet/src/domain/loki/account.dart';
|
||||
import 'package:loki_wallet/src/domain/common/mnemotic_item.dart';
|
||||
import 'package:loki_wallet/src/domain/common/transaction_info.dart';
|
||||
import 'package:loki_wallet/src/domain/loki/subaddress.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/contact.dart';
|
||||
import 'package:oxen_wallet/src/domain/services/user_service.dart';
|
||||
import 'package:oxen_wallet/src/domain/services/wallet_list_service.dart';
|
||||
import 'package:oxen_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/changenow/changenow_exchange_provider.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/node.dart';
|
||||
import 'package:oxen_wallet/src/domain/oxen/transaction_description.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:oxen_wallet/src/domain/oxen/account.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/mnemotic_item.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/transaction_info.dart';
|
||||
import 'package:oxen_wallet/src/domain/oxen/subaddress.dart';
|
||||
|
||||
// MARK: Import stores
|
||||
|
||||
import 'package:loki_wallet/src/stores/authentication/authentication_store.dart';
|
||||
import 'package:loki_wallet/src/stores/node_list/node_list_store.dart';
|
||||
import 'package:loki_wallet/src/stores/auth/auth_store.dart';
|
||||
import 'package:loki_wallet/src/stores/balance/balance_store.dart';
|
||||
import 'package:loki_wallet/src/stores/send/send_store.dart';
|
||||
import 'package:loki_wallet/src/stores/subaddress_creation/subaddress_creation_store.dart';
|
||||
import 'package:loki_wallet/src/stores/subaddress_list/subaddress_list_store.dart';
|
||||
import 'package:loki_wallet/src/stores/sync/sync_store.dart';
|
||||
import 'package:loki_wallet/src/stores/user/user_store.dart';
|
||||
import 'package:loki_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:loki_wallet/src/stores/wallet_creation/wallet_creation_store.dart';
|
||||
import 'package:loki_wallet/src/stores/wallet_list/wallet_list_store.dart';
|
||||
import 'package:loki_wallet/src/stores/wallet_restoration/wallet_restoration_store.dart';
|
||||
import 'package:loki_wallet/src/stores/account_list/account_list_store.dart';
|
||||
import 'package:loki_wallet/src/stores/address_book/address_book_store.dart';
|
||||
import 'package:loki_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:loki_wallet/src/stores/wallet/wallet_keys_store.dart';
|
||||
import 'package:loki_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
|
||||
import 'package:loki_wallet/src/stores/exchange/exchange_store.dart';
|
||||
import 'package:loki_wallet/src/stores/rescan/rescan_wallet_store.dart';
|
||||
import 'package:loki_wallet/src/stores/price/price_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/authentication/authentication_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/node_list/node_list_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/auth/auth_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/balance/balance_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/send/send_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/subaddress_creation/subaddress_creation_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/subaddress_list/subaddress_list_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/sync/sync_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/user/user_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/wallet_creation/wallet_creation_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/wallet_list/wallet_list_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/wallet_restoration/wallet_restoration_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/account_list/account_list_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/address_book/address_book_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/wallet/wallet_keys_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/exchange/exchange_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/rescan/rescan_wallet_store.dart';
|
||||
import 'package:oxen_wallet/src/stores/price/price_store.dart';
|
||||
|
||||
// MARK: Import screens
|
||||
|
||||
import 'package:loki_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:loki_wallet/src/screens/nodes/new_node_page.dart';
|
||||
import 'package:loki_wallet/src/screens/nodes/nodes_list_page.dart';
|
||||
import 'package:loki_wallet/src/screens/receive/receive_page.dart';
|
||||
import 'package:loki_wallet/src/screens/subaddress/new_subaddress_page.dart';
|
||||
import 'package:loki_wallet/src/screens/wallet_list/wallet_list_page.dart';
|
||||
import 'package:loki_wallet/src/screens/new_wallet/new_wallet_page.dart';
|
||||
import 'package:loki_wallet/src/screens/setup_pin_code/setup_pin_code.dart';
|
||||
import 'package:loki_wallet/src/screens/restore/restore_options_page.dart';
|
||||
import 'package:loki_wallet/src/screens/restore/restore_wallet_options_page.dart';
|
||||
import 'package:loki_wallet/src/screens/restore/restore_wallet_from_seed_page.dart';
|
||||
import 'package:loki_wallet/src/screens/restore/restore_wallet_from_keys_page.dart';
|
||||
import 'package:loki_wallet/src/screens/send/send_page.dart';
|
||||
import 'package:loki_wallet/src/screens/disclaimer/disclaimer_page.dart';
|
||||
import 'package:loki_wallet/src/screens/seed_language/seed_language_page.dart';
|
||||
import 'package:loki_wallet/src/screens/transaction_details/transaction_details_page.dart';
|
||||
import 'package:loki_wallet/src/screens/accounts/account_page.dart';
|
||||
import 'package:loki_wallet/src/screens/accounts/account_list_page.dart';
|
||||
import 'package:loki_wallet/src/screens/address_book/address_book_page.dart';
|
||||
import 'package:loki_wallet/src/screens/address_book/contact_page.dart';
|
||||
import 'package:loki_wallet/src/screens/show_keys/show_keys_page.dart';
|
||||
import 'package:loki_wallet/src/screens/exchange_trade/exchange_confirm_page.dart';
|
||||
import 'package:loki_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
|
||||
import 'package:loki_wallet/src/screens/subaddress/subaddress_list_page.dart';
|
||||
import 'package:loki_wallet/src/screens/settings/change_language.dart';
|
||||
import 'package:loki_wallet/src/screens/restore/restore_wallet_from_seed_details.dart';
|
||||
import 'package:loki_wallet/src/screens/exchange/exchange_page.dart';
|
||||
import 'package:loki_wallet/src/screens/settings/settings.dart';
|
||||
import 'package:loki_wallet/src/screens/rescan/rescan_page.dart';
|
||||
import 'package:loki_wallet/src/screens/faq/faq_page.dart';
|
||||
import 'package:loki_wallet/src/screens/trade_details/trade_details_page.dart';
|
||||
import 'package:loki_wallet/src/screens/auth/create_unlock_page.dart';
|
||||
import 'package:loki_wallet/src/screens/auth/create_login_page.dart';
|
||||
import 'package:loki_wallet/src/screens/seed/create_seed_page.dart';
|
||||
import 'package:loki_wallet/src/screens/dashboard/create_dashboard_page.dart';
|
||||
import 'package:loki_wallet/src/screens/welcome/create_welcome_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/nodes/new_node_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/nodes/nodes_list_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/receive/receive_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/subaddress/new_subaddress_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/wallet_list/wallet_list_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/new_wallet/new_wallet_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/setup_pin_code/setup_pin_code.dart';
|
||||
import 'package:oxen_wallet/src/screens/restore/restore_options_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/restore/restore_wallet_options_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/restore/restore_wallet_from_seed_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/restore/restore_wallet_from_keys_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/send/send_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/disclaimer/disclaimer_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/seed_language/seed_language_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/transaction_details/transaction_details_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/accounts/account_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/accounts/account_list_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/address_book/address_book_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/address_book/contact_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/show_keys/show_keys_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/exchange_trade/exchange_confirm_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/subaddress/subaddress_list_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/settings/change_language.dart';
|
||||
import 'package:oxen_wallet/src/screens/restore/restore_wallet_from_seed_details.dart';
|
||||
import 'package:oxen_wallet/src/screens/exchange/exchange_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/settings/settings.dart';
|
||||
import 'package:oxen_wallet/src/screens/rescan/rescan_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/faq/faq_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/trade_details/trade_details_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/auth/create_unlock_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/auth/create_login_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/seed/create_seed_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/dashboard/create_dashboard_page.dart';
|
||||
import 'package:oxen_wallet/src/screens/welcome/create_welcome_page.dart';
|
||||
|
||||
class Router {
|
||||
static Route<dynamic> generateRoute(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
|
||||
const bitcoinAmountDivider = 100000000;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
|
||||
const bitcoinCashAmountDivider = 100000000;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:loki_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/enumerable_item.dart';
|
||||
|
||||
class BalanceDisplayMode extends EnumerableItem<int> with Serializable<int> {
|
||||
const BalanceDisplayMode({@required String title, @required int raw})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
|
||||
class BiometricAuth {
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import 'package:loki_wallet/src/domain/common/loki_transaction_priority.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/oxen_transaction_priority.dart';
|
||||
|
||||
// TODO: FIX calculation
|
||||
|
||||
double calculateEstimatedFee({LokiTransactionPriority priority}) {
|
||||
if (priority == LokiTransactionPriority.slow) {
|
||||
double calculateEstimatedFee({OxenTransactionPriority priority}) {
|
||||
if (priority == OxenTransactionPriority.slow) {
|
||||
// 2*<fee_per_output> + size*<fee_per_byte>
|
||||
return 0.00002459;
|
||||
}
|
||||
|
||||
if (priority == LokiTransactionPriority.blink) {
|
||||
if (priority == OxenTransactionPriority.blink) {
|
||||
// 2*<blink_fee_per_output> + size*<blink_fee_per_byte>
|
||||
return 0.0260216;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
|
||||
part 'contact.g.dart';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'crypto_currency.g.dart';
|
||||
|
@ -9,7 +9,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
|
|||
: super(title: title, raw: raw);
|
||||
|
||||
static const all = [
|
||||
CryptoCurrency.loki,
|
||||
CryptoCurrency.oxen,
|
||||
CryptoCurrency.ada,
|
||||
CryptoCurrency.bch,
|
||||
CryptoCurrency.bnb,
|
||||
|
@ -25,7 +25,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
|
|||
CryptoCurrency.xrp,
|
||||
CryptoCurrency.xmr
|
||||
];
|
||||
static const loki = CryptoCurrency(title: 'LOKI', raw: 0);
|
||||
static const oxen = CryptoCurrency(title: 'OXEN', raw: 0);
|
||||
static const ada = CryptoCurrency(title: 'ADA', raw: 1);
|
||||
static const bch = CryptoCurrency(title: 'BCH', raw: 2);
|
||||
static const bnb = CryptoCurrency(title: 'BNB', raw: 3);
|
||||
|
@ -45,7 +45,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
|
|||
static CryptoCurrency deserialize({int raw}) {
|
||||
switch (raw) {
|
||||
case 0:
|
||||
return CryptoCurrency.loki;
|
||||
return CryptoCurrency.oxen;
|
||||
case 1:
|
||||
return CryptoCurrency.ada;
|
||||
case 2:
|
||||
|
@ -81,8 +81,8 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
|
|||
|
||||
static CryptoCurrency fromString(String raw) {
|
||||
switch (raw.toLowerCase()) {
|
||||
case 'loki':
|
||||
return CryptoCurrency.loki;
|
||||
case 'oxen':
|
||||
return CryptoCurrency.oxen;
|
||||
case 'xmr':
|
||||
return CryptoCurrency.xmr;
|
||||
case 'ada':
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
|
||||
String cryptoToString(CryptoCurrency crypto) {
|
||||
switch (crypto) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:loki_wallet/src/domain/common/node.dart';
|
||||
import 'package:loki_wallet/src/domain/common/balance_display_mode.dart';
|
||||
import 'package:loki_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/common/node_list.dart';
|
||||
import 'package:loki_wallet/src/domain/common/loki_transaction_priority.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/node.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/balance_display_mode.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/node_list.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/oxen_transaction_priority.dart';
|
||||
|
||||
Future defaultSettingsMigration(
|
||||
{@required int version,
|
||||
|
@ -30,7 +30,7 @@ Future defaultSettingsMigration(
|
|||
await sharedPreferences.setString(
|
||||
'current_fiat_currency', FiatCurrency.usd.toString());
|
||||
await sharedPreferences.setInt(
|
||||
'current_fee_priority', LokiTransactionPriority.standard.raw);
|
||||
'current_fee_priority', OxenTransactionPriority.standard.raw);
|
||||
await sharedPreferences.setInt('current_balance_display_mode',
|
||||
BalanceDisplayMode.availableBalance.raw);
|
||||
await sharedPreferences.setBool('save_recipient_address', true);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:encrypt/encrypt.dart';
|
||||
import 'package:password/password.dart';
|
||||
import 'package:loki_wallet/.secrets.g.dart' as secrets;
|
||||
import 'package:oxen_wallet/.secrets.g.dart' as secrets;
|
||||
|
||||
String encrypt({String source, String key, int keyLength = 16}) {
|
||||
final _key = Key.fromUtf8(key);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/common/currency_formatter.dart';
|
||||
import 'package:loki_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/currency_formatter.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/fiat_currency.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
// TODO: USE COINMARKETCAP-PIPE
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/enumerable_item.dart';
|
||||
|
||||
class FiatCurrency extends EnumerableItem<String> with Serializable<String> {
|
||||
const FiatCurrency({String symbol}) : super(title: symbol, raw: symbol);
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:loki_wallet/src/domain/common/enumerable_item.dart';
|
||||
|
||||
class LokiTransactionPriority extends EnumerableItem<int> with Serializable<int> {
|
||||
const LokiTransactionPriority({String title, int raw})
|
||||
: super(title: title, raw: raw);
|
||||
|
||||
static const all = [
|
||||
LokiTransactionPriority.slow,
|
||||
LokiTransactionPriority.blink
|
||||
];
|
||||
|
||||
static const slow = LokiTransactionPriority(title: 'Slow', raw: 1);
|
||||
static const blink = LokiTransactionPriority(title: 'Blink', raw: 5);
|
||||
static const standard = slow;
|
||||
|
||||
static LokiTransactionPriority deserialize({int raw}) {
|
||||
switch (raw) {
|
||||
case 1:
|
||||
return slow;
|
||||
case 5:
|
||||
return blink;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
switch (this) {
|
||||
case LokiTransactionPriority.slow:
|
||||
return S.current.transaction_priority_slow;
|
||||
case LokiTransactionPriority.blink:
|
||||
return S.current.transaction_priority_fastest; // TODO: ADD BLINK
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:loki_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/enumerable_item.dart';
|
||||
|
||||
class MoneroTransactionPriority extends EnumerableItem<int> with Serializable<int> {
|
||||
const MoneroTransactionPriority({String title, int raw})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:loki_wallet/src/domain/common/digest_request.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/digest_request.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
import 'package:loki_wallet/src/domain/common/node.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/node.dart';
|
||||
|
||||
Future<List<Node>> loadDefaultNodes() async {
|
||||
final nodesRaw = await rootBundle.loadString('assets/node_list.yml');
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/enumerable_item.dart';
|
||||
|
||||
class OxenTransactionPriority extends EnumerableItem<int> with Serializable<int> {
|
||||
const OxenTransactionPriority({String title, int raw})
|
||||
: super(title: title, raw: raw);
|
||||
|
||||
static const all = [
|
||||
OxenTransactionPriority.slow,
|
||||
OxenTransactionPriority.blink
|
||||
];
|
||||
|
||||
static const slow = OxenTransactionPriority(title: 'Slow', raw: 1);
|
||||
static const blink = OxenTransactionPriority(title: 'Blink', raw: 5);
|
||||
static const standard = blink;
|
||||
|
||||
static OxenTransactionPriority deserialize({int raw}) {
|
||||
switch (raw) {
|
||||
case 1:
|
||||
return slow;
|
||||
case 5:
|
||||
return blink;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
switch (this) {
|
||||
case OxenTransactionPriority.slow:
|
||||
return S.current.transaction_priority_slow;
|
||||
case OxenTransactionPriority.blink:
|
||||
return S.current.transaction_priority_fastest; // TODO: ADD BLINK
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cw_monero/transaction_history.dart' as transaction_history;
|
||||
import 'package:cw_monero/structs/pending_transaction.dart';
|
||||
import 'package:loki_wallet/src/domain/monero/monero_amount_format.dart';
|
||||
import 'package:oxen_coin/transaction_history.dart' as transaction_history;
|
||||
import 'package:oxen_coin/structs/pending_transaction.dart';
|
||||
import 'package:oxen_wallet/src/domain/monero/monero_amount_format.dart';
|
||||
|
||||
class PendingTransaction {
|
||||
PendingTransaction(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
|
||||
abstract class SyncStatus {
|
||||
const SyncStatus();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:loki_wallet/src/domain/common/transaction_info.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/transaction_info.dart';
|
||||
|
||||
abstract class TransactionHistory {
|
||||
Observable<List<TransactionInfo>> transactions;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:loki_wallet/src/domain/loki/loki_amount_format.dart';
|
||||
import 'package:cw_monero/structs/transaction_info_row.dart';
|
||||
import 'package:loki_wallet/src/domain/common/parseBoolFromString.dart';
|
||||
import 'package:loki_wallet/src/domain/common/transaction_direction.dart';
|
||||
import 'package:loki_wallet/src/domain/common/format_amount.dart';
|
||||
import 'package:oxen_wallet/src/domain/oxen/oxen_amount_format.dart';
|
||||
import 'package:oxen_coin/structs/transaction_info_row.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/parseBoolFromString.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/transaction_direction.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/format_amount.dart';
|
||||
|
||||
class TransactionInfo {
|
||||
TransactionInfo(this.id, this.height, this.direction, this.date,
|
||||
|
@ -41,7 +41,7 @@ class TransactionInfo {
|
|||
|
||||
String _fiatAmount;
|
||||
|
||||
String amountFormatted() => '${formatAmount(lokiAmountToString(amount: amount))} LOKI';
|
||||
String amountFormatted() => '${formatAmount(oxenAmountToString(amount: amount))} OXEN';
|
||||
|
||||
String fiatAmount() => _fiatAmount ?? '';
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:loki_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:loki_wallet/src/domain/common/transaction_history.dart';
|
||||
import 'package:loki_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:loki_wallet/src/domain/common/transaction_creation_credentials.dart';
|
||||
import 'package:loki_wallet/src/domain/common/pending_transaction.dart';
|
||||
import 'package:loki_wallet/src/domain/common/balance.dart';
|
||||
import 'package:loki_wallet/src/domain/common/node.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/transaction_history.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/transaction_creation_credentials.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/pending_transaction.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/balance.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/node.dart';
|
||||
|
||||
abstract class Wallet {
|
||||
WalletType getType();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/wallet_type.dart';
|
||||
|
||||
class WalletDescription {
|
||||
WalletDescription({this.name, this.type});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'wallet_info.g.dart';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:loki_wallet/src/domain/common/wallet.dart';
|
||||
import 'package:loki_wallet/src/domain/common/wallet_description.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/wallet.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/wallet_description.dart';
|
||||
|
||||
abstract class WalletsManager {
|
||||
Future<Wallet> create(String name, String password, String language);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
|
||||
const dashAmountDivider = 100000000;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_amount_format.dart';
|
||||
|
||||
const ethereumAmountDivider = 1000000000000000000;
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import 'dart:convert';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_not_found_exeption.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_not_found_exeption.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:loki_wallet/.secrets.g.dart' as secrets;
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_provider.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/changenow/changenow_request.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_not_created_exeption.dart';
|
||||
import 'package:oxen_wallet/.secrets.g.dart' as secrets;
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_provider.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/changenow/changenow_request.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_not_created_exeption.dart';
|
||||
|
||||
class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||
ChangeNowExchangeProvider()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_request.dart';
|
||||
|
||||
class ChangeNowRequest extends TradeRequest {
|
||||
ChangeNowRequest(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
|
||||
class ExchangePair {
|
||||
ExchangePair({this.from, this.to, this.reverse = true});
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
|
||||
abstract class ExchangeProvider {
|
||||
ExchangeProvider({this.pairList});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:loki_wallet/src/domain/common/enumerable_item.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/enumerable_item.dart';
|
||||
|
||||
class ExchangeProviderDescription extends EnumerableItem<int>
|
||||
with Serializable<int> {
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
import 'dart:convert';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_not_found_exeption.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_not_found_exeption.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_provider.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/morphtoken/morphtoken_request.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_not_created_exeption.dart';
|
||||
import 'package:loki_wallet/src/domain/monero/monero_amount_format.dart';
|
||||
import 'package:loki_wallet/src/domain/bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:loki_wallet/src/domain/bitcoin_cash/bitcoin_cash_amount_format.dart';
|
||||
import 'package:loki_wallet/src/domain/dash/dash_amount_format.dart';
|
||||
import 'package:loki_wallet/src/domain/ethereum/ethereum_amount_format.dart';
|
||||
import 'package:loki_wallet/src/domain/litecoin/litecoin_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_pair.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_provider.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/limits.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/morphtoken/morphtoken_request.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_not_created_exeption.dart';
|
||||
import 'package:oxen_wallet/src/domain/monero/monero_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/bitcoin/bitcoin_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/bitcoin_cash/bitcoin_cash_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/dash/dash_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/ethereum/ethereum_amount_format.dart';
|
||||
import 'package:oxen_wallet/src/domain/litecoin/litecoin_amount_format.dart';
|
||||
|
||||
class MorphTokenExchangeProvider extends ExchangeProvider {
|
||||
MorphTokenExchangeProvider({@required this.trades})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_request.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_request.dart';
|
||||
|
||||
class MorphTokenRequest extends TradeRequest {
|
||||
MorphTokenRequest(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:loki_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:loki_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:loki_wallet/src/domain/common/format_amount.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/trade_state.dart';
|
||||
import 'package:oxen_wallet/src/domain/common/format_amount.dart';
|
||||
|
||||
part 'trade.g.dart';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:loki_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
|
||||
class TradeNotCreatedException implements Exception {
|
||||
TradeNotCreatedException(this.provider, {this.description = ''});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:loki_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:loki_wallet/generated/i18n.dart';
|
||||
import 'package:oxen_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:oxen_wallet/generated/i18n.dart';
|
||||
|
||||
class TradeNotFoundException implements Exception {
|
||||
TradeNotFoundException(this.tradeId, {this.provider, this.description = ''});
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue