nerva-py 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nerva/wallet.py ADDED
@@ -0,0 +1,2179 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Dict, List, Optional
4
+
5
+ import aiohttp
6
+
7
+ __all__ = ["Wallet"]
8
+
9
+
10
+ class Wallet:
11
+ """
12
+ A class to interact with the Nerva wallet's JSON-RPC interface.
13
+
14
+ Parameters
15
+ ----------
16
+ port : int
17
+ The port of the wallet's JSON-RPC interface.
18
+ host : str, optional
19
+ The host of the wallet's JSON-RPC interface. Default is "localhost".
20
+ ssl : bool, optional
21
+ Whether to use SSL. Default is False.
22
+ timeout : float, optional
23
+ The timeout for the request. Default is 10.0.
24
+ username : str, optional
25
+ The username for the wallet's JSON-RPC interface. Default is "".
26
+ password : str, optional
27
+ The password for the wallet's JSON-RPC interface. Default is "".
28
+
29
+ Attributes
30
+ ----------
31
+ url : str
32
+ The URL of the wallet's JSON-RPC interface.
33
+ auth : Optional[aiohttp.BasicAuth]
34
+ The authentication for the wallet's JSON-RPC interface.
35
+ timeout : float
36
+ The timeout for the request.
37
+ headers : Dict[str, str]
38
+ The headers for the request.
39
+
40
+ """
41
+
42
+ __slots__ = [
43
+ "url",
44
+ "auth",
45
+ "timeout",
46
+ "headers",
47
+ ]
48
+
49
+ def __init__(
50
+ self,
51
+ port: int,
52
+ host: str = "localhost",
53
+ ssl: bool = False,
54
+ timeout: float = 10.0,
55
+ username: str = "",
56
+ password: str = "",
57
+ ) -> None:
58
+ self.url: str = f"http{'s' if ssl else ''}://{host}:{port}"
59
+ self.auth: Optional[aiohttp.BasicAuth] = (
60
+ aiohttp.BasicAuth(username, password) if username and password else None
61
+ )
62
+ self.timeout: float = timeout
63
+
64
+ self.headers: Dict[str, str] = {"Content-Type": "application/json"}
65
+
66
+ async def _request(self, method: str, params: Dict[str, Any]) -> Dict[str, Any]:
67
+ async with aiohttp.ClientSession() as session:
68
+ async with session.post(
69
+ f"{self.url}/json_rpc",
70
+ json={"jsonrpc": "2.0", "id": 0, "method": method, "params": params},
71
+ headers=self.headers,
72
+ auth=self.auth,
73
+ timeout=self.timeout,
74
+ ) as response:
75
+ return await response.json(content_type=None)
76
+
77
+ async def get_balance(
78
+ self, account_index: int, address_indices: Optional[List[int]] = None
79
+ ) -> Dict[str, Any]:
80
+ """
81
+ Return the wallet's balance.
82
+
83
+ Parameters
84
+ ----------
85
+ account_index : int
86
+ Return balance for this account.
87
+ address_indices : List[int], optional
88
+ Return balance detail for those subaddresses.
89
+
90
+ Returns
91
+ -------
92
+ Dict[str, Any]
93
+ The response from wallet RPC.
94
+ """
95
+ return await self._request(
96
+ "get_balance",
97
+ {
98
+ "account_index": account_index,
99
+ "address_indices": address_indices or [],
100
+ },
101
+ )
102
+
103
+ async def get_address(
104
+ self, account_index: int, address_indices: Optional[List[int]] = None
105
+ ) -> Dict[str, Any]:
106
+ """
107
+ Return the wallet's addresses for an account. Optionally filter for specific set of subaddresses.
108
+
109
+ Parameters
110
+ ----------
111
+ account_index : int
112
+ Get addresses for this account.
113
+ address_indices : List[int], optional
114
+ Return specific set of subaddresses.
115
+
116
+ Returns
117
+ -------
118
+ Dict[str, Any]
119
+ The response from wallet RPC.
120
+
121
+ """
122
+ return await self._request(
123
+ "get_address",
124
+ {
125
+ "account_index": account_index,
126
+ "address_indices": address_indices or [],
127
+ },
128
+ )
129
+
130
+ async def get_address_index(self, address: str) -> Dict[str, Any]:
131
+ """
132
+ Get account and address indexes from a specific (sub)address.
133
+
134
+ Parameters
135
+ ----------
136
+ address : str
137
+ The (sub)address to look for.
138
+
139
+ Returns
140
+ -------
141
+ Dict[str, Any]
142
+ The response from wallet RPC.
143
+
144
+ """
145
+ return await self._request("get_address_index", {"address": address})
146
+
147
+ async def create_address(
148
+ self, account_index: int, label: Optional[str] = None
149
+ ) -> Dict[str, Any]:
150
+ """
151
+ Create a new address for an account.
152
+
153
+ Parameters
154
+ ----------
155
+ account_index : int
156
+ Create a new address for this account.
157
+ label : str, optional
158
+ Label for the new address.
159
+
160
+ Returns
161
+ -------
162
+ Dict[str, Any]
163
+ The response from wallet RPC.
164
+
165
+ """
166
+ return await self._request(
167
+ "create_address", {"account_index": account_index, "label": label}
168
+ )
169
+
170
+ async def label_address(
171
+ self, index: Dict[str, int], label: str
172
+ ) -> Dict[str, Any]:
173
+ """
174
+ Label an address.
175
+
176
+ Parameters
177
+ ----------
178
+ index : Dict[str, int]
179
+ Subaddress index in the form {"major": 0, "minor": 0}.
180
+ label : str
181
+ The label of the address.
182
+
183
+ Returns
184
+ -------
185
+ Dict[str, Any]
186
+ The response from wallet RPC.
187
+
188
+ """
189
+ return await self._request("label_address", {"index": index, "label": label})
190
+
191
+ async def get_accounts(self, tag: Optional[str] = None) -> Dict[str, Any]:
192
+ """
193
+ Return the wallet's accounts.
194
+
195
+ Parameters
196
+ ----------
197
+ tag : str, optional
198
+ Tag for filtering accounts.
199
+
200
+ Returns
201
+ -------
202
+ Dict[str, Any]
203
+ The response from wallet RPC.
204
+
205
+ """
206
+ return await self._request("get_accounts", {"tag": tag})
207
+
208
+ async def create_account(self, label: Optional[str] = None) -> Dict[str, Any]:
209
+ """
210
+ Create a new account.
211
+
212
+ Parameters
213
+ ----------
214
+ label : str, optional
215
+ The label of the account.
216
+
217
+ Returns
218
+ -------
219
+ Dict[str, Any]
220
+ The response from wallet RPC.
221
+
222
+ """
223
+ return await self._request("create_account", {"label": label})
224
+
225
+ async def label_account(self, account_index: int, label: str) -> Dict[str, Any]:
226
+ """
227
+ Label an account.
228
+
229
+ Parameters
230
+ ----------
231
+ account_index : int
232
+ The index of the account.
233
+ label : str
234
+ The label of the account.
235
+
236
+ Returns
237
+ -------
238
+ Dict[str, Any]
239
+ The response from wallet RPC.
240
+
241
+ """
242
+ return await self._request(
243
+ "label_account", {"account_index": account_index, "label": label}
244
+ )
245
+
246
+ async def get_account_tags(self) -> Dict[str, Any]:
247
+ """
248
+ Return the wallet's account tags.
249
+
250
+ Returns
251
+ -------
252
+ Dict[str, Any]
253
+ The response from wallet RPC.
254
+
255
+ """
256
+ return await self._request("get_account_tags", {})
257
+
258
+ async def tag_accounts(self, tag: str, accounts: List[int]) -> Dict[str, Any]:
259
+ """
260
+ Apply a filtering tag to a list of accounts.
261
+
262
+ Parameters
263
+ ----------
264
+ tag : str
265
+ The tag to apply.
266
+ accounts : List[int]
267
+ The accounts to tag.
268
+
269
+ Returns
270
+ -------
271
+ Dict[str, Any]
272
+ The response from wallet RPC.
273
+
274
+ """
275
+ return await self._request(
276
+ "tag_accounts", {"tag": tag, "accounts": accounts}
277
+ )
278
+
279
+ async def untag_accounts(self, accounts: List[int]) -> Dict[str, Any]:
280
+ """
281
+ Remove filtering tag from a list of accounts.
282
+
283
+ Parameters
284
+ ----------
285
+ accounts : List[int]
286
+ The accounts to untag.
287
+
288
+ Returns
289
+ -------
290
+ Dict[str, Any]
291
+ The response from wallet RPC.
292
+
293
+ """
294
+ return await self._request("untag_accounts", {"accounts": accounts})
295
+
296
+ async def set_account_tag_description(
297
+ self, tag: str, description: str
298
+ ) -> Dict[str, Any]:
299
+ """
300
+ Set description for an account tag.
301
+
302
+ Parameters
303
+ ----------
304
+ tag : str
305
+ The tag to set description for.
306
+ description : str
307
+ Description for the tag.
308
+
309
+ Returns
310
+ -------
311
+ Dict[str, Any]
312
+ The response from wallet RPC.
313
+ """
314
+ return await self._request(
315
+ "set_account_tag_description", {"tag": tag, "description": description}
316
+ )
317
+
318
+ async def get_height(self) -> Dict[str, Any]:
319
+ """
320
+ Return the wallet's current block height.
321
+
322
+ Returns
323
+ -------
324
+ Dict[str, Any]
325
+ The response from wallet RPC.
326
+
327
+ """
328
+ return await self._request("get_height", {})
329
+
330
+ async def transfer(
331
+ self,
332
+ destinations: List[Dict[str, Any]],
333
+ account_index: int,
334
+ subaddr_indices: List[int],
335
+ priority: int,
336
+ mixin: int,
337
+ ring_size: int,
338
+ unlock_time: int,
339
+ get_tx_key: bool,
340
+ get_tx_hex: bool,
341
+ get_tx_metadata: bool,
342
+ do_not_relay: bool,
343
+ payment_id: Optional[str] = None,
344
+ ) -> Dict[str, Any]:
345
+ """
346
+ Send a transfer from the wallet to a single recipient.
347
+
348
+ Parameters
349
+ ----------
350
+ destinations : List[Dict[str, Any]]
351
+ The destinations to send the transfer to.
352
+ account_index : int
353
+ The account to send the transfer from.
354
+ subaddr_indices : List[int]
355
+ Array of subaddress indices to send from.
356
+ priority : int
357
+ Set a priority for the transfer.
358
+ mixin : int
359
+ Number of outputs from the blockchain to mix with (0 means no mixing).
360
+ ring_size : int
361
+ Sets ringsize for each transaction.
362
+ unlock_time : int
363
+ Number of blocks before the Nerva can be spent (0 to not add a lock).
364
+ get_tx_key : bool
365
+ Return the transaction key after sending.
366
+ get_tx_hex : bool
367
+ Return the transaction as hex string after sending.
368
+ get_tx_metadata : bool
369
+ Return the transaction metadata.
370
+ do_not_relay : bool
371
+ If true, the transfer won't be relayed to the Nerva network.
372
+ payment_id : str, optional
373
+ Random 32-byte/64-character hex string to identify a transaction.
374
+
375
+ Returns
376
+ -------
377
+ Dict[str, Any]
378
+ The response from wallet RPC.
379
+
380
+ """
381
+ return await self._request(
382
+ "transfer",
383
+ {
384
+ "destinations": destinations,
385
+ "account_index": account_index,
386
+ "subaddr_indices": subaddr_indices,
387
+ "priority": priority,
388
+ "mixin": mixin,
389
+ "ring_size": ring_size,
390
+ "unlock_time": unlock_time,
391
+ "get_tx_key": get_tx_key,
392
+ "get_tx_hex": get_tx_hex,
393
+ "get_tx_metadata": get_tx_metadata,
394
+ "do_not_relay": do_not_relay,
395
+ "payment_id": payment_id,
396
+ },
397
+ )
398
+
399
+ async def transfer_split(
400
+ self,
401
+ destinations: List[Dict[str, Any]],
402
+ account_index: int,
403
+ subaddr_indices: List[int],
404
+ priority: int,
405
+ mixin: int,
406
+ ring_size: int,
407
+ unlock_time: int,
408
+ get_tx_keys: bool,
409
+ get_tx_hex: bool,
410
+ get_tx_metadata: bool,
411
+ do_not_relay: bool,
412
+ payment_id: Optional[str] = None,
413
+ ) -> Dict[str, Any]:
414
+ """
415
+ Send a transfer from the wallet to multiple recipients.
416
+
417
+ Parameters
418
+ ----------
419
+ destinations : List[Dict[str, Any]]
420
+ The destinations to send the transfer to.
421
+ account_index : int
422
+ The account to send the transfer from.
423
+ subaddr_indices : List[int]
424
+ Array of subaddress indices to send from.
425
+ priority : int
426
+ Set a priority for the transfer.
427
+ mixin : int
428
+ Number of outputs from the blockchain to mix with (0 means no mixing).
429
+ ring_size : int
430
+ Sets ringsize for each transaction.
431
+ unlock_time : int
432
+ Number of blocks before the Nerva can be spent (0 to not add a lock).
433
+ get_tx_keys : bool
434
+ Return the transaction keys after sending.
435
+ get_tx_hex : bool
436
+ Return the transaction as hex string after sending.
437
+ get_tx_metadata : bool
438
+ Return the transaction metadata.
439
+ do_not_relay : bool
440
+ If true, the transfer won't be relayed to the Nerva network.
441
+ payment_id : str, optional
442
+ Random 32-byte/64-character hex string to identify a transaction.
443
+
444
+ Returns
445
+ -------
446
+ Dict[str, Any]
447
+ The response from wallet RPC.
448
+
449
+ """
450
+ return await self._request(
451
+ "transfer_split",
452
+ {
453
+ "destinations": destinations,
454
+ "account_index": account_index,
455
+ "subaddr_indices": subaddr_indices,
456
+ "priority": priority,
457
+ "mixin": mixin,
458
+ "ring_size": ring_size,
459
+ "unlock_time": unlock_time,
460
+ "get_tx_keys": get_tx_keys,
461
+ "get_tx_hex": get_tx_hex,
462
+ "get_tx_metadata": get_tx_metadata,
463
+ "do_not_relay": do_not_relay,
464
+ "payment_id": payment_id,
465
+ },
466
+ )
467
+
468
+ async def sign_transfer(
469
+ self, unsigned_txset: str, export_raw: Optional[bool] = False
470
+ ) -> Dict[str, Any]:
471
+ """
472
+ Sign a transaction created on a read-only wallet (in cold-signing process).
473
+
474
+ Parameters
475
+ ----------
476
+ unsigned_txset : str
477
+ Set of unsigned tx returned by "transfer" method.
478
+ export_raw : bool, optional
479
+ If true, return the raw transaction data. Default is False.
480
+
481
+ Returns
482
+ -------
483
+ Dict[str, Any]
484
+ The response from wallet RPC.
485
+
486
+ """
487
+ return await self._request(
488
+ "sign_transfer",
489
+ {"unsigned_txset": unsigned_txset, "export_raw": export_raw},
490
+ )
491
+
492
+ async def describe_transfer(self, unsigned_txset: str) -> Dict[str, Any]:
493
+ """
494
+ Return a list of unsigned transfers in the set, their count, and total amount.
495
+
496
+ Parameters
497
+ ----------
498
+ unsigned_txset : str
499
+ Set of unsigned tx returned by "transfer" method.
500
+
501
+ Returns
502
+ -------
503
+ Dict[str, Any]
504
+ The response from wallet RPC.
505
+
506
+ """
507
+ return await self._request(
508
+ "describe_transfer", {"unsigned_txset": unsigned_txset}
509
+ )
510
+
511
+ async def submit_transfer(self, tx_data_hex: str) -> Dict[str, Any]:
512
+ """
513
+ Submit a previously signed transaction.
514
+
515
+ Parameters
516
+ ----------
517
+ tx_data_hex : str
518
+ Transaction in hex format.
519
+
520
+ Returns
521
+ -------
522
+ Dict[str, Any]
523
+ The response from wallet RPC.
524
+
525
+ """
526
+ return await self._request("submit_transfer", {"tx_data_hex": tx_data_hex})
527
+
528
+ async def sweep_dust(
529
+ self,
530
+ get_tx_keys: Optional[bool] = False,
531
+ do_not_relay: Optional[str] = False,
532
+ get_tx_hex: Optional[bool] = False,
533
+ get_tx_metadata: Optional[bool] = False,
534
+ ) -> Dict[str, Any]:
535
+ """
536
+ Sweep the dust from the wallet.
537
+
538
+ Parameters
539
+ ----------
540
+ get_tx_keys : bool, optional
541
+ Return the transaction keys after sending.
542
+ do_not_relay : bool, optional
543
+ If true, do not relay this sweep transfer.
544
+ get_tx_hex : bool, optional
545
+ Return the transactions as hex string after sending.
546
+ get_tx_metadata : bool, optional
547
+ Return the transaction metadata.
548
+
549
+ Returns
550
+ -------
551
+ Dict[str, Any]
552
+ The response from wallet RPC.
553
+
554
+ """
555
+ return await self._request(
556
+ "sweep_dust",
557
+ {
558
+ "get_tx_keys": get_tx_keys,
559
+ "do_not_relay": do_not_relay,
560
+ "get_tx_hex": get_tx_hex,
561
+ "get_tx_metadata": get_tx_metadata,
562
+ },
563
+ )
564
+
565
+ async def sweep_unmixable(self) -> Dict[str, Any]:
566
+ """
567
+ Sweep unmixable outputs from the wallet.
568
+
569
+ Returns
570
+ -------
571
+ Dict[str, Any]
572
+ The response from wallet RPC.
573
+
574
+ """
575
+ return await self._request("sweep_unmixable", {})
576
+
577
+ async def sweep_all(
578
+ self,
579
+ address: str,
580
+ account_index: int,
581
+ subaddr_indices: List[int],
582
+ priority: int,
583
+ mixin: int,
584
+ ring_size: int,
585
+ unlock_time: int,
586
+ get_tx_keys: bool,
587
+ below_amount: int,
588
+ do_not_relay: bool,
589
+ get_tx_hex: bool,
590
+ get_tx_metadata: bool,
591
+ payment_id: Optional[str] = None,
592
+ ) -> Dict[str, Any]:
593
+ """
594
+ Sweep all unlocked outputs in a specified subaddress to an address.
595
+
596
+ Parameters
597
+ ----------
598
+ address : str
599
+ Destination public address.
600
+ account_index : int
601
+ Account to sweep from.
602
+ subaddr_indices : List[int]
603
+ Array of subaddress indices to sweep from.
604
+ priority : int
605
+ Set a priority for the transfer.
606
+ mixin : int
607
+ Number of outputs from the blockchain to mix with (0 means no mixing).
608
+ ring_size : int
609
+ Sets ringsize for each transaction.
610
+ unlock_time : int
611
+ Number of blocks before the Nerva can be spent (0 to not add a lock).
612
+ get_tx_keys : bool
613
+ Return the transaction keys after sending.
614
+ below_amount : int
615
+ Sweep all outputs below this amount.
616
+ do_not_relay : bool
617
+ If true, do not relay this sweep transfer.
618
+ get_tx_hex : bool
619
+ Return the transactions as hex string after sending.
620
+ get_tx_metadata : bool
621
+ Return the transaction metadata.
622
+ payment_id : str, optional
623
+ Random 32-byte/64-character hex string to identify a transaction.
624
+
625
+ Returns
626
+ -------
627
+ Dict[str, Any]
628
+ The response from wallet RPC.
629
+
630
+ """
631
+ return await self._request(
632
+ "sweep_all",
633
+ {
634
+ "address": address,
635
+ "account_index": account_index,
636
+ "subaddr_indices": subaddr_indices,
637
+ "priority": priority,
638
+ "mixin": mixin,
639
+ "ring_size": ring_size,
640
+ "unlock_time": unlock_time,
641
+ "get_tx_keys": get_tx_keys,
642
+ "below_amount": below_amount,
643
+ "do_not_relay": do_not_relay,
644
+ "get_tx_hex": get_tx_hex,
645
+ "get_tx_metadata": get_tx_metadata,
646
+ "payment_id": payment_id,
647
+ },
648
+ )
649
+
650
+ async def sweep_single(
651
+ self,
652
+ address: str,
653
+ priority: int,
654
+ mixin: int,
655
+ ring_size: int,
656
+ unlock_time: int,
657
+ get_tx_key: bool,
658
+ get_tx_hex: bool,
659
+ get_tx_metadata: bool,
660
+ do_not_relay: bool,
661
+ payment_id: Optional[str] = None,
662
+ ) -> Dict[str, Any]:
663
+ """
664
+ Sweep a single output to an address.
665
+
666
+ Parameters
667
+ ----------
668
+ address : str
669
+ Destination public address.
670
+ priority : int
671
+ Set a priority for the transfer.
672
+ mixin : int
673
+ Number of outputs from the blockchain to mix with (0 means no mixing).
674
+ ring_size : int
675
+ Sets ringsize for each transaction.
676
+ unlock_time : int
677
+ Number of blocks before the Nerva can be spent (0 to not add a lock).
678
+ get_tx_key : bool
679
+ Return the transaction keys after sending.
680
+ get_tx_hex : bool
681
+ Return the transaction as hex string after sending.
682
+ get_tx_metadata : bool
683
+ Return the transaction metadata.
684
+ do_not_relay : bool
685
+ If true, the transfer won't be relayed to the Nerva network.
686
+ payment_id : str, optional
687
+ Random 32-byte/64-character hex string to identify a transaction.
688
+
689
+ Returns
690
+ -------
691
+ Dict[str, Any]
692
+ The response from wallet RPC.
693
+
694
+ """
695
+ return await self._request(
696
+ "sweep_single",
697
+ {
698
+ "address": address,
699
+ "priority": priority,
700
+ "mixin": mixin,
701
+ "ring_size": ring_size,
702
+ "unlock_time": unlock_time,
703
+ "get_tx_key": get_tx_key,
704
+ "get_tx_hex": get_tx_hex,
705
+ "get_tx_metadata": get_tx_metadata,
706
+ "do_not_relay": do_not_relay,
707
+ "payment_id": payment_id,
708
+ },
709
+ )
710
+
711
+ async def relay_tx(self, tx_hex: str) -> Dict[str, Any]:
712
+ """
713
+ Relay a transaction previously created with "do_not_relay" set to true.
714
+
715
+ Parameters
716
+ ----------
717
+ tx_hex : str
718
+ Transaction in hex format.
719
+
720
+ Returns
721
+ -------
722
+ Dict[str, Any]
723
+ The response from wallet RPC.
724
+
725
+ """
726
+ return await self._request("relay_tx", {"hex": tx_hex})
727
+
728
+ async def store(self) -> Dict[str, Any]:
729
+ """
730
+ Save the wallet file.
731
+
732
+ Returns
733
+ -------
734
+ Dict[str, Any]
735
+ The response from wallet RPC.
736
+
737
+ """
738
+ return await self._request("store", {})
739
+
740
+ async def get_payments(self, payment_id: str) -> Dict[str, Any]:
741
+ """
742
+ Return a list of incoming payments using a given payment ID.
743
+
744
+ Parameters
745
+ ----------
746
+ payment_id : str
747
+ Payment ID to query.
748
+
749
+ Returns
750
+ -------
751
+ Dict[str, Any]
752
+ The response from wallet RPC.
753
+
754
+ """
755
+ return await self._request("get_payments", {"payment_id": payment_id})
756
+
757
+ async def get_bulk_payments(
758
+ self, payment_ids: List[str], min_block_height: int
759
+ ) -> Dict[str, Any]:
760
+ """
761
+ Return a list of incoming payments using a given payment ID.
762
+
763
+ Parameters
764
+ ----------
765
+ payment_ids : List[str]
766
+ Payment IDs to query.
767
+ min_block_height : int
768
+ The minimum block height to scan.
769
+
770
+ Returns
771
+ -------
772
+ Dict[str, Any]
773
+ The response from wallet RPC.
774
+
775
+ """
776
+ return await self._request(
777
+ "get_bulk_payments",
778
+ {"payment_ids": payment_ids, "min_block_height": min_block_height},
779
+ )
780
+
781
+ async def incoming_transfers(
782
+ self,
783
+ transfer_type: str,
784
+ account_index: int,
785
+ subaddr_indices: List[int],
786
+ verbose: Optional[bool] = False,
787
+ ) -> Dict[str, Any]:
788
+ """
789
+ Return a list of incoming transfers to the wallet.
790
+
791
+ Parameters
792
+ ----------
793
+ transfer_type : str
794
+ "all": all the transfers.
795
+ "available": only transfers which are not yet spent.
796
+ "unavailable": only transfers which are already spent.
797
+ account_index : int
798
+ Return transfers for this account.
799
+ subaddr_indices : List[int]
800
+ Array of subaddress indices to query.
801
+ verbose : bool, optional
802
+ Enable verbose output.
803
+
804
+ Returns
805
+ -------
806
+ Dict[str, Any]
807
+ The response from wallet RPC.
808
+
809
+ """
810
+ return await self._request(
811
+ "incoming_transfers",
812
+ {
813
+ "transfer_type": transfer_type,
814
+ "account_index": account_index,
815
+ "subaddr_indices": subaddr_indices,
816
+ "verbose": verbose,
817
+ },
818
+ )
819
+
820
+ async def query_key(self, key_type: str) -> Dict[str, Any]:
821
+ """
822
+ Return the spend or view private key.
823
+
824
+ Parameters
825
+ ----------
826
+ key_type : str
827
+ "mnemonic": the mnemonic seed.
828
+ "view_key": the view key.
829
+ "spend_key": the spend key.
830
+ "seed": the mnemonic seed.
831
+
832
+ Returns
833
+ -------
834
+ Dict[str, Any]
835
+ The response from wallet RPC.
836
+
837
+ """
838
+ return await self._request("query_key", {"key_type": key_type})
839
+
840
+ async def make_integrated_address(
841
+ self, payment_id: str, standard_address: Optional[str] = None
842
+ ) -> Dict[str, Any]:
843
+ """
844
+ Make an integrated address from the wallet address and a payment ID.
845
+
846
+ Parameters
847
+ ----------
848
+ payment_id : str
849
+ Payment ID.
850
+ standard_address : str, optional
851
+ Destination public address. If not provided, the wallet's address is used.
852
+
853
+ Returns
854
+ -------
855
+ Dict[str, Any]
856
+ The response from wallet RPC.
857
+
858
+ """
859
+ return await self._request(
860
+ "make_integrated_address",
861
+ {"payment_id": payment_id, "standard_address": standard_address},
862
+ )
863
+
864
+ async def split_integrated_address(
865
+ self, integrated_address: str
866
+ ) -> Dict[str, Any]:
867
+ """
868
+ Retrieve the standard address and payment ID corresponding to an integrated address.
869
+
870
+ Parameters
871
+ ----------
872
+ integrated_address : str
873
+ Integrated address to split.
874
+
875
+ Returns
876
+ -------
877
+ Dict[str, Any]
878
+ The response from wallet RPC.
879
+
880
+ """
881
+ return await self._request(
882
+ "split_integrated_address", {"integrated_address": integrated_address}
883
+ )
884
+
885
+ async def stop_wallet(self) -> Dict[str, Any]:
886
+ """
887
+ Stop the wallet.
888
+
889
+ Returns
890
+ -------
891
+ Dict[str, Any]
892
+ The response from wallet RPC.
893
+
894
+ """
895
+ return await self._request("stop_wallet", {})
896
+
897
+ async def rescan_blockchain(self) -> Dict[str, Any]:
898
+ """
899
+ Re-scan the blockchain.
900
+
901
+ Returns
902
+ -------
903
+ Dict[str, Any]
904
+ The response from wallet RPC.
905
+
906
+ """
907
+ return await self._request("rescan_blockchain", {})
908
+
909
+ async def set_tx_notes(
910
+ self, txids: List[str], notes: List[str]
911
+ ) -> Dict[str, Any]:
912
+ """
913
+ Set arbitrary string notes for transactions.
914
+
915
+ Parameters
916
+ ----------
917
+ txids : List[str]
918
+ Array of transaction IDs.
919
+ notes : List[str]
920
+ Notes for the transactions.
921
+
922
+ Returns
923
+ -------
924
+ Dict[str, Any]
925
+ The response from wallet RPC.
926
+
927
+ """
928
+ return await self._request("set_tx_notes", {"txids": txids, "notes": notes})
929
+
930
+ async def get_tx_notes(self, txids: List[str]) -> Dict[str, Any]:
931
+ """
932
+ Get string notes for transactions.
933
+
934
+ Parameters
935
+ ----------
936
+ txids : List[str]
937
+ Array of transaction IDs.
938
+
939
+ Returns
940
+ -------
941
+ Dict[str, Any]
942
+ The response from wallet RPC.
943
+
944
+ """
945
+ return await self._request("get_tx_notes", {"txids": txids})
946
+
947
+ async def set_attribute(self, key: str, value: str) -> Dict[str, Any]:
948
+ """
949
+ Set arbitrary attribute.
950
+
951
+ Parameters
952
+ ----------
953
+ key : str
954
+ Attribute name.
955
+ value : str
956
+ Attribute value.
957
+
958
+ Returns
959
+ -------
960
+ Dict[str, Any]
961
+ The response from wallet RPC.
962
+
963
+ """
964
+ return await self._request("set_attribute", {"key": key, "value": value})
965
+
966
+ async def get_attribute(self, key: str) -> Dict[str, Any]:
967
+ """
968
+ Get an attribute.
969
+
970
+ Parameters
971
+ ----------
972
+ key : str
973
+ Attribute name.
974
+
975
+ Returns
976
+ -------
977
+ Dict[str, Any]
978
+ The response from wallet RPC.
979
+
980
+ """
981
+ return await self._request("get_attribute", {"key": key})
982
+
983
+ async def get_tx_key(self, txid: str) -> Dict[str, Any]:
984
+ """
985
+ Get transaction secret key.
986
+
987
+ Parameters
988
+ ----------
989
+ txid : str
990
+ Transaction ID.
991
+
992
+ Returns
993
+ -------
994
+ Dict[str, Any]
995
+ The response from wallet RPC.
996
+
997
+ """
998
+ return await self._request("get_tx_key", {"txid": txid})
999
+
1000
+ async def check_tx_key(
1001
+ self, txid: str, tx_key: str, address: str
1002
+ ) -> Dict[str, Any]:
1003
+ """
1004
+ Check a transaction in the blockchain with its secret key.
1005
+
1006
+ Parameters
1007
+ ----------
1008
+ txid : str
1009
+ Transaction ID.
1010
+ tx_key : str
1011
+ Transaction secret key.
1012
+ address : str
1013
+ Destination public address.
1014
+
1015
+ Returns
1016
+ -------
1017
+ Dict[str, Any]
1018
+ The response from wallet RPC.
1019
+
1020
+ """
1021
+ return await self._request(
1022
+ "check_tx_key", {"txid": txid, "tx_key": tx_key, "address": address}
1023
+ )
1024
+
1025
+ async def get_tx_proof(
1026
+ self, txid: str, address: str, message: Optional[str] = None
1027
+ ) -> Dict[str, Any]:
1028
+ """
1029
+ Generate a signature to prove a transaction in the blockchain.
1030
+
1031
+ Parameters
1032
+ ----------
1033
+ txid : str
1034
+ Transaction ID.
1035
+ address : str
1036
+ Destination public address.
1037
+ message : str, optional
1038
+ Add a message to the signature to further authenticate.
1039
+
1040
+ Returns
1041
+ -------
1042
+ Dict[str, Any]
1043
+ The response from wallet RPC.
1044
+
1045
+ """
1046
+ return await self._request(
1047
+ "get_tx_proof", {"txid": txid, "address": address, "message": message}
1048
+ )
1049
+
1050
+ async def check_tx_proof(
1051
+ self, txid: str, address: str, signature: str, message: Optional[str] = None
1052
+ ) -> Dict[str, Any]:
1053
+ """
1054
+ Prove a transaction by checking its signature.
1055
+
1056
+ Parameters
1057
+ ----------
1058
+ txid : str
1059
+ Transaction ID.
1060
+ address : str
1061
+ Destination public address.
1062
+ signature : str
1063
+ Transaction signature.
1064
+ message : str, optional
1065
+ Add a message to the signature to further authenticate.
1066
+
1067
+ Returns
1068
+ -------
1069
+ Dict[str, Any]
1070
+ The response from wallet RPC.
1071
+
1072
+ """
1073
+ return await self._request(
1074
+ "check_tx_proof",
1075
+ {
1076
+ "txid": txid,
1077
+ "address": address,
1078
+ "signature": signature,
1079
+ "message": message,
1080
+ },
1081
+ )
1082
+
1083
+ async def get_spend_proof(
1084
+ self, txid: str, message: Optional[str] = None
1085
+ ) -> Dict[str, Any]:
1086
+ """
1087
+ Generate a signature to prove a spend using the key of the transaction.
1088
+
1089
+ Parameters
1090
+ ----------
1091
+ txid : str
1092
+ Transaction ID.
1093
+ message : str, optional
1094
+ Add a message to the signature to further authenticate.
1095
+
1096
+ Returns
1097
+ -------
1098
+ Dict[str, Any]
1099
+ The response from wallet RPC.
1100
+
1101
+ """
1102
+ return await self._request(
1103
+ "get_spend_proof", {"txid": txid, "message": message}
1104
+ )
1105
+
1106
+ async def check_spend_proof(
1107
+ self, txid: str, signature: str, message: Optional[str] = None
1108
+ ) -> Dict[str, Any]:
1109
+ """
1110
+ Prove a spend using the key of the transaction.
1111
+
1112
+ Parameters
1113
+ ----------
1114
+ txid : str
1115
+ Transaction ID.
1116
+ signature : str
1117
+ Spend signature.
1118
+ message : str, optional
1119
+ Add a message to the signature to further authenticate.
1120
+
1121
+ Returns
1122
+ -------
1123
+ Dict[str, Any]
1124
+ The response from wallet RPC.
1125
+
1126
+ """
1127
+ return await self._request(
1128
+ "check_spend_proof",
1129
+ {"txid": txid, "message": message, "signature": signature},
1130
+ )
1131
+
1132
+ async def get_reserve_proof(
1133
+ self,
1134
+ all_reserve: bool,
1135
+ account_index: int,
1136
+ amount: int,
1137
+ message: Optional[str] = None,
1138
+ ) -> Dict[str, Any]:
1139
+ """
1140
+ Generate a signature to prove of a reserve proof.
1141
+
1142
+ Parameters
1143
+ ----------
1144
+ all_reserve : bool
1145
+ Proves all wallet reserve.
1146
+ account_index : int
1147
+ Account to prove reserve for.
1148
+ amount : int
1149
+ Amount to prove.
1150
+ message : str, optional
1151
+ Add a message to the signature to further authenticate.
1152
+
1153
+ Returns
1154
+ -------
1155
+ Dict[str, Any]
1156
+ The response from wallet RPC.
1157
+
1158
+ """
1159
+ return await self._request(
1160
+ "get_reserve_proof",
1161
+ {
1162
+ "all": all_reserve,
1163
+ "account_index": account_index,
1164
+ "amount": amount,
1165
+ "message": message,
1166
+ },
1167
+ )
1168
+
1169
+ async def check_reserve_proof(
1170
+ self, address: str, signature: str, message: Optional[str] = None
1171
+ ) -> Dict[str, Any]:
1172
+ """
1173
+ Prove a wallet has a disposable reserve using a signature.
1174
+
1175
+ Parameters
1176
+ ----------
1177
+ address : str
1178
+ Public address.
1179
+ signature : str
1180
+ Reserve proof signature.
1181
+ message : str, optional
1182
+ Add a message to the signature to further authenticate.
1183
+
1184
+ Returns
1185
+ -------
1186
+ Dict[str, Any]
1187
+ The response from wallet RPC.
1188
+
1189
+ """
1190
+ return await self._request(
1191
+ "check_reserve_proof",
1192
+ {"address": address, "message": message, "signature": signature},
1193
+ )
1194
+
1195
+ async def get_transfers(
1196
+ self,
1197
+ incoming: Optional[bool] = False,
1198
+ outgoing: Optional[bool] = False,
1199
+ pending: Optional[bool] = False,
1200
+ failed: Optional[bool] = False,
1201
+ pool: Optional[bool] = False,
1202
+ filter_by_height: Optional[bool] = False,
1203
+ min_height: Optional[int] = None,
1204
+ max_height: Optional[int] = None,
1205
+ account_index: Optional[int] = None,
1206
+ subaddr_indices: Optional[List[int]] = None,
1207
+ ) -> Dict[str, Any]:
1208
+ """
1209
+ Return a list of transfers.
1210
+
1211
+ Parameters
1212
+ ----------
1213
+ incoming : bool, optional
1214
+ Include incoming transfers.
1215
+ outgoing : bool, optional
1216
+ Include outgoing transfers.
1217
+ pending : bool, optional
1218
+ Include pending transfers.
1219
+ failed : bool, optional
1220
+ Include failed transfers.
1221
+ pool : bool, optional
1222
+ Include transfers from the daemon's transaction pool.
1223
+ filter_by_height : bool, optional
1224
+ Filter transfers by block height.
1225
+ min_height : int, optional
1226
+ Minimum block height to scan for transfers.
1227
+ max_height : int, optional
1228
+ Maximum block height to scan for transfers.
1229
+ account_index : int, optional
1230
+ Return transfers for this account.
1231
+ subaddr_indices : List[int], optional
1232
+ Array of subaddress indices to query.
1233
+
1234
+ Returns
1235
+ -------
1236
+ Dict[str, Any]
1237
+ The response from wallet RPC.
1238
+
1239
+ """
1240
+ return await self._request(
1241
+ "get_transfers",
1242
+ {
1243
+ "in": incoming,
1244
+ "out": outgoing,
1245
+ "pending": pending,
1246
+ "failed": failed,
1247
+ "pool": pool,
1248
+ "filter_by_height": filter_by_height,
1249
+ "min_height": min_height,
1250
+ "max_height": max_height,
1251
+ "account_index": account_index,
1252
+ "subaddr_indices": subaddr_indices or [],
1253
+ },
1254
+ )
1255
+
1256
+ async def get_transfer_by_txid(
1257
+ self, txid: str, account_index: Optional[int] = None
1258
+ ) -> Dict[str, Any]:
1259
+ """
1260
+ Return a list of transfers for the given txid.
1261
+
1262
+ Parameters
1263
+ ----------
1264
+ txid : str
1265
+ Transaction ID.
1266
+ account_index : int, optional
1267
+ Return transfers for this account.
1268
+
1269
+ Returns
1270
+ -------
1271
+ Dict[str, Any]
1272
+ The response from wallet RPC.
1273
+
1274
+ """
1275
+ return await self._request(
1276
+ "get_transfer_by_txid", {"txid": txid, "account_index": account_index}
1277
+ )
1278
+
1279
+ async def sign(self, data: str) -> Dict[str, Any]:
1280
+ """
1281
+ Sign a string.
1282
+
1283
+ Parameters
1284
+ ----------
1285
+ data : str
1286
+ Data to sign.
1287
+
1288
+ Returns
1289
+ -------
1290
+ Dict[str, Any]
1291
+ The response from wallet RPC.
1292
+
1293
+ """
1294
+ return await self._request("sign", {"data": data})
1295
+
1296
+ async def verify(
1297
+ self, data: str, address: str, signature: str
1298
+ ) -> Dict[str, Any]:
1299
+ """
1300
+ Verify a signature on a string.
1301
+
1302
+ Parameters
1303
+ ----------
1304
+ data : str
1305
+ Data to verify.
1306
+ address : str
1307
+ Public address.
1308
+ signature : str
1309
+ Signature to verify.
1310
+
1311
+ Returns
1312
+ -------
1313
+ Dict[str, Any]
1314
+ The response from wallet RPC.
1315
+
1316
+ """
1317
+ return await self._request(
1318
+ "verify", {"data": data, "address": address, "signature": signature}
1319
+ )
1320
+
1321
+ async def export_outputs(self) -> Dict[str, Any]:
1322
+ """
1323
+ Export all outputs in hex format.
1324
+
1325
+ Returns
1326
+ -------
1327
+ Dict[str, Any]
1328
+ The response from wallet RPC.
1329
+
1330
+ """
1331
+ return await self._request("export_outputs", {})
1332
+
1333
+ async def import_outputs(self, outputs_data_hex: str) -> Dict[str, Any]:
1334
+ """
1335
+ Import outputs in hex format.
1336
+
1337
+ Parameters
1338
+ ----------
1339
+ outputs_data_hex : str
1340
+ Outputs to import in hex format.
1341
+
1342
+ Returns
1343
+ -------
1344
+ Dict[str, Any]
1345
+ The response from wallet RPC.
1346
+
1347
+ """
1348
+ return await self._request(
1349
+ "import_outputs", {"outputs_data_hex": outputs_data_hex}
1350
+ )
1351
+
1352
+ async def export_key_images(self) -> Dict[str, Any]:
1353
+ """
1354
+ Export a signed set of key images.
1355
+
1356
+ Returns
1357
+ -------
1358
+ Dict[str, Any]
1359
+ The response from wallet RPC.
1360
+
1361
+ """
1362
+ return await self._request("export_key_images", {})
1363
+
1364
+ async def import_key_images(
1365
+ self, signed_key_images: List[str], key_image: str, signature: str
1366
+ ) -> Dict[str, Any]:
1367
+ """
1368
+ Import signed key images list and verify their spent status.
1369
+
1370
+ Parameters
1371
+ ----------
1372
+ signed_key_images : List[str]
1373
+ Array of signed key images in hex format.
1374
+ key_image : str
1375
+ Key image to import.
1376
+ signature : str
1377
+ Signature of the key image.
1378
+
1379
+ Returns
1380
+ -------
1381
+ Dict[str, Any]
1382
+ The response from wallet RPC.
1383
+
1384
+ """
1385
+ return await self._request(
1386
+ "import_key_images",
1387
+ {
1388
+ "signed_key_images": signed_key_images,
1389
+ "key_image": key_image,
1390
+ "signature": signature,
1391
+ },
1392
+ )
1393
+
1394
+ async def make_uri(
1395
+ self,
1396
+ address: str,
1397
+ amount: Optional[int] = None,
1398
+ payment_id: Optional[str] = None,
1399
+ recipient_name: Optional[str] = None,
1400
+ tx_description: Optional[str] = None,
1401
+ ) -> Dict[str, Any]:
1402
+ """
1403
+ Create a payment URI using the official URI spec.
1404
+
1405
+ Parameters
1406
+ ----------
1407
+ address : str
1408
+ Destination public address.
1409
+ amount : int, optional
1410
+ Amount to send.
1411
+ payment_id : str, optional
1412
+ Random 32-byte/64-character hex string to identify a transaction.
1413
+ recipient_name : str, optional
1414
+ Name of the payment recipient.
1415
+ tx_description : str, optional
1416
+ Description of the reason for the tx.
1417
+
1418
+ Returns
1419
+ -------
1420
+ Dict[str, Any]
1421
+ The response from wallet RPC.
1422
+
1423
+ """
1424
+ return await self._request(
1425
+ "make_uri",
1426
+ {
1427
+ "address": address,
1428
+ "amount": amount,
1429
+ "payment_id": payment_id,
1430
+ "recipient_name": recipient_name,
1431
+ "tx_description": tx_description,
1432
+ },
1433
+ )
1434
+
1435
+ async def parse_uri(self, uri: str) -> Dict[str, Any]:
1436
+ """
1437
+ Parse a payment URI to get payment information.
1438
+
1439
+ Parameters
1440
+ ----------
1441
+ uri : str
1442
+ Payment URI.
1443
+
1444
+ Returns
1445
+ -------
1446
+ Dict[str, Any]
1447
+ The response from wallet RPC.
1448
+
1449
+ """
1450
+ return await self._request("parse_uri", {"uri": uri})
1451
+
1452
+ async def get_address_book(self, entries: List[int]) -> Dict[str, Any]:
1453
+ """
1454
+ Return the wallet's address book.
1455
+
1456
+ Parameters
1457
+ ----------
1458
+ entries : List[int]
1459
+ Array of address book entries.
1460
+
1461
+ Returns
1462
+ -------
1463
+ Dict[str, Any]
1464
+ The response from wallet RPC.
1465
+
1466
+ """
1467
+ return await self._request("get_address_book", {"entries": entries})
1468
+
1469
+ async def add_address_book(
1470
+ self,
1471
+ address: str,
1472
+ payment_id: Optional[str] = None,
1473
+ description: Optional[str] = None,
1474
+ ) -> Dict[str, Any]:
1475
+ """
1476
+ Add an entry to the wallet's address book.
1477
+
1478
+ Parameters
1479
+ ----------
1480
+ address : str
1481
+ Destination public address.
1482
+ payment_id : str, optional
1483
+ Random 32-byte/64-character hex string to identify a transaction.
1484
+ description : str, optional
1485
+ Description of the address.
1486
+
1487
+ Returns
1488
+ -------
1489
+ Dict[str, Any]
1490
+ The response from wallet RPC.
1491
+
1492
+ """
1493
+ return await self._request(
1494
+ "add_address_book",
1495
+ {
1496
+ "address": address,
1497
+ "payment_id": payment_id,
1498
+ "description": description,
1499
+ },
1500
+ )
1501
+
1502
+ async def edit_address_book(
1503
+ self,
1504
+ index: int,
1505
+ set_address: Optional[bool] = False,
1506
+ address: Optional[str] = None,
1507
+ set_description: Optional[bool] = False,
1508
+ description: Optional[str] = None,
1509
+ set_payment_id: Optional[bool] = False,
1510
+ payment_id: Optional[str] = None,
1511
+ ) -> Dict[str, Any]:
1512
+ """
1513
+ Edit an existing entry in the wallet's address book.
1514
+
1515
+ Parameters
1516
+ ----------
1517
+ index : int
1518
+ The index of the address book entry to edit.
1519
+ set_address : bool, optional
1520
+ Set the address.
1521
+ address : str, optional
1522
+ Destination public address.
1523
+ set_description : bool, optional
1524
+ Set the description.
1525
+ description : str, optional
1526
+ Description of the address.
1527
+ set_payment_id : bool, optional
1528
+ Set the payment ID.
1529
+ payment_id : str, optional
1530
+ Random 32-byte/64-character hex string to identify a transaction.
1531
+
1532
+ Returns
1533
+ -------
1534
+ Dict[str, Any]
1535
+ The response from wallet RPC.
1536
+
1537
+ """
1538
+ return await self._request(
1539
+ "edit_address_book",
1540
+ {
1541
+ "index": index,
1542
+ "set_address": set_address,
1543
+ "address": address,
1544
+ "set_description": set_description,
1545
+ "description": description,
1546
+ "set_payment_id": set_payment_id,
1547
+ "payment_id": payment_id,
1548
+ },
1549
+ )
1550
+
1551
+ async def delete_address_book(self, index: int) -> Dict[str, Any]:
1552
+ """
1553
+ Delete an entry from the wallet's address book.
1554
+
1555
+ Parameters
1556
+ ----------
1557
+ index : int
1558
+ The index of the address book entry to delete.
1559
+
1560
+ Returns
1561
+ -------
1562
+ Dict[str, Any]
1563
+ The response from wallet RPC.
1564
+
1565
+ """
1566
+ return await self._request("delete_address_book", {"index": index})
1567
+
1568
+ async def refresh(self, start_height: Optional[int] = None) -> Dict[str, Any]:
1569
+ """
1570
+ Refresh the wallet.
1571
+
1572
+ Parameters
1573
+ ----------
1574
+ start_height : int, optional
1575
+ Start height to refresh from.
1576
+
1577
+ Returns
1578
+ -------
1579
+ Dict[str, Any]
1580
+ The response from wallet RPC.
1581
+
1582
+ """
1583
+ return await self._request("refresh", {"start_height": start_height})
1584
+
1585
+ async def auto_refresh(
1586
+ self, enable: Optional[bool] = True, period: Optional[int] = None
1587
+ ) -> Dict[str, Any]:
1588
+ """
1589
+ Set whether to automatically refresh the wallet.
1590
+
1591
+ Parameters
1592
+ ----------
1593
+ enable : bool
1594
+ Enable or disable auto refresh.
1595
+ period : int, optional
1596
+ Set the refresh period.
1597
+
1598
+ Returns
1599
+ -------
1600
+ Dict[str, Any]
1601
+ The response from wallet RPC.
1602
+
1603
+ """
1604
+ return await self._request(
1605
+ "auto_refresh", {"enable": enable, "period": period}
1606
+ )
1607
+
1608
+ async def rescan_spent(self) -> Dict[str, Any]:
1609
+ """
1610
+ Re-scan spent outputs.
1611
+
1612
+ Returns
1613
+ -------
1614
+ Dict[str, Any]
1615
+ The response from wallet RPC.
1616
+
1617
+ """
1618
+ return await self._request("rescan_spent", {})
1619
+
1620
+ async def start_mining(
1621
+ self, threads_count: int, do_background_mining: bool, ignore_battery: bool
1622
+ ) -> Dict[str, Any]:
1623
+ """
1624
+ Start mining in the wallet.
1625
+
1626
+ Parameters
1627
+ ----------
1628
+ threads_count : int
1629
+ Number of threads to use for mining.
1630
+ do_background_mining : bool
1631
+ If true, mine in the background.
1632
+ ignore_battery : bool
1633
+ If true, mine even if battery is low.
1634
+
1635
+ Returns
1636
+ -------
1637
+ Dict[str, Any]
1638
+ The response from wallet RPC.
1639
+
1640
+ """
1641
+ return await self._request(
1642
+ "start_mining",
1643
+ {
1644
+ "threads_count": threads_count,
1645
+ "do_background_mining": do_background_mining,
1646
+ "ignore_battery": ignore_battery,
1647
+ },
1648
+ )
1649
+
1650
+ async def set_donate_level(self, blocks: int) -> Dict[str, Any]:
1651
+ """
1652
+ Set the donation level for the Nerva network.
1653
+
1654
+ Parameters
1655
+ ----------
1656
+ blocks : int
1657
+ Number of blocks to donate.
1658
+
1659
+ Returns
1660
+ -------
1661
+ Dict[str, Any]
1662
+ The response from wallet RPC.
1663
+
1664
+ """
1665
+ return await self._request("set_donate_level", {"blocks": blocks})
1666
+
1667
+ async def stop_mining(self) -> Dict[str, Any]:
1668
+ """
1669
+ Stop mining in the wallet.
1670
+
1671
+ Returns
1672
+ -------
1673
+ Dict[str, Any]
1674
+ The response from wallet RPC.
1675
+
1676
+ """
1677
+ return await self._request("stop_mining", {})
1678
+
1679
+ async def get_languages(self) -> Dict[str, Any]:
1680
+ """
1681
+ Return the list of available languages for the wallet's seed.
1682
+
1683
+ Returns
1684
+ -------
1685
+ Dict[str, Any]
1686
+ The response from wallet RPC.
1687
+
1688
+ """
1689
+ return await self._request("get_languages", {})
1690
+
1691
+ async def create_wallet(
1692
+ self,
1693
+ filename: str,
1694
+ language: str,
1695
+ password: Optional[str] = None,
1696
+ ) -> Dict[str, Any]:
1697
+ """
1698
+ Create a new wallet.
1699
+
1700
+ Parameters
1701
+ ----------
1702
+ filename : str
1703
+ Wallet file name.
1704
+ language : str
1705
+ Language for seed.
1706
+ password : str, optional
1707
+ Wallet password.
1708
+
1709
+ Returns
1710
+ -------
1711
+ Dict[str, Any]
1712
+ The response from wallet RPC.
1713
+
1714
+ """
1715
+ return await self._request(
1716
+ "create_wallet",
1717
+ {
1718
+ "filename": filename,
1719
+ "password": password or "",
1720
+ "language": language,
1721
+ },
1722
+ )
1723
+
1724
+ async def create_hw_wallet(
1725
+ self, filename: str, language: str, device_name: str, restore_height: int
1726
+ ) -> Dict[str, Any]:
1727
+ """
1728
+ Create a wallet from a hardware device.
1729
+
1730
+ Parameters
1731
+ ----------
1732
+ filename : str
1733
+ Wallet file name.
1734
+ language : str
1735
+ Wallet language.
1736
+ device_name : str
1737
+ Hardware device name.
1738
+ restore_height : int
1739
+ Wallet restore height.
1740
+
1741
+ Returns
1742
+ -------
1743
+ Dict[str, Any]
1744
+ The response from wallet RPC.
1745
+
1746
+ """
1747
+ return await self._request(
1748
+ "create_hw_wallet",
1749
+ {
1750
+ "filename": filename,
1751
+ "language": language,
1752
+ "device_name": device_name,
1753
+ "restore_height": restore_height,
1754
+ },
1755
+ )
1756
+
1757
+ async def open_wallet(
1758
+ self, filename: str, password: Optional[str] = None
1759
+ ) -> Dict[str, Any]:
1760
+ """
1761
+ Open a wallet.
1762
+
1763
+ Parameters
1764
+ ----------
1765
+ filename : str
1766
+ Wallet file name.
1767
+ password : str, optional
1768
+ Wallet password.
1769
+
1770
+ Returns
1771
+ -------
1772
+ Dict[str, Any]
1773
+ The response from wallet RPC.
1774
+
1775
+ """
1776
+ return await self._request(
1777
+ "open_wallet", {"filename": filename, "password": password or ""}
1778
+ )
1779
+
1780
+ async def close_wallet(self) -> Dict[str, Any]:
1781
+ """
1782
+ Close the wallet.
1783
+
1784
+ Returns
1785
+ -------
1786
+ Dict[str, Any]
1787
+ The response from wallet RPC.
1788
+
1789
+ """
1790
+ return await self._request("close_wallet", {})
1791
+
1792
+ async def change_wallet_password(
1793
+ self, old_password: Optional[str] = None, new_password: Optional[str] = None
1794
+ ) -> Dict[str, Any]:
1795
+ """
1796
+ Change the wallet password.
1797
+
1798
+ Parameters
1799
+ ----------
1800
+ old_password : str, optional
1801
+ Old wallet password.
1802
+ new_password : str, optional
1803
+ New wallet password.
1804
+
1805
+ Returns
1806
+ -------
1807
+ Dict[str, Any]
1808
+ The response from wallet RPC.
1809
+
1810
+ """
1811
+ return await self._request(
1812
+ "change_wallet_password",
1813
+ {"old_password": old_password or "", "new_password": new_password or ""},
1814
+ )
1815
+
1816
+ async def restore_wallet_from_seed(
1817
+ self, filename: str, seed: str, restore_height: int
1818
+ ) -> Dict[str, Any]:
1819
+ """
1820
+ Restore a wallet from a mnemonic seed.
1821
+
1822
+ Parameters
1823
+ ----------
1824
+ filename : str
1825
+ Wallet file name.
1826
+ seed : str
1827
+ Wallet mnemonic seed.
1828
+ restore_height : int
1829
+ Wallet restore height.
1830
+
1831
+ Returns
1832
+ -------
1833
+ Dict[str, Any]
1834
+ The response from wallet RPC.
1835
+
1836
+ """
1837
+ return await self._request(
1838
+ "restore_wallet_from_seed",
1839
+ {"filename": filename, "seed": seed, "restore_height": restore_height},
1840
+ )
1841
+
1842
+ async def restore_wallet_from_keys(
1843
+ self,
1844
+ filename: str,
1845
+ address: str,
1846
+ viewkey: str,
1847
+ spendkey: str,
1848
+ restore_height: int,
1849
+ ) -> Dict[str, Any]:
1850
+ """
1851
+ Restore a wallet from a set of keys.
1852
+
1853
+ Parameters
1854
+ ----------
1855
+ filename : str
1856
+ Wallet file name.
1857
+ address : str
1858
+ Wallet public address.
1859
+ viewkey : str
1860
+ Wallet view key.
1861
+ spendkey : str
1862
+ Wallet spend key.
1863
+ restore_height : int
1864
+ Wallet restore height.
1865
+
1866
+ Returns
1867
+ -------
1868
+ Dict[str, Any]
1869
+ The response from wallet RPC.
1870
+
1871
+ """
1872
+ return await self._request(
1873
+ "restore_wallet_from_keys",
1874
+ {
1875
+ "filename": filename,
1876
+ "address": address,
1877
+ "viewkey": viewkey,
1878
+ "spendkey": spendkey,
1879
+ "restore_height": restore_height,
1880
+ },
1881
+ )
1882
+
1883
+ async def is_multisig(self) -> Dict[str, Any]:
1884
+ """
1885
+ Check if the wallet is a multisig wallet.
1886
+
1887
+ Returns
1888
+ -------
1889
+ Dict[str, Any]
1890
+ The response from wallet RPC.
1891
+
1892
+ """
1893
+ return await self._request("is_multisig", {})
1894
+
1895
+ async def prepare_multisig(self) -> Dict[str, Any]:
1896
+ """
1897
+ Prepare a wallet for multisig use.
1898
+
1899
+ Returns
1900
+ -------
1901
+ Dict[str, Any]
1902
+ The response from wallet RPC.
1903
+
1904
+ """
1905
+ return await self._request("prepare_multisig", {})
1906
+
1907
+ async def make_multisig(
1908
+ self, multisig_info: List[str], threshold: int, password: str
1909
+ ) -> Dict[str, Any]:
1910
+ """
1911
+ Make a wallet multisig.
1912
+
1913
+ Parameters
1914
+ ----------
1915
+ multisig_info : List[str]
1916
+ Array of multisig info from other participants.
1917
+ threshold : int
1918
+ Number of signatures needed to sign a transfer.
1919
+ password : str
1920
+ Wallet password.
1921
+
1922
+ Returns
1923
+ -------
1924
+ Dict[str, Any]
1925
+ The response from wallet RPC.
1926
+
1927
+ """
1928
+ return await self._request(
1929
+ "make_multisig",
1930
+ {
1931
+ "multisig_info": multisig_info,
1932
+ "threshold": threshold,
1933
+ "password": password,
1934
+ },
1935
+ )
1936
+
1937
+ async def export_multisig_info(self) -> Dict[str, Any]:
1938
+ """
1939
+ Export multisig info for other participants.
1940
+
1941
+ Returns
1942
+ -------
1943
+ Dict[str, Any]
1944
+ The response from wallet RPC.
1945
+
1946
+ """
1947
+ return await self._request("export_multisig_info", {})
1948
+
1949
+ async def import_multisig_info(self, info: List[str]) -> Dict[str, Any]:
1950
+ """
1951
+ Import multisig info from other participants.
1952
+
1953
+ Parameters
1954
+ ----------
1955
+ info : List[str]
1956
+ Array of multisig info from other participants.
1957
+
1958
+ Returns
1959
+ -------
1960
+ Dict[str, Any]
1961
+ The response from wallet RPC.
1962
+
1963
+ """
1964
+ return await self._request("import_multisig_info", {"info": info})
1965
+
1966
+ async def finalize_multisig(
1967
+ self, multisig_info: List[str], password: str
1968
+ ) -> Dict[str, Any]:
1969
+ """
1970
+ Finalize a multisig wallet.
1971
+
1972
+ Parameters
1973
+ ----------
1974
+ multisig_info : List[str]
1975
+ Array of multisig info from other participants.
1976
+ password : str
1977
+ Wallet password.
1978
+
1979
+ Returns
1980
+ -------
1981
+ Dict[str, Any]
1982
+ The response from wallet RPC.
1983
+
1984
+ """
1985
+ return await self._request(
1986
+ "finalize_multisig",
1987
+ {"multisig_info": multisig_info, "password": password},
1988
+ )
1989
+
1990
+ async def exchange_multisig_keys(
1991
+ self, multisig_info: List[str], password: str
1992
+ ) -> Dict[str, Any]:
1993
+ """
1994
+ Exchange multisig keys with other participants.
1995
+
1996
+ Parameters
1997
+ ----------
1998
+ multisig_info : List[str]
1999
+ Array of multisig info from other participants.
2000
+ password : str
2001
+ Wallet password.
2002
+
2003
+ Returns
2004
+ -------
2005
+ Dict[str, Any]
2006
+ The response from wallet RPC.
2007
+
2008
+ """
2009
+ return await self._request(
2010
+ "exchange_multisig_keys",
2011
+ {"multisig_info": multisig_info, "password": password},
2012
+ )
2013
+
2014
+ async def sign_multisig(self, tx_data_hex: str) -> Dict[str, Any]:
2015
+ """
2016
+ Sign a multisig transaction.
2017
+
2018
+ Parameters
2019
+ ----------
2020
+ tx_data_hex : str
2021
+ Transaction in hex format.
2022
+
2023
+ Returns
2024
+ -------
2025
+ Dict[str, Any]
2026
+ The response from wallet RPC.
2027
+
2028
+ """
2029
+ return await self._request("sign_multisig", {"tx_data_hex": tx_data_hex})
2030
+
2031
+ async def submit_multisig(self, tx_data_hex: str) -> Dict[str, Any]:
2032
+ """
2033
+ Submit a signed multisig transaction.
2034
+
2035
+ Parameters
2036
+ ----------
2037
+ tx_data_hex : str
2038
+ Transaction in hex format.
2039
+
2040
+ Returns
2041
+ -------
2042
+ Dict[str, Any]
2043
+ The submitted transaction.
2044
+
2045
+ """
2046
+ return await self._request("submit_multisig", {"tx_data_hex": tx_data_hex})
2047
+
2048
+ async def validate_address(
2049
+ self,
2050
+ address: str,
2051
+ any_net_type: Optional[bool] = False,
2052
+ allow_openalias: Optional[bool] = False,
2053
+ ) -> Dict[str, Any]:
2054
+ """
2055
+ Validate a public address.
2056
+
2057
+ Parameters
2058
+ ----------
2059
+ address : str
2060
+ Public address.
2061
+ any_net_type : bool, optional
2062
+ Allow any net type.
2063
+ allow_openalias : bool, optional
2064
+ Allow OpenAlias addresses.
2065
+
2066
+
2067
+ Returns
2068
+ -------
2069
+ Dict[str, Any]
2070
+ The response from wallet RPC.
2071
+
2072
+ """
2073
+ return await self._request(
2074
+ "validate_address",
2075
+ {
2076
+ "address": address,
2077
+ "any_net_type": any_net_type,
2078
+ "allow_openalias": allow_openalias,
2079
+ },
2080
+ )
2081
+
2082
+ async def set_daemon(
2083
+ self,
2084
+ address: str,
2085
+ trusted: bool,
2086
+ ssl_support: Optional[str] = "autodetect",
2087
+ ssl_private_key_path: Optional[str] = None,
2088
+ ssl_certificate_path: Optional[str] = None,
2089
+ ssl_ca_file: Optional[str] = None,
2090
+ ssl_allowed_fingerprints: Optional[List[str]] = None,
2091
+ ssl_allow_any_cert: Optional[bool] = False,
2092
+ ) -> Dict[str, Any]:
2093
+ """
2094
+ Set the daemon address.
2095
+
2096
+ Parameters
2097
+ ----------
2098
+ address : str
2099
+ Daemon public address.
2100
+ trusted : bool
2101
+ If true, trust the daemon.
2102
+ ssl_support : str, optional
2103
+ SSL support (autodetect, enabled, disabled).
2104
+ ssl_private_key_path : str, optional
2105
+ SSL private key path.
2106
+ ssl_certificate_path : str, optional
2107
+ SSL certificate path.
2108
+ ssl_ca_file : str, optional
2109
+ SSL CA file.
2110
+ ssl_allowed_fingerprints : List[str], optional
2111
+ SSL allowed fingerprints.
2112
+ ssl_allow_any_cert : bool, optional
2113
+ Allow any certificate.
2114
+
2115
+ Returns
2116
+ -------
2117
+ Dict[str, Any]
2118
+ The response from wallet RPC.
2119
+
2120
+ """
2121
+ return await self._request(
2122
+ "set_daemon",
2123
+ {
2124
+ "address": address,
2125
+ "trusted": trusted,
2126
+ "ssl_support": ssl_support,
2127
+ "ssl_private_key_path": ssl_private_key_path,
2128
+ "ssl_certificate_path": ssl_certificate_path,
2129
+ "ssl_ca_file": ssl_ca_file,
2130
+ "ssl_allowed_fingerprints": ssl_allowed_fingerprints,
2131
+ "ssl_allow_any_cert": ssl_allow_any_cert,
2132
+ },
2133
+ )
2134
+
2135
+ async def set_log_level(self, level: int) -> Dict[str, Any]:
2136
+ """
2137
+ Set the log level.
2138
+
2139
+ Parameters
2140
+ ----------
2141
+ level : int
2142
+ Log level.
2143
+
2144
+ Returns
2145
+ -------
2146
+ Dict[str, Any]
2147
+ The response from wallet RPC.
2148
+
2149
+ """
2150
+ return await self._request("set_log_level", {"level": level})
2151
+
2152
+ async def set_log_categories(self, categories: str) -> Dict[str, Any]:
2153
+ """
2154
+ Set the log categories.
2155
+
2156
+ Parameters
2157
+ ----------
2158
+ categories : str
2159
+ Log categories.
2160
+
2161
+ Returns
2162
+ -------
2163
+ Dict[str, Any]
2164
+ The response from wallet RPC.
2165
+
2166
+ """
2167
+ return await self._request("set_log_categories", {"categories": categories})
2168
+
2169
+ async def get_version(self) -> Dict[str, Any]:
2170
+ """
2171
+ Get the wallet version.
2172
+
2173
+ Returns
2174
+ -------
2175
+ Dict[str, Any]
2176
+ The response from wallet RPC.
2177
+
2178
+ """
2179
+ return await self._request("get_version", {})