updates [skip ci]

This commit is contained in:
Matthew Fosse 2024-06-08 14:26:48 +02:00
parent fe7fc63ba9
commit f354ae8c7d
6 changed files with 62 additions and 2 deletions

View file

@ -3,6 +3,8 @@ import 'dart:math';
import 'package:collection/collection.dart';
import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';
import 'package:cw_core/cake_hive.dart';
import 'package:cw_core/mweb_utxo.dart';
import 'package:fixnum/fixnum.dart';
import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
@ -77,6 +79,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
}
final bitcoin.HDWallet mwebHd;
late final Box<MwebUtxo> mwebUtxosBox;
Timer? _syncTimer;
static Future<LitecoinWallet> create(
@ -140,7 +143,9 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
);
}
final Map<String, Utxo> mwebUtxos = {};
int mwebUtxosHeight = 0;
int lastMwebUtxosHeight = 2699272;
@action
@override
@ -187,8 +192,18 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
processMwebUtxos();
}
final Map<String, Utxo> mwebUtxos = {};
int lastMwebUtxosHeight = 0;
Future<void> initMwebUtxosBox() async {
final boxName = "${walletInfo.name.replaceAll(" ", "_")}_${MwebUtxo.boxName}";
mwebUtxosBox = await CakeHive.openBox<MwebUtxo>(boxName);
}
// final Map<String, MwebUtxo> mwebUtxo = MwebUtxo();
@override
Future<void> init() async {
await initMwebUtxosBox();
}
Future<void> processMwebUtxos() async {
final stub = await CwMweb.stub();
@ -487,4 +502,9 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
await updateBalance();
});
}
@override
Future<void> save() async {
await super.save();
}
}

View file

@ -18,3 +18,4 @@ const SPL_TOKEN_TYPE_ID = 16;
const DERIVATION_INFO_TYPE_ID = 17;
const TRON_TOKEN_TYPE_ID = 18;
const HARDWARE_WALLET_TYPE_TYPE_ID = 19;
const MWEB_UTXO_TYPE_ID = 20;

View file

@ -0,0 +1,25 @@
import 'package:cw_core/hive_type_ids.dart';
import 'package:hive/hive.dart';
// part 'mweb_utxo.g.dart';
@HiveType(typeId: MWEB_UTXO_TYPE_ID)
class MwebUtxo extends HiveObject {
MwebUtxo({
required this.address,
this.accountIndex,
required this.label,
});
static const typeId = MWEB_UTXO_TYPE_ID;
static const boxName = 'MwebUtxo';
@HiveField(0)
int? accountIndex;
@HiveField(1, defaultValue: '')
String address;
@HiveField(2, defaultValue: '')
String label;
}

View file

@ -40,5 +40,6 @@ class CwMwebPlugin: FlutterPlugin, MethodCallHandler {
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
server?.stop()
server = null
}
}

View file

@ -49,4 +49,10 @@ public class CwMwebPlugin: NSObject, FlutterPlugin {
result(FlutterMethodNotImplemented)
}
}
deinit {
// Perform cleanup tasks
CwMwebPlugin.server?.stop()
CwMwebPlugin.server = nil
}
}

View file

@ -0,0 +1,7 @@
git clone https://github.com/ltcmweb/mwebd
cd mwebd
go install github.com/ltcmweb/mwebd/cmd/mwebd@latest
gomobile bind -target=android -androidapi 19 github.com/ltcmweb/mwebd
mkdir -p ../../../cw_mweb/android/libs/
mv ./mwebd.aar $_