parent
2eb76f8232
commit
5f0a8e8473
|
@ -21,7 +21,8 @@ class _AccountPageState extends State<AccountPage>
|
|||
with WidgetsBindingObserver, AutomaticKeepAliveClientMixin {
|
||||
Timer _timerSync;
|
||||
int _progress = 0;
|
||||
StreamSubscription _sub;
|
||||
bool _useSnapAddress = false;
|
||||
String _snapAddress = "";
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
@ -34,7 +35,6 @@ class _AccountPageState extends State<AccountPage>
|
|||
await accountManager.updateUnconfirmedBalance();
|
||||
await accountManager.fetchNotesAndHistory();
|
||||
_setupTimer();
|
||||
await showAboutOnce(this.context);
|
||||
});
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
progressStream.listen((percent) {
|
||||
|
@ -72,6 +72,8 @@ class _AccountPageState extends State<AccountPage>
|
|||
super.build(context);
|
||||
if (!syncStatus.isSynced()) _trySync();
|
||||
if (accountManager.active == null) return CircularProgressIndicator();
|
||||
final address = _useSnapAddress ? _snapAddress : accountManager.active.address;
|
||||
|
||||
return DefaultTabController(
|
||||
length: 3,
|
||||
child: Scaffold(
|
||||
|
@ -120,16 +122,15 @@ class _AccountPageState extends State<AccountPage>
|
|||
: Text(
|
||||
'${syncStatus.syncedHeight} / ${syncStatus.latestHeight}')),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 8)),
|
||||
Observer(builder: (context) {
|
||||
return Column(children: [
|
||||
Column(children: [
|
||||
QrImage(
|
||||
data: accountManager.active.address,
|
||||
data: address,
|
||||
size: 200,
|
||||
backgroundColor: Colors.white),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 8)),
|
||||
SelectableText('${accountManager.active.address}'),
|
||||
]);
|
||||
}),
|
||||
SelectableText('$address'),
|
||||
TextButton(child: Text('New Snap Address'), onPressed: _onSnapAddress)
|
||||
]),
|
||||
Observer(
|
||||
builder: (context) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
@ -250,6 +251,19 @@ class _AccountPageState extends State<AccountPage>
|
|||
await accountManager.updateUnconfirmedBalance();
|
||||
}
|
||||
|
||||
_onSnapAddress() {
|
||||
final address = accountManager.newAddress();
|
||||
setState(() {
|
||||
_useSnapAddress = true;
|
||||
_snapAddress = address;
|
||||
});
|
||||
Timer(Duration(seconds: 15), () {
|
||||
setState(() {
|
||||
_useSnapAddress = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_onSend() {
|
||||
Navigator.of(this.context).pushNamed('/send');
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ import 'package:flutter_mobx/flutter_mobx.dart';
|
|||
import 'package:warp/main.dart';
|
||||
import 'package:warp/store.dart';
|
||||
|
||||
import 'about.dart';
|
||||
|
||||
class AccountManagerPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => AccountManagerState();
|
||||
|
@ -11,8 +13,9 @@ class AccountManagerPage extends StatefulWidget {
|
|||
class AccountManagerState extends State<AccountManagerPage> {
|
||||
@override
|
||||
initState() {
|
||||
Future.microtask(accountManager.refresh);
|
||||
super.initState();
|
||||
Future.microtask(accountManager.refresh);
|
||||
showAboutOnce(this.context);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -107,6 +107,10 @@ abstract class _AccountManager with Store {
|
|||
setActiveAccount(account);
|
||||
}
|
||||
|
||||
String newAddress() {
|
||||
return WarpApi.newAddress(active.id);
|
||||
}
|
||||
|
||||
Future<String> getBackup() async {
|
||||
final List<Map> res = await db.rawQuery(
|
||||
"SELECT seed, sk, ivk FROM accounts WHERE id_account = ?1",
|
||||
|
|
|
@ -18,13 +18,19 @@ bool is_valid_key(char *seed);
|
|||
|
||||
bool valid_address(char *address);
|
||||
|
||||
char *new_address(uint32_t account);
|
||||
|
||||
void set_mempool_account(uint32_t account);
|
||||
|
||||
uint32_t new_account(char *name, char *data);
|
||||
|
||||
int64_t get_mempool_balance(void);
|
||||
|
||||
const char *send_payment(uint32_t account, char *address, uint64_t amount, uint64_t max_amount_per_note, int64_t port);
|
||||
const char *send_payment(uint32_t account,
|
||||
char *address,
|
||||
uint64_t amount,
|
||||
uint64_t max_amount_per_note,
|
||||
int64_t port);
|
||||
|
||||
int8_t try_warp_sync(void);
|
||||
|
||||
|
|
|
@ -5,9 +5,3 @@ typedef long long int uintptr_t;
|
|||
typedef long int uint32_t;
|
||||
typedef char bool;
|
||||
typedef void *DartPostCObjectFnType;
|
||||
|
||||
typedef struct WalletBalance {
|
||||
uint64_t confirmed;
|
||||
int64_t unconfirmed;
|
||||
uint64_t spendable;
|
||||
} WalletBalance;
|
||||
|
|
|
@ -114,6 +114,11 @@ pub fn valid_address(address: &str) -> bool {
|
|||
Wallet::valid_address(address)
|
||||
}
|
||||
|
||||
pub fn new_address(account: u32) -> String {
|
||||
let wallet = WALLET.get().unwrap().lock().unwrap();
|
||||
wallet.new_diversified_address(account).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_latest_height() -> u32 {
|
||||
let r = Runtime::new().unwrap();
|
||||
r.block_on(async {
|
||||
|
|
|
@ -39,6 +39,12 @@ pub unsafe extern "C" fn valid_address(address: *mut c_char) -> bool {
|
|||
api::valid_address(&address)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn new_address(account: u32) -> *mut c_char {
|
||||
let address = api::new_address(account);
|
||||
CString::new(address).unwrap().into_raw()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn set_mempool_account(account: u32) {
|
||||
api::set_mempool_account(account);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4548e888a1e5c67d98a31f16be7a0323ef3e318c
|
||||
Subproject commit 7d40ad28c6c197d5f50b347783c32ac68574c742
|
|
@ -100,6 +100,11 @@ class WarpApi {
|
|||
return warp_api_lib.valid_address(address.toNativeUtf8().cast<Int8>()) != 0;
|
||||
}
|
||||
|
||||
static String newAddress(int account) {
|
||||
final address = warp_api_lib.new_address(account);
|
||||
return address.cast<Utf8>().toDartString();
|
||||
}
|
||||
|
||||
static void setMempoolAccount(int account) {
|
||||
return warp_api_lib.set_mempool_account(account);
|
||||
}
|
||||
|
|
|
@ -92,6 +92,19 @@ class NativeLibrary {
|
|||
late final _dart_valid_address _valid_address =
|
||||
_valid_address_ptr.asFunction<_dart_valid_address>();
|
||||
|
||||
ffi.Pointer<ffi.Int8> new_address(
|
||||
int account,
|
||||
) {
|
||||
return _new_address(
|
||||
account,
|
||||
);
|
||||
}
|
||||
|
||||
late final _new_address_ptr =
|
||||
_lookup<ffi.NativeFunction<_c_new_address>>('new_address');
|
||||
late final _dart_new_address _new_address =
|
||||
_new_address_ptr.asFunction<_dart_new_address>();
|
||||
|
||||
void set_mempool_account(
|
||||
int account,
|
||||
) {
|
||||
|
@ -238,6 +251,14 @@ typedef _dart_valid_address = int Function(
|
|||
ffi.Pointer<ffi.Int8> address,
|
||||
);
|
||||
|
||||
typedef _c_new_address = ffi.Pointer<ffi.Int8> Function(
|
||||
ffi.Uint32 account,
|
||||
);
|
||||
|
||||
typedef _dart_new_address = ffi.Pointer<ffi.Int8> Function(
|
||||
int account,
|
||||
);
|
||||
|
||||
typedef _c_set_mempool_account = ffi.Void Function(
|
||||
ffi.Uint32 account,
|
||||
);
|
||||
|
|
|
@ -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.0.1+14
|
||||
version: 1.0.2+15
|
||||
|
||||
environment:
|
||||
sdk: ">=2.9.0 <3.0.0"
|
||||
|
|
Loading…
Reference in New Issue