update moneroc hash

WIP fixes for zano
This commit is contained in:
Czarek Nakamoto 2024-12-20 09:22:09 +01:00
parent be786635b6
commit 80cb8453c8
9 changed files with 36 additions and 20 deletions

View file

@ -511,8 +511,8 @@ packages:
dependency: "direct main"
description:
path: "impls/monero.dart"
ref: 4672390caf1c9cd58351ce1869f3ed656ae67720
resolved-ref: 4672390caf1c9cd58351ce1869f3ed656ae67720
ref: "e3cafc9aa0f06d4cecde96f28c497e7ab686be90"
resolved-ref: "e3cafc9aa0f06d4cecde96f28c497e7ab686be90"
url: "https://github.com/mrcyjanek/monero_c"
source: git
version: "0.0.0"

View file

@ -25,7 +25,7 @@ dependencies:
monero:
git:
url: https://github.com/mrcyjanek/monero_c
ref: 4672390caf1c9cd58351ce1869f3ed656ae67720
ref: e3cafc9aa0f06d4cecde96f28c497e7ab686be90
path: impls/monero.dart
mutex: ^3.1.0
ledger_flutter_plus: ^1.4.1

View file

@ -471,8 +471,8 @@ packages:
dependency: "direct main"
description:
path: "impls/monero.dart"
ref: 4672390caf1c9cd58351ce1869f3ed656ae67720
resolved-ref: 4672390caf1c9cd58351ce1869f3ed656ae67720
ref: "e3cafc9aa0f06d4cecde96f28c497e7ab686be90"
resolved-ref: "e3cafc9aa0f06d4cecde96f28c497e7ab686be90"
url: "https://github.com/mrcyjanek/monero_c"
source: git
version: "0.0.0"

View file

@ -25,7 +25,7 @@ dependencies:
monero:
git:
url: https://github.com/mrcyjanek/monero_c
ref: 4672390caf1c9cd58351ce1869f3ed656ae67720 # monero_c hash
ref: e3cafc9aa0f06d4cecde96f28c497e7ab686be90 # monero_c hash
path: impls/monero.dart
mutex: ^3.1.0

View file

@ -44,7 +44,6 @@ abstract class ZanoWalletBase extends WalletBase<ZanoBalance, ZanoTransactionHis
static const int _autoSaveIntervalSeconds = 30;
static const int _pollIntervalMilliseconds = 2000;
static const int _maxLoadAssetsRetries = 5;
static const DO_NOT_MERGE_hardcodedNodeUri = '195.201.107.230:33340';
@override
void setPassword(String password) {
@ -124,19 +123,21 @@ abstract class ZanoWalletBase extends WalletBase<ZanoBalance, ZanoTransactionHis
static Future<ZanoWallet> create({required WalletCredentials credentials}) async {
final wallet = ZanoWallet(credentials.walletInfo!, credentials.password!);
await wallet.connectToNode(node: Node()..uriRaw = DO_NOT_MERGE_hardcodedNodeUri);
await wallet.initWallet();
final path = await pathForWallet(name: credentials.name, type: credentials.walletInfo!.type);
final createWalletResult = await wallet.createWallet(path, credentials.password!);
await wallet.initWallet();
await wallet.parseCreateWalletResult(createWalletResult);
await wallet.init(createWalletResult.wi.address);
return wallet;
}
static Future<ZanoWallet> restore({required ZanoRestoreWalletFromSeedCredentials credentials}) async {
final wallet = ZanoWallet(credentials.walletInfo!, credentials.password!);
await wallet.connectToNode(node: Node()..uriRaw = DO_NOT_MERGE_hardcodedNodeUri);
final wallet = ZanoWallet(credentials.walletInfo!, credentials.password!); await wallet.initWallet();
await wallet.initWallet();
final path = await pathForWallet(name: credentials.name, type: credentials.walletInfo!.type);
final createWalletResult = await wallet.restoreWalletFromSeed(path, credentials.password!, credentials.mnemonic);
await wallet.initWallet();
await wallet.parseCreateWalletResult(createWalletResult);
await wallet.init(createWalletResult.wi.address);
return wallet;
@ -145,8 +146,9 @@ abstract class ZanoWalletBase extends WalletBase<ZanoBalance, ZanoTransactionHis
static Future<ZanoWallet> open({required String name, required String password, required WalletInfo walletInfo}) async {
final path = await pathForWallet(name: name, type: walletInfo.type);
final wallet = ZanoWallet(walletInfo, password);
await wallet.connectToNode(node: Node()..uriRaw = DO_NOT_MERGE_hardcodedNodeUri);
await wallet.initWallet();
final createWalletResult = await wallet.loadWallet(path, password);
await wallet.initWallet();
await wallet.parseCreateWalletResult(createWalletResult);
await wallet.init(createWalletResult.wi.address);
return wallet;

View file

@ -4,6 +4,7 @@ import 'dart:isolate';
import 'package:cw_core/pathForWallet.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_zano/api/consts.dart';
import 'package:cw_zano/api/model/asset_id_params.dart';
import 'package:cw_zano/api/model/create_wallet_result.dart';
@ -54,14 +55,18 @@ mixin ZanoWalletApi {
info('close_wallet result $result');
}
Future<bool> setupNode(String nodeUri) async {
info('init $nodeUri');
Future<bool> initWallet() async {
// pathForWallet(name: , type: type)
final result = zano.PlainWallet_init(nodeUri, "", 0);
info('init result $result');
final result = zano.PlainWallet_init("", "", 0);
printV(result);
return result == "OK";
}
Future<bool> setupNode(String nodeUrl) async {
await _setupNode(hWallet, nodeUrl);
return true;
}
Future<GetWalletInfoResult> getWalletInfo() async {
final json = await _getWalletInfo(hWallet);
final result = GetWalletInfoResult.fromJson(jsonDecode(json) as Map<String, dynamic>);
@ -276,7 +281,7 @@ mixin ZanoWalletApi {
return result;
}
Future<CreateWalletResult> loadWallet(String path, String password, [int attempt = 0]) async {
Future<CreateWalletResult>loadWallet(String path, String password, [int attempt = 0]) async {
info('load_wallet1 path $path password ${_shorten(password)}');
final String json;
try {
@ -450,9 +455,18 @@ Future<String> _getWalletInfo(int hWallet) async {
return json;
}
Future<String> _setupNode(int hWallet, String nodeUrl) async {
final resp = await callSyncMethod("reset_connection_url", hWallet, nodeUrl);
printV(resp);
final resp2 = await callSyncMethod("configure", hWallet, r'{"postponed_run_wallet": false}');
printV(resp2);
return "OK";
}
Future<String> _closeWallet(int hWallet) async {
final str = await Isolate.run(() async {
return zano.PlainWallet_closeWallet(hWallet);
});
printV("Closing wallet: $str");
return str;
}

View file

@ -476,8 +476,8 @@ packages:
dependency: "direct main"
description:
path: "impls/monero.dart"
ref: 4672390caf1c9cd58351ce1869f3ed656ae67720
resolved-ref: 4672390caf1c9cd58351ce1869f3ed656ae67720
ref: "e3cafc9aa0f06d4cecde96f28c497e7ab686be90"
resolved-ref: "e3cafc9aa0f06d4cecde96f28c497e7ab686be90"
url: "https://github.com/mrcyjanek/monero_c"
source: git
version: "0.0.0"

View file

@ -26,7 +26,7 @@ dependencies:
monero:
git:
url: https://github.com/mrcyjanek/monero_c
ref: 4672390caf1c9cd58351ce1869f3ed656ae67720 # monero_c hash
ref: e3cafc9aa0f06d4cecde96f28c497e7ab686be90 # monero_c hash
path: impls/monero.dart
dev_dependencies:
flutter_test:

View file

@ -8,7 +8,7 @@ if [[ ! -d "monero_c" ]];
then
git clone https://github.com/mrcyjanek/monero_c --branch master
cd monero_c
git checkout 4672390caf1c9cd58351ce1869f3ed656ae67720
git checkout e3cafc9aa0f06d4cecde96f28c497e7ab686be90
git reset --hard
git submodule update --init --force --recursive
./apply_patches.sh monero