Build 330

Customizable diversified addresses
This commit is contained in:
Hanh 2022-12-20 19:58:26 +08:00
parent 0e9c37a5a1
commit 21c4fefd81
11 changed files with 47 additions and 78 deletions

View File

@ -3,4 +3,3 @@ build/**
misc/build-dir
misc/.flatpak-builder
misc/root
**/.git/**

View File

@ -47,6 +47,9 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data
android:name="com.tekartik.sqflite.wal_enabled"
android:value="true" />
<service android:name="com.pravera.flutter_foreground_task.service.ForegroundService" />
</application>
<queries>

View File

@ -13,7 +13,6 @@ if [ "$DL_DIR" == "" ]; then
DL_DIR="/tmp"
fi
sudo pacman -Sy --noconfirm unzip jdk8-openjdk wget
wget -qP $DL_DIR -N https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip

View File

@ -322,11 +322,11 @@ abstract class _ActiveAccount with Store {
}
String newAddress() {
return WarpApi.newDiversifiedAddress();
return WarpApi.newDiversifiedAddress(settings.uaType);
}
String getAddress(bool t, bool s, bool o) {
return WarpApi.getAddress(coin, id, (t ? 1 : 0) | (s ? 2 : 0) | (o ? 4 : 0));
String getAddress(int uaType) {
return WarpApi.getAddress(coin, id, uaType);
}
@computed

View File

@ -41,10 +41,17 @@ abstract class CoinBase {
dbFullPath = _getFullPath(dbDir);
}
Future<void> open() async {
Future<void> open(bool wal) async {
print("Opening DB ${dbFullPath}");
// schema handled in backend
db = await openDatabase(dbFullPath/*, onCreate: createSchema, version: 1*/);
db = await openDatabase(dbFullPath, onConfigure: (db) async {
if (wal)
await db.rawQuery("PRAGMA journal_mode=WAL");
});
}
Future<void> close() async {
await db.close();
}
Future<bool> tryImport(PlatformFile file) async {
@ -69,8 +76,9 @@ abstract class CoinBase {
Future<void> export(BuildContext context, String dbPath) async {
final path = _getFullPath(dbPath);
WarpApi.disableWAL(path);
db = await openDatabase(path);
db = await openDatabase(path, onConfigure: (db) async {
await db.rawQuery("PRAGMA journal_mode=off");
});
await db.close();
await exportFile(context, path, dbName);
}

View File

@ -348,7 +348,8 @@ class ZWalletAppState extends State<ZWalletApp> {
final dbPath = await getDbPath();
for (var coin in coins) {
coin.init(dbPath);
WarpApi.createDb(coin.dbFullPath);
await coin.open(false);
await coin.close();
}
if (exportDb) {
@ -367,7 +368,6 @@ class ZWalletAppState extends State<ZWalletApp> {
_setProgress(0.1 * (coin.coin+1), 'Initializing ${coin.ticker}');
WarpApi.migrateWallet(coin.coin, coin.dbFullPath);
WarpApi.initWallet(coin.coin, coin.dbFullPath);
await coin.open();
}
for (var s in settings.servers) {
@ -377,6 +377,11 @@ class ZWalletAppState extends State<ZWalletApp> {
WarpApi.migrateData(s.coin);
}
}
for (var coin in coins) {
await coin.open(true);
}
_setProgress(0.6, 'Loading Account Data');
await accounts.refresh();
_setProgress(0.7, 'Restoring Active Account');

View File

@ -107,7 +107,6 @@ class PaymentURIState extends State<PaymentURIPage> {
final amount = amountKey.currentState!.amount;
final memo = _memoController.text;
final String _qrText;
if (amount > 0) {
return WarpApi.makePaymentURI(address, amount, memo);
}
@ -123,7 +122,7 @@ class PaymentURIState extends State<PaymentURIPage> {
if (types == null) { return; }
setState(() {
if (types.isEmpty) {
address = active.getAddress(true, true, true);
address = active.getAddress(7);
}
else
address = _decodeCheckboxes(types);
@ -132,13 +131,11 @@ class PaymentURIState extends State<PaymentURIPage> {
}
String _decodeCheckboxes(List<String> types) {
var t = false;
var s = false;
var o = false;
if (types.contains("T")) t = true;
if (types.contains("S")) s = true;
if (types.contains("O")) o = true;
return active.getAddress(t, s, o);
var uaType = 0;
if (types.contains("T")) uaType |= 1;
if (types.contains("S")) uaType |= 2;
if (types.contains("O")) uaType |= 4;
return active.getAddress(uaType);
}
void _reset() {

@ -1 +1 @@
Subproject commit 37d81e586a35cfdca75e79464cd6fa3aa961431b
Subproject commit 9ae96e7d88bc3bd60c21558062a29c571e27eb09

View File

@ -64,10 +64,6 @@ class WarpApi {
throw UnsupportedError('This platform is not supported.');
}
static void createDb(String dbPath) {
unwrapResultU8(warp_api_lib.create_db(toNative(dbPath)));
}
static void migrateWallet(int coin, String dbPath) {
unwrapResultU8(warp_api_lib.migrate_db(coin, toNative(dbPath)));
}
@ -168,8 +164,8 @@ class WarpApi {
0;
}
static String newDiversifiedAddress() {
final address = warp_api_lib.new_diversified_address();
static String newDiversifiedAddress(int uaType) {
final address = warp_api_lib.new_diversified_address(uaType);
return unwrapResultString(address);
}
@ -395,10 +391,6 @@ class WarpApi {
return kp;
}
static void disableWAL(String dbPath) {
warp_api_lib.disable_wal(dbPath.toNativeUtf8().cast<Int8>());
}
static bool hasCuda() {
return warp_api_lib.has_cuda() != 0;
}

View File

@ -68,19 +68,6 @@ class NativeLibrary {
late final _dart_init_wallet _init_wallet =
_init_wallet_ptr.asFunction<_dart_init_wallet>();
CResult_u8 create_db(
ffi.Pointer<ffi.Int8> db_path,
) {
return _create_db(
db_path,
);
}
late final _create_db_ptr =
_lookup<ffi.NativeFunction<_c_create_db>>('create_db');
late final _dart_create_db _create_db =
_create_db_ptr.asFunction<_dart_create_db>();
CResult_u8 migrate_db(
int coin,
ffi.Pointer<ffi.Int8> db_path,
@ -381,8 +368,12 @@ class NativeLibrary {
late final _dart_valid_address _valid_address =
_valid_address_ptr.asFunction<_dart_valid_address>();
CResult_____c_char new_diversified_address() {
return _new_diversified_address();
CResult_____c_char new_diversified_address(
int ua_type,
) {
return _new_diversified_address(
ua_type,
);
}
late final _new_diversified_address_ptr =
@ -901,19 +892,6 @@ class NativeLibrary {
late final _dart_derive_zip32 _derive_zip32 =
_derive_zip32_ptr.asFunction<_dart_derive_zip32>();
void disable_wal(
ffi.Pointer<ffi.Int8> db_path,
) {
return _disable_wal(
db_path,
);
}
late final _disable_wal_ptr =
_lookup<ffi.NativeFunction<_c_disable_wal>>('disable_wal');
late final _dart_disable_wal _disable_wal =
_disable_wal_ptr.asFunction<_dart_disable_wal>();
int has_cuda() {
return _has_cuda();
}
@ -1014,14 +992,6 @@ typedef _dart_init_wallet = CResult_u8 Function(
ffi.Pointer<ffi.Int8> db_path,
);
typedef _c_create_db = CResult_u8 Function(
ffi.Pointer<ffi.Int8> db_path,
);
typedef _dart_create_db = CResult_u8 Function(
ffi.Pointer<ffi.Int8> db_path,
);
typedef _c_migrate_db = CResult_u8 Function(
ffi.Uint8 coin,
ffi.Pointer<ffi.Int8> db_path,
@ -1220,9 +1190,13 @@ typedef _dart_valid_address = int Function(
ffi.Pointer<ffi.Int8> address,
);
typedef _c_new_diversified_address = CResult_____c_char Function();
typedef _c_new_diversified_address = CResult_____c_char Function(
ffi.Uint8 ua_type,
);
typedef _dart_new_diversified_address = CResult_____c_char Function();
typedef _dart_new_diversified_address = CResult_____c_char Function(
int ua_type,
);
typedef _c_get_latest_height = CResult_u32 Function();
@ -1558,14 +1532,6 @@ typedef _dart_derive_zip32 = CResult_____c_char Function(
int address,
);
typedef _c_disable_wal = ffi.Void Function(
ffi.Pointer<ffi.Int8> db_path,
);
typedef _dart_disable_wal = void Function(
ffi.Pointer<ffi.Int8> db_path,
);
typedef _c_has_cuda = ffi.Int8 Function();
typedef _dart_has_cuda = int Function();

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.2.17+329
version: 1.2.17+330
environment:
sdk: ">=2.12.0 <3.0.0"