dev
md 47 lines 1.63 KB
Rendered Raw
1 # cw_decred
2
3 Decred wallet module that bridges to the native `libdcrwallet` via FFI. Provides high‑level methods to create/load wallets, sync, query balances/transactions, build and broadcast transactions, and sign/verify messages.
4
5 ## Features
6
7 - FFI bindings to `libdcrwallet` with an isolate‑based request/response model.
8 - Initialize, create, load, close wallets; watch‑only creation.
9 - Start sync with optional peer list; query sync status and best block.
10 - Query balances, list transactions and unspents, rescan from height.
11 - Create signed transactions and broadcast raw transactions.
12 - Export wallet seed; change wallet password.
13 - Address management (new external address, default pubkey, address lists).
14 - Message signing and verification.
15
16 ## Getting started
17
18 Ensure the platform library is available:
19
20 - Android/Linux: `libdcrwallet.so`
21 - Apple: embedded `cw_decred.framework/cw_decred`
22
23 Initialize and load a wallet:
24
25 ```dart
26 final lib = await Libwallet.spawn();
27 await lib.initLibdcrwallet('', 'info');
28 await lib.loadWallet(jsonEncode({ /* libdcrwallet config */ }));
29 await lib.startSync('wallet.db', '');
30 final status = await lib.syncStatus('wallet.db');
31 ```
32
33 ## Usage
34
35 Create, sign, and broadcast a transaction:
36
37 ```dart
38 final signed = await lib.createSignedTransaction('wallet.db', jsonEncode({
39 // inputs/outputs and policy for libdcrwallet
40 }));
41 final txid = await lib.sendRawTransaction('wallet.db', signed);
42 ```
43
44 ## Additional information
45
46 - See `lib/api/` for the isolate wrapper (`libdcrwallet.dart`) and low‑level bindings.
47 - Errors are surfaced via the `PayloadResult` struct; some calls support `throwOnError` in higher‑level wrappers.