From 95aec7b9449be499563e89cc9e943deef1c50dd4 Mon Sep 17 00:00:00 2001 From: Hanh Date: Fri, 4 Aug 2023 11:20:07 +1000 Subject: [PATCH] Allow custom fee --- idl/data.fbs | 7 + lib/accounts.dart | 1 - lib/contact.dart | 2 +- lib/generated/intl/messages_en.dart | 1 + lib/generated/intl/messages_es.dart | 1 + lib/generated/intl/messages_fr.dart | 1 + lib/generated/l10n.dart | 10 ++ lib/home.dart | 72 +++++---- lib/l10n/intl_en.arb | 3 +- lib/l10n/intl_es.arb | 3 +- lib/l10n/intl_fr.arb | 3 +- lib/main.dart | 2 +- lib/pools.dart | 3 +- lib/send.dart | 2 +- lib/settings.dart | 14 ++ lib/store.dart | 17 +++ native/zcash-sync | 2 +- .../warp_api_ffi/lib/data_fb_generated.dart | 137 ++++++++++++++++++ packages/warp_api_ffi/lib/warp_api.dart | 58 +++++--- .../warp_api_ffi/lib/warp_api_generated.dart | 52 ++++++- packages/warp_api_ffi/pubspec.yaml | 2 +- pubspec.yaml | 2 +- 22 files changed, 336 insertions(+), 59 deletions(-) diff --git a/idl/data.fbs b/idl/data.fbs index 8fae1452b..d0da9b420 100644 --- a/idl/data.fbs +++ b/idl/data.fbs @@ -226,3 +226,10 @@ table TxReport { fee:uint64; privacy_level:uint8; } + +table Fee { + fee:uint64; + min_fee:uint64; + max_fee:uint64; + scheme:uint8; +} diff --git a/lib/accounts.dart b/lib/accounts.dart index 6d8ebee31..b801c46d4 100644 --- a/lib/accounts.dart +++ b/lib/accounts.dart @@ -49,7 +49,6 @@ class AccountList { (a) => Account(coin.coin, a.id, a.name!, a.keyType, a.balance, 0)) .toList(); final id = WarpApi.getActiveAccountId(coin.coin); - print("active $id"); if (id != 0) { accounts.firstWhere((a) => a.id == id).active = true; } diff --git a/lib/contact.dart b/lib/contact.dart index 4915c1712..d45a6bb8b 100644 --- a/lib/contact.dart +++ b/lib/contact.dart @@ -89,7 +89,7 @@ class ContactsState extends State { _onCommit() async { try { - final txPlan = WarpApi.commitUnsavedContacts(settings.anchorOffset); + final txPlan = WarpApi.commitUnsavedContacts(settings.anchorOffset, settings.feeRule); Navigator.of(context).pushNamed('/txplan', arguments: txPlan); } on String catch (msg) { showSnackBar(msg, error: true); diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index abe846c95..703c10666 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -236,6 +236,7 @@ class MessageLookup extends MessageLookupByLibrary { "error": m7, "excludedNotes": MessageLookupByLibrary.simpleMessage("Excluded Notes"), "expert": MessageLookupByLibrary.simpleMessage("Expert"), + "fee": MessageLookupByLibrary.simpleMessage("Fee"), "fileSaved": MessageLookupByLibrary.simpleMessage("File saved"), "fromPool": MessageLookupByLibrary.simpleMessage("From Pool"), "fromto": MessageLookupByLibrary.simpleMessage("From/To"), diff --git a/lib/generated/intl/messages_es.dart b/lib/generated/intl/messages_es.dart index 709de434e..2de03e0eb 100644 --- a/lib/generated/intl/messages_es.dart +++ b/lib/generated/intl/messages_es.dart @@ -241,6 +241,7 @@ class MessageLookup extends MessageLookupByLibrary { "excludedNotes": MessageLookupByLibrary.simpleMessage("Notas excluidas"), "expert": MessageLookupByLibrary.simpleMessage("Modo Experto"), + "fee": MessageLookupByLibrary.simpleMessage("Fee"), "fileSaved": MessageLookupByLibrary.simpleMessage("Archivo guardado"), "fromPool": MessageLookupByLibrary.simpleMessage("Del Suministro"), "fromto": MessageLookupByLibrary.simpleMessage("Rem/Dest."), diff --git a/lib/generated/intl/messages_fr.dart b/lib/generated/intl/messages_fr.dart index 7f728d794..8580efbcf 100644 --- a/lib/generated/intl/messages_fr.dart +++ b/lib/generated/intl/messages_fr.dart @@ -240,6 +240,7 @@ class MessageLookup extends MessageLookupByLibrary { "error": m7, "excludedNotes": MessageLookupByLibrary.simpleMessage("Billets exclus"), "expert": MessageLookupByLibrary.simpleMessage("Expert"), + "fee": MessageLookupByLibrary.simpleMessage("Fee"), "fileSaved": MessageLookupByLibrary.simpleMessage("File saved"), "fromPool": MessageLookupByLibrary.simpleMessage("A partir du Fond"), "fromto": MessageLookupByLibrary.simpleMessage("Env/Dest."), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 90fc1a240..36b33a4e5 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -3171,6 +3171,16 @@ class S { args: [], ); } + + /// `Fee` + String get fee { + return Intl.message( + 'Fee', + name: 'fee', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/home.dart b/lib/home.dart index f5f95e1ee..4019fd498 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -364,43 +364,61 @@ class HomeInnerState extends State if (!WarpApi.isValidTransparentKey(k)) return s.invalidKey; return null; }; + final formKey = GlobalKey(); final confirmed = await showDialog( context: context, barrierDismissible: false, builder: (context) => AlertDialog( title: Text(s.sweep), content: SingleChildScrollView( + child: FormBuilder( + key: formKey, child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - TextFormField( - decoration: InputDecoration(labelText: s.transparentKey), - controller: keyController, - validator: checkKey, + mainAxisSize: MainAxisSize.min, + children: [ + FormBuilderTextField( + name: 'key', + decoration: + InputDecoration(labelText: s.transparentKey), + controller: keyController, + validator: checkKey, + ), + FormBuilderRadioGroup( + orientation: OptionsOrientation.horizontal, + decoration: InputDecoration(labelText: s.toPool), + name: 'pool', + initialValue: 0, + onChanged: (v) { + pool = v ?? 0; + }, + options: [ + FormBuilderFieldOption( + child: Text('T'), value: 0), + FormBuilderFieldOption( + child: Text('S'), value: 1), + if (active.coinDef.supportsUA) + FormBuilderFieldOption( + child: Text('O'), value: 2), + ]), + ], ), - FormBuilderRadioGroup( - orientation: OptionsOrientation.horizontal, - decoration: InputDecoration(labelText: s.toPool), - name: 'pool', - initialValue: 0, - onChanged: (v) { - pool = v ?? 0; - }, - options: [ - FormBuilderFieldOption(child: Text('T'), value: 0), - FormBuilderFieldOption(child: Text('S'), value: 1), - if (active.coinDef.supportsUA) - FormBuilderFieldOption(child: Text('O'), value: 2), - ]), - ], - )), - actions: confirmButtons( - context, () => Navigator.of(context).pop(true)))) ?? + ), + ), + actions: confirmButtons(context, () async { + final form = formKey.currentState!; + if (form.validate()) { + try { + final txid = await WarpApi.sweepTransparent(syncStatus.latestHeight, + keyController.text, pool, settings.anchorOffset, settings.feeRule); + showSnackBar(s.txId(txid)); + Navigator.of(context).pop(true); + } on String catch (msg) { + form.fields['key']!.invalidate(msg); + } + } + }))) ?? false; if (confirmed) { - final txid = await WarpApi.sweepTransparent(syncStatus.latestHeight, - keyController.text, pool, settings.anchorOffset); - showSnackBar(s.txId(txid)); } } diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 7539414a2..6ffc5d5bf 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -310,5 +310,6 @@ "scanningAddresses": "Scanning addresses", "blockExplorer": "Block Explorer", "tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address", - "playSound": "Play Sound" + "playSound": "Play Sound", + "fee": "Fee" } diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index c8d3b4bd8..103f4170a 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -308,5 +308,6 @@ "scanningAddresses": "Scanning addresses", "blockExplorer": "Block Explorer", "tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address", - "playSound": "Sonido" + "playSound": "Sonido", + "fee": "Fee" } diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 88b63dbec..c3813c050 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -309,5 +309,6 @@ "scanningAddresses": "Scanning addresses", "blockExplorer": "Block Explorer", "tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address", - "playSound": "Effets Sonores" + "playSound": "Effets Sonores", + "fee": "Fee" } diff --git a/lib/main.dart b/lib/main.dart index bd4d9081c..f82af4ca4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -834,7 +834,7 @@ Future authenticate(BuildContext context, String reason) async { Future shieldTAddr(BuildContext context) async { try { final txPlan = WarpApi.shieldTAddr( - active.coin, active.id, active.tbalance, settings.anchorOffset); + active.coin, active.id, active.tbalance, settings.anchorOffset, settings.feeRule); Navigator.of(context).pushNamed('/txplan', arguments: txPlan); } on String catch (msg) { showSnackBar(msg, error: true); diff --git a/lib/pools.dart b/lib/pools.dart index 2135afb90..eec59d133 100644 --- a/lib/pools.dart +++ b/lib/pools.dart @@ -149,7 +149,8 @@ class PoolsState extends State { includeFee, _memoController.text, stringToAmount(_maxAmountController.text), - settings.anchorOffset); + settings.anchorOffset, + settings.feeRule); Navigator.of(context) .pushReplacementNamed('/txplan', arguments: txPlan); } on String catch (message) { diff --git a/lib/send.dart b/lib/send.dart index 6d1fea631..f37552d24 100644 --- a/lib/send.dart +++ b/lib/send.dart @@ -538,7 +538,7 @@ Future send(BuildContext context, List recipients) async { if (recipients.length == 1) active.setDraftRecipient(recipients[0]); try { final txPlan = await WarpApi.prepareTx( - active.coin, active.id, recipients, settings.anchorOffset); + active.coin, active.id, recipients, settings.anchorOffset, settings.feeRule); Navigator.pushReplacementNamed(context, '/txplan', arguments: txPlan); } on String catch (message) { showSnackBar(message); diff --git a/lib/settings.dart b/lib/settings.dart index d35f9f07b..b6f2011ac 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -35,6 +35,7 @@ class SettingsState extends State with SingleTickerProviderStateMixin { var _anchorController = TextEditingController(text: "${settings.anchorOffset}"); + var _feeController = TextEditingController(text: amountToString(settings.fee, MAX_PRECISION)); var _memoController = TextEditingController(); var _currency = settings.currency; var _needAuth = false; @@ -152,6 +153,15 @@ class SettingsState extends State }, onSaved: _onProtectOpen)), ]), + if (!simpleMode) + FormBuilderTextField( + decoration: InputDecoration( + labelText: s.fee), + name: 'fee', + keyboardType: TextInputType.number, + controller: _feeController, + inputFormatters: [makeInputFormatter(false)], + onSaved: _onFee), if (!simpleMode) FormBuilderCheckbox( name: 'use_millis', @@ -441,6 +451,10 @@ class SettingsState extends State settings.updateGetTx(v); } + _onFee(v) { + settings.setFee(stringToAmount(v)); + } + _onUseMillis(v) { settings.setUseMillis(v); } diff --git a/lib/store.dart b/lib/store.dart index c23b1bf47..82a6a4f66 100644 --- a/lib/store.dart +++ b/lib/store.dart @@ -199,6 +199,9 @@ abstract class _Settings with Store { @observable bool sound = true; + @observable + int fee = 1000; + String dbPasswd = ""; @action @@ -229,6 +232,7 @@ abstract class _Settings with Store { txView = ViewStyle.values[(prefs.getInt('tx_view') ?? 0)]; qrOffline = prefs.getBool('qr_offline') ?? true; sound = prefs.getBool('sound') ?? true; + fee = prefs.getInt('fee') ?? 10000; primaryColorValue = prefs.getInt('primary') ?? Colors.blue.value; primaryVariantColorValue = @@ -594,7 +598,20 @@ abstract class _Settings with Store { prefs.setInt('min_privacy', v); } + @action + Future setFee(int v) async { + final prefs = await SharedPreferences.getInstance(); + fee = v; + prefs.setInt('fee', v); + } + bool get isDeveloper => developerMode == 0; + + FeeT get feeRule { + return FeeT( + fee: fee, + ); + } } Future getFxRate(String coin, String fiat) async { diff --git a/native/zcash-sync b/native/zcash-sync index 652f71a83..660eab90f 160000 --- a/native/zcash-sync +++ b/native/zcash-sync @@ -1 +1 @@ -Subproject commit 652f71a83d8c39e840f416c47e926c7b99dc8b32 +Subproject commit 660eab90fcdc37df25dcb174bc111d3e18d2a7df diff --git a/packages/warp_api_ffi/lib/data_fb_generated.dart b/packages/warp_api_ffi/lib/data_fb_generated.dart index 40317deed..423174fab 100644 --- a/packages/warp_api_ffi/lib/data_fb_generated.dart +++ b/packages/warp_api_ffi/lib/data_fb_generated.dart @@ -4864,3 +4864,140 @@ class TxReportObjectBuilder extends fb.ObjectBuilder { return fbBuilder.buffer; } } +class Fee { + Fee._(this._bc, this._bcOffset); + factory Fee(List bytes) { + final rootRef = fb.BufferContext.fromBytes(bytes); + return reader.read(rootRef, 0); + } + + static const fb.Reader reader = _FeeReader(); + + final fb.BufferContext _bc; + final int _bcOffset; + + int get fee => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 4, 0); + int get minFee => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 6, 0); + int get maxFee => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 8, 0); + int get scheme => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 10, 0); + + @override + String toString() { + return 'Fee{fee: ${fee}, minFee: ${minFee}, maxFee: ${maxFee}, scheme: ${scheme}}'; + } + + FeeT unpack() => FeeT( + fee: fee, + minFee: minFee, + maxFee: maxFee, + scheme: scheme); + + static int pack(fb.Builder fbBuilder, FeeT? object) { + if (object == null) return 0; + return object.pack(fbBuilder); + } +} + +class FeeT implements fb.Packable { + int fee; + int minFee; + int maxFee; + int scheme; + + FeeT({ + this.fee = 0, + this.minFee = 0, + this.maxFee = 0, + this.scheme = 0}); + + @override + int pack(fb.Builder fbBuilder) { + fbBuilder.startTable(4); + fbBuilder.addUint64(0, fee); + fbBuilder.addUint64(1, minFee); + fbBuilder.addUint64(2, maxFee); + fbBuilder.addUint8(3, scheme); + return fbBuilder.endTable(); + } + + @override + String toString() { + return 'FeeT{fee: ${fee}, minFee: ${minFee}, maxFee: ${maxFee}, scheme: ${scheme}}'; + } +} + +class _FeeReader extends fb.TableReader { + const _FeeReader(); + + @override + Fee createObject(fb.BufferContext bc, int offset) => + Fee._(bc, offset); +} + +class FeeBuilder { + FeeBuilder(this.fbBuilder); + + final fb.Builder fbBuilder; + + void begin() { + fbBuilder.startTable(4); + } + + int addFee(int? fee) { + fbBuilder.addUint64(0, fee); + return fbBuilder.offset; + } + int addMinFee(int? minFee) { + fbBuilder.addUint64(1, minFee); + return fbBuilder.offset; + } + int addMaxFee(int? maxFee) { + fbBuilder.addUint64(2, maxFee); + return fbBuilder.offset; + } + int addScheme(int? scheme) { + fbBuilder.addUint8(3, scheme); + return fbBuilder.offset; + } + + int finish() { + return fbBuilder.endTable(); + } +} + +class FeeObjectBuilder extends fb.ObjectBuilder { + final int? _fee; + final int? _minFee; + final int? _maxFee; + final int? _scheme; + + FeeObjectBuilder({ + int? fee, + int? minFee, + int? maxFee, + int? scheme, + }) + : _fee = fee, + _minFee = minFee, + _maxFee = maxFee, + _scheme = scheme; + + /// Finish building, and store into the [fbBuilder]. + @override + int finish(fb.Builder fbBuilder) { + fbBuilder.startTable(4); + fbBuilder.addUint64(0, _fee); + fbBuilder.addUint64(1, _minFee); + fbBuilder.addUint64(2, _maxFee); + fbBuilder.addUint8(3, _scheme); + return fbBuilder.endTable(); + } + + /// Convenience method to serialize to byte list. + @override + Uint8List toBytes([String? fileIdentifier]) { + final fbBuilder = fb.Builder(deduplicateTables: false); + fbBuilder.finish(finish(fbBuilder), fileIdentifier); + return fbBuilder.buffer; + } +} diff --git a/packages/warp_api_ffi/lib/warp_api.dart b/packages/warp_api_ffi/lib/warp_api.dart index de47d2279..7c8a7ed19 100644 --- a/packages/warp_api_ffi/lib/warp_api.dart +++ b/packages/warp_api_ffi/lib/warp_api.dart @@ -7,6 +7,7 @@ import 'package:flat_buffers/flat_buffers.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:ffi/ffi.dart'; +import 'package:tuple/tuple.dart'; import 'warp_api_generated.dart'; import 'data_fb_generated.dart'; @@ -241,18 +242,20 @@ class WarpApi { bool includeFee, String memo, int splitAmount, - int anchorOffset) async { + int anchorOffset, + FeeT fee) async { final txId = await compute( transferPoolsIsolateFn, TransferPoolsParams(coin, account, fromPool, toPool, amount, includeFee, - memo, splitAmount, anchorOffset)); + memo, splitAmount, anchorOffset, fee)); return txId; } static String shieldTAddr( - int coin, int account, int amount, int anchorOffset) { - final txPlan = - warp_api_lib.shield_taddr(coin, account, amount, anchorOffset); + int coin, int account, int amount, int anchorOffset, FeeT fee) { + final fee2 = encodeFee(fee); + final txPlan = warp_api_lib.shield_taddr(coin, account, amount, + anchorOffset, toNativeBytes(fee2), fee2.lengthInBytes); return unwrapResultString(txPlan); } @@ -263,14 +266,21 @@ class WarpApi { } static Future prepareTx(int coin, int account, - List recipients, int anchorOffset) async { + List recipients, int anchorOffset, FeeT fee) async { final builder = Builder(); final rs = recipients.map((r) => r.unpack()).toList(); int root = RecipientsT(values: rs).pack(builder); builder.finish(root); + final fee2 = encodeFee(fee); return await compute((_) { - final res = warp_api_lib.prepare_multi_payment(coin, account, - toNativeBytes(builder.buffer), builder.size(), anchorOffset); + final res = warp_api_lib.prepare_multi_payment( + coin, + account, + toNativeBytes(builder.buffer), + builder.size(), + anchorOffset, + toNativeBytes(fee2), + fee2.lengthInBytes); final json = unwrapResultString(res); return json; }, null); @@ -312,11 +322,12 @@ class WarpApi { return warp_api_lib.is_valid_tkey(toNative(key)) != 0; } - static Future sweepTransparent( - int latestHeight, String sk, int pool, int confirmations) async { + static Future sweepTransparent(int latestHeight, String sk, int pool, + int confirmations, FeeT fee) async { return await compute((_) { - final txid = warp_api_lib.sweep_tkey( - latestHeight, toNative(sk), pool, confirmations); + final fee2 = encodeFee(fee); + final txid = warp_api_lib.sweep_tkey(latestHeight, toNative(sk), pool, + confirmations, toNativeBytes(fee2), fee2.lengthInBytes); return unwrapResultString(txid); }, null); } @@ -359,9 +370,10 @@ class WarpApi { address.toNativeUtf8().cast(), dirty ? 1 : 0); } - static String commitUnsavedContacts(int anchorOffset) { - return unwrapResultString( - warp_api_lib.commit_unsaved_contacts(anchorOffset)); + static String commitUnsavedContacts(int anchorOffset, FeeT fee) { + final fee2 = encodeFee(fee); + return unwrapResultString(warp_api_lib.commit_unsaved_contacts( + anchorOffset, toNativeBytes(fee2), fee2.lengthInBytes)); } static void markMessageAsRead(int messageId, bool read) { @@ -668,6 +680,7 @@ int getLatestHeightIsolateFn(Null n) { } String transferPoolsIsolateFn(TransferPoolsParams params) { + final fee2 = encodeFee(params.fee); final txId = warp_api_lib.transfer_pools( params.coin, params.account, @@ -677,7 +690,9 @@ String transferPoolsIsolateFn(TransferPoolsParams params) { params.takeFee ? 1 : 0, toNative(params.memo), params.splitAmount, - params.anchorOffset); + params.anchorOffset, + toNativeBytes(fee2), + fee2.lengthInBytes); return unwrapResultString(txId); } @@ -750,6 +765,7 @@ class TransferPoolsParams { final String memo; final int splitAmount; final int anchorOffset; + final FeeT fee; TransferPoolsParams( this.coin, @@ -760,7 +776,8 @@ class TransferPoolsParams { this.takeFee, this.memo, this.splitAmount, - this.anchorOffset); + this.anchorOffset, + this.fee); } class SyncHistoricalPricesParams { @@ -794,6 +811,13 @@ List convertBytes(Pointer s, int len) { return bytes; } +Uint8List encodeFee(FeeT fee) { + final feeBuilder = Builder(); + int fee2 = fee.pack(feeBuilder); + feeBuilder.finish(fee2); + return feeBuilder.buffer; +} + void mempoolRunIsolateFn(int port) { warp_api_lib.mempool_run(port); } diff --git a/packages/warp_api_ffi/lib/warp_api_generated.dart b/packages/warp_api_ffi/lib/warp_api_generated.dart index 34ed33750..a52129806 100644 --- a/packages/warp_api_ffi/lib/warp_api_generated.dart +++ b/packages/warp_api_ffi/lib/warp_api_generated.dart @@ -520,6 +520,8 @@ class NativeLibrary { ffi.Pointer memo, int split_amount, int confirmations, + ffi.Pointer fee_bytes, + int fee_len, ) { return _transfer_pools( coin, @@ -531,6 +533,8 @@ class NativeLibrary { memo, split_amount, confirmations, + fee_bytes, + fee_len, ); } @@ -544,12 +548,16 @@ class NativeLibrary { int account, int amount, int confirmations, + ffi.Pointer fee_bytes, + int fee_len, ) { return _shield_taddr( coin, account, amount, confirmations, + fee_bytes, + fee_len, ); } @@ -583,6 +591,8 @@ class NativeLibrary { ffi.Pointer recipients_bytes, int recipients_len, int anchor_offset, + ffi.Pointer fee_bytes, + int fee_len, ) { return _prepare_multi_payment( coin, @@ -590,6 +600,8 @@ class NativeLibrary { recipients_bytes, recipients_len, anchor_offset, + fee_bytes, + fee_len, ); } @@ -679,12 +691,16 @@ class NativeLibrary { ffi.Pointer sk, int pool, int confirmations, + ffi.Pointer fee_bytes, + int fee_len, ) { return _sweep_tkey( last_height, sk, pool, confirmations, + fee_bytes, + fee_len, ); } @@ -755,9 +771,13 @@ class NativeLibrary { CResult_____c_char commit_unsaved_contacts( int anchor_offset, + ffi.Pointer fee_bytes, + int fee_len, ) { return _commit_unsaved_contacts( anchor_offset, + fee_bytes, + fee_len, ); } @@ -1582,11 +1602,9 @@ const int Account_VT_ID = 4; const int Account_VT_NAME = 6; -const int Account_VT_COLD = 8; +const int Account_VT_KEY_TYPE = 8; -const int Account_VT_HARDWARE = 10; - -const int Account_VT_BALANCE = 12; +const int Account_VT_BALANCE = 10; const int AccountVec_VT_ACCOUNTS = 4; @@ -1714,6 +1732,12 @@ const int TxReport_VT_FEE = 16; const int TxReport_VT_PRIVACY_LEVEL = 18; +const int Fee_VT_MIN_FEE = 6; + +const int Fee_VT_MAX_FEE = 8; + +const int Fee_VT_SCHEME = 10; + typedef _c_dummy_export = ffi.Void Function(); typedef _dart_dummy_export = void Function(); @@ -2036,6 +2060,8 @@ typedef _c_transfer_pools = CResult_____c_char Function( ffi.Pointer memo, ffi.Uint64 split_amount, ffi.Uint32 confirmations, + ffi.Pointer fee_bytes, + ffi.Uint64 fee_len, ); typedef _dart_transfer_pools = CResult_____c_char Function( @@ -2048,6 +2074,8 @@ typedef _dart_transfer_pools = CResult_____c_char Function( ffi.Pointer memo, int split_amount, int confirmations, + ffi.Pointer fee_bytes, + int fee_len, ); typedef _c_shield_taddr = CResult_____c_char Function( @@ -2055,6 +2083,8 @@ typedef _c_shield_taddr = CResult_____c_char Function( ffi.Uint32 account, ffi.Uint64 amount, ffi.Uint32 confirmations, + ffi.Pointer fee_bytes, + ffi.Uint64 fee_len, ); typedef _dart_shield_taddr = CResult_____c_char Function( @@ -2062,6 +2092,8 @@ typedef _dart_shield_taddr = CResult_____c_char Function( int account, int amount, int confirmations, + ffi.Pointer fee_bytes, + int fee_len, ); typedef _c_scan_transparent_accounts = CResult______u8 Function( @@ -2082,6 +2114,8 @@ typedef _c_prepare_multi_payment = CResult_____c_char Function( ffi.Pointer recipients_bytes, ffi.Uint64 recipients_len, ffi.Uint32 anchor_offset, + ffi.Pointer fee_bytes, + ffi.Uint64 fee_len, ); typedef _dart_prepare_multi_payment = CResult_____c_char Function( @@ -2090,6 +2124,8 @@ typedef _dart_prepare_multi_payment = CResult_____c_char Function( ffi.Pointer recipients_bytes, int recipients_len, int anchor_offset, + ffi.Pointer fee_bytes, + int fee_len, ); typedef _c_transaction_report = CResult______u8 Function( @@ -2149,6 +2185,8 @@ typedef _c_sweep_tkey = CResult_____c_char Function( ffi.Pointer sk, ffi.Uint8 pool, ffi.Uint32 confirmations, + ffi.Pointer fee_bytes, + ffi.Uint64 fee_len, ); typedef _dart_sweep_tkey = CResult_____c_char Function( @@ -2156,6 +2194,8 @@ typedef _dart_sweep_tkey = CResult_____c_char Function( ffi.Pointer sk, int pool, int confirmations, + ffi.Pointer fee_bytes, + int fee_len, ); typedef _c_get_activation_date = CResult_u32 Function(); @@ -2198,10 +2238,14 @@ typedef _dart_store_contact = void Function( typedef _c_commit_unsaved_contacts = CResult_____c_char Function( ffi.Uint32 anchor_offset, + ffi.Pointer fee_bytes, + ffi.Uint64 fee_len, ); typedef _dart_commit_unsaved_contacts = CResult_____c_char Function( int anchor_offset, + ffi.Pointer fee_bytes, + int fee_len, ); typedef _c_mark_message_read = ffi.Void Function( diff --git a/packages/warp_api_ffi/pubspec.yaml b/packages/warp_api_ffi/pubspec.yaml index 839b11b3a..a2c93bad1 100644 --- a/packages/warp_api_ffi/pubspec.yaml +++ b/packages/warp_api_ffi/pubspec.yaml @@ -30,7 +30,7 @@ ffigen: - '../../native/zcash-sync/binding.h' # On MacOS llvm-path: - - '/opt/homebrew/Cellar/llvm/15.0.7_1' + - '/opt/homebrew/Cellar/llvm/16.0.5' # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/pubspec.yaml b/pubspec.yaml index 464502159..44f097c47 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.4.0+466 +version: 1.4.1+469 environment: sdk: ">=2.12.0 <3.0.0"