-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy patherror.rs
More file actions
2904 lines (2658 loc) · 124 KB
/
Copy patherror.rs
File metadata and controls
2904 lines (2658 loc) · 124 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//! Typed error envelope for backend tasks.
//!
//! `Display` → user-friendly text (shown in `MessageBanner`).
//! `Debug` → variant name + fields (logged and shown in collapsible details).
use crate::model::fee_estimation::format_credits_as_dash;
use dash_sdk::Error as SdkError;
use dash_sdk::dapi_client::DapiClientError;
use dash_sdk::dapi_client::transport::TransportError;
use dash_sdk::dapi_grpc::tonic::Code;
use dash_sdk::dashcore_rpc;
use dash_sdk::dpp::ProtocolError;
use dash_sdk::dpp::consensus::ConsensusError;
use dash_sdk::dpp::consensus::basic::basic_error::BasicError;
use dash_sdk::dpp::consensus::state::state_error::StateError;
use dash_sdk::dpp::dashcore;
use dash_sdk::dpp::dashcore::Network;
use dash_sdk::dpp::platform_value::string_encoding::Encoding;
use dash_sdk::dpp::prelude::Identifier;
use thiserror::Error;
/// Dash Core RPC error code: wallet file not specified (multi-wallet node).
const RPC_WALLET_NOT_SPECIFIED: i32 = -19;
/// App-level error envelope for backend tasks.
#[derive(Debug, Error)]
pub enum TaskError {
/// SPV subsystem errors.
#[error("{}", spv_user_message(.0))]
Spv(#[from] crate::spv::SpvError),
/// DashPay domain errors.
#[error(transparent)]
DashPay(#[from] crate::backend_task::dashpay::errors::DashPayError),
/// Configuration errors.
#[error(transparent)]
Config(#[from] crate::config::ConfigError),
/// GroveSTARK prover errors.
#[error("Could not verify platform data. Please retry.")]
GroveStark(#[from] crate::model::grovestark_prover::GroveSTARKError),
/// Wallet errors.
#[error(transparent)]
Wallet(#[from] crate::database::WalletError),
/// A local database operation failed.
#[error("Could not access local data. Check available disk space and restart the application.")]
Database {
#[from]
source: rusqlite::Error,
},
/// Tokio task join errors.
#[error("An internal operation failed unexpectedly. Please restart the application.")]
JoinError(#[from] tokio::task::JoinError),
/// DAPI node discovery or address resolution failed.
#[error(transparent)]
DapiDiscovery(#[from] crate::backend_task::dapi_discovery::DapiDiscoveryError),
/// Core wallet not configured for this wallet on a multi-wallet Core node.
#[error(
"Core wallet not configured for this wallet. Go to the Wallets screen and refresh to auto-detect the Core wallet association."
)]
CoreWalletNotConfigured,
/// Dash Core RPC rejected the request due to invalid credentials (HTTP 401).
#[error("Dash Core rejected your credentials. Check your RPC password in settings.")]
CoreRpcAuthFailed,
/// Could not connect to Dash Core at the configured address.
#[error(
"Could not connect to Dash Core at {url}. Check that Dash Core is running and your network settings are correct."
)]
CoreRpcConnectionFailed {
url: String,
#[source]
source: Option<Box<dashcore_rpc::Error>>,
},
/// A Dash Core RPC call failed.
#[error("Could not communicate with Dash Core. Check that Dash Core is running and retry.")]
CoreRpc {
#[source]
source: dashcore_rpc::Error,
},
/// An internal lock was poisoned — another thread panicked while holding it.
#[error("An internal error occurred. Please restart the application.")]
LockPoisoned {
/// Which resource's lock was poisoned (for Debug / logs).
resource: &'static str,
},
/// The requested wallet was not found in the local wallet store.
#[error("Wallet not found. Please check your wallet list and try again.")]
WalletNotFound,
/// The wallet is locked and must be unlocked before this operation can proceed.
#[error("Wallet is locked. Please unlock your wallet and try again.")]
WalletLocked,
/// Refreshing wallet UTXOs from Dash Core failed.
#[error("Could not refresh wallet balance. Please try again.")]
WalletUtxoReloadFailed { detail: String },
/// Recalculating address balances after a transaction failed.
#[error("Could not update wallet balances after transaction. Please refresh your wallet.")]
WalletBalanceRecalculationFailed { detail: String },
/// The requested document could not be found on the platform.
#[error("The document could not be found. It may have been deleted or the ID is incorrect.")]
DocumentNotFound,
/// An asset lock's instant-lock proof has expired before Platform verified it.
#[error(
"This transaction cannot be used yet because its verification has expired. \
The network is still processing earlier blocks. \
Please wait a few minutes and retry."
)]
AssetLockExpired {
tx_block_height: u32,
platform_height: u32,
},
/// The private key for the asset lock address was not found in the wallet.
#[error(
"The address for this transaction could not be found in your wallet. \
Make sure you are using the correct wallet."
)]
AssetLockAddressNotFound,
/// A state transition was broadcast but proof verification failed; the proof has been logged.
#[error(
"The operation could not be fully verified by the platform. The issue has been logged. \
Please check whether the operation completed and retry if needed."
)]
ProofError {
/// The original SDK error that triggered proof-verification failure.
#[source]
source_error: Box<SdkError>,
},
/// The requested identity was not found on the platform.
#[error("Identity not found on the platform. Please check the ID or name and try again.")]
IdentityNotFound,
/// Timed out waiting for transaction confirmation.
#[error(
"The transaction was not confirmed within the expected time. Please check your network connection and retry."
)]
ConfirmationTimeout,
/// Dash Core peer-to-peer communication failed.
#[error(transparent)]
P2P(#[from] crate::components::core_p2p_handler::P2PError),
/// The operation's prerequisite was auto-fixed (e.g., Core wallet detected).
/// Callers should retry the failed operation.
#[error("{0}")]
MustRetry(String),
/// Duplicate identity public key — this key's hash is already registered and
/// the key is marked as unique, so it cannot be reused.
#[error(
"This public key must be unique but is already registered on the platform. Try a different key."
)]
DuplicateIdentityPublicKey {
/// The original SDK error returned by the broadcast API.
#[source]
source_error: Box<SdkError>,
},
/// Duplicate identity public key ID — the key ID is already used by another
/// key on this identity.
#[error("This key ID is already used by another key on this identity. Try a different key.")]
DuplicateIdentityPublicKeyId {
/// The original SDK error returned by the broadcast API.
#[source]
source_error: Box<SdkError>,
},
/// Identity public key conflicts with an existing key's unique contract bounds.
#[error(
"This key conflicts with an existing key bound to contract {contract_id}. Use a different key or purpose."
)]
IdentityPublicKeyContractBoundsConflict {
contract_id: String,
/// The original SDK error returned by the broadcast API.
#[source]
source_error: Box<SdkError>,
},
/// The identity could not be found in the local wallet database.
#[error(
"This identity could not be found in your local wallet. Try refreshing your identities list."
)]
IdentityNotFoundLocally,
/// Failed to build the identity update state transition.
#[error("Could not build the key update transaction. Please retry.")]
IdentityUpdateTransitionError {
#[source]
source_error: Box<SdkError>,
},
/// Failed to send a result back to the UI — the receiver was dropped.
#[error("Internal update failed. Please retry the operation.")]
InternalSendError,
/// DAPI server is temporarily unavailable (gRPC Unavailable).
#[error("A Dash network server is temporarily unavailable. Please retry.")]
DapiUnavailable {
#[source]
source_error: Box<SdkError>,
},
/// Connection to DAPI server timed out (gRPC Unavailable with timeout message).
#[error("Connection to a Dash network server timed out. Please retry.")]
DapiTimeout {
#[source]
source_error: Box<SdkError>,
},
/// Could not reach DAPI server (gRPC Unavailable with connection refused).
#[error("Could not reach a Dash network server. Please retry.")]
DapiConnectionRefused {
#[source]
source_error: Box<SdkError>,
},
/// DAPI returned an internal error (gRPC Internal, non-domain).
#[error("The Dash network returned an internal error. Please retry in a few moments.")]
DapiInternalError {
#[source]
source_error: Box<SdkError>,
},
/// DAPI deadline exceeded (gRPC DeadlineExceeded).
#[error("The operation took too long. Please retry — it often succeeds on the next attempt.")]
DapiDeadlineExceeded {
#[source]
source_error: Box<SdkError>,
},
/// Access denied by DAPI server (gRPC Unauthenticated/PermissionDenied).
#[error("Access was denied by the network server. Check your password in settings.")]
DapiAccessDenied {
#[source]
source_error: Box<SdkError>,
},
/// DAPI server overloaded (gRPC ResourceExhausted).
#[error("The network server is overloaded. Please wait a moment and retry.")]
DapiResourceExhausted {
#[source]
source_error: Box<SdkError>,
},
/// No DAPI servers configured.
#[error("No Dash network servers are configured. Please check your network settings.")]
DapiNoAddresses {
#[source]
source_error: Box<SdkError>,
},
/// All DAPI servers exhausted (NoAvailableAddressesToRetry).
#[error(
"All Dash network servers are temporarily unreachable. Please wait a minute and retry."
)]
DapiAllAddressesExhausted {
#[source]
source_error: Box<SdkError>,
},
/// SDK operation timed out (SdkError::TimeoutReached).
#[error(
"The operation did not complete within {timeout_secs} seconds. Please retry — it often succeeds on the second attempt."
)]
SdkTimeout {
timeout_secs: u64,
#[source]
source_error: Box<SdkError>,
},
/// Connected server is behind (SdkError::StaleNode).
#[error("The server you connected to is behind. Please retry.")]
DapiStaleNode {
#[source]
source_error: Box<SdkError>,
},
/// Platform rejected the request (StateTransitionBroadcastError, unclassified cause).
#[error("The platform rejected this request. Please check your input and try again.")]
PlatformRejected {
#[source]
source_error: Box<SdkError>,
},
/// Object already exists on Platform (SdkError::AlreadyExists).
#[error("This object already exists on the platform.")]
PlatformAlreadyExists {
#[source]
source_error: Box<SdkError>,
},
/// Operation was cancelled.
#[error("The operation was cancelled.")]
OperationCancelled {
#[source]
source_error: Box<SdkError>,
},
/// Identity nonce overflow — max operations reached.
#[error("This identity has reached its maximum number of operations. Please try again later.")]
IdentityNonceOverflow {
#[source]
source_error: Box<SdkError>,
},
/// Identity not yet indexed on Platform.
#[error("The platform has not indexed this identity yet. Please retry in a few moments.")]
IdentityNonceNotFound {
#[source]
source_error: Box<SdkError>,
},
/// Unclassified SDK error — the operation failed for an unrecognised reason.
#[error("An unexpected error occurred. Please try again later.")]
SdkError {
#[source]
source_error: Box<SdkError>,
},
// ──────────────────────────────────────────────────────────────────────────
// Wallet / platform-address operation errors
// ──────────────────────────────────────────────────────────────────────────
/// Wallet address provider could not be set up (wallet is open but derivation failed).
#[error(
"Could not prepare wallet addresses for sync. Please close and reopen your wallet, then retry."
)]
WalletAddressProviderSetupFailed { detail: String },
/// A Core address could not be converted to a Platform address.
#[error("Could not convert a wallet address for platform use. Please retry.")]
AddressConversionFailed {
#[source]
source: Box<ProtocolError>,
},
/// Overflow while converting duffs to platform credits.
#[error("The amount is too large to process. Please use a smaller amount.")]
CreditCalculationOverflow { amount: u64, credits_per_duff: u64 },
/// A change address could not be derived or located in the outputs map.
#[error("Could not prepare a change address for this transaction. Please retry.")]
ChangeAddressUnavailable { reason: &'static str },
// ──────────────────────────────────────────────────────────────────────────
// Asset-lock transaction errors
// ──────────────────────────────────────────────────────────────────────────
/// The asset lock transaction was expected in the local database but was not found.
#[error(
"The funding transaction could not be found locally. Please check your network connection and retry."
)]
AssetLockTransactionNotFoundInDatabase,
/// An asset lock transaction has no credit outputs (malformed transaction).
#[error(
"The funding transaction is missing required outputs and cannot be used. Please retry creating the transaction."
)]
AssetLockNoCreditOutputs,
/// Could not derive a Core address from an asset lock output script.
#[error("Could not read the address from the funding transaction. Please retry.")]
AssetLockAddressDerivationFailed {
#[source]
source: dashcore::address::Error,
},
// ──────────────────────────────────────────────────────────────────────────
// Token contract errors
// ──────────────────────────────────────────────────────────────────────────
/// A token at the expected position was not found in the contract.
#[error(
"Token at position {position} was not found in the contract. Please reload the contract and retry."
)]
TokenPositionNotFound { position: u16 },
/// The token name contains whitespace or control characters.
#[error(
"The token name \"{}\" in {form} contains invalid characters. \
Token names must not include spaces or control characters. Please rename and try again.",
escape_token_name(token_name)
)]
InvalidTokenNameCharacter {
form: String,
token_name: String,
#[source]
source_error: Box<SdkError>,
},
/// The token name length is outside the allowed range.
#[error(
"The token {form} is {actual} characters long, but must be between {min} and {max}. \
Please adjust the name length and try again."
)]
InvalidTokenNameLength {
form: String,
actual: usize,
min: usize,
max: usize,
#[source]
source_error: Box<SdkError>,
},
/// The token language code is not recognized.
#[error(
"The language code \"{language_code}\" is not valid. \
Use a standard language code like \"en\" or \"fr\" and try again."
)]
InvalidTokenLanguageCode {
language_code: String,
#[source]
source_error: Box<SdkError>,
},
/// The token's decimal places exceed the platform limit.
#[error(
"Token decimals cannot exceed {max_decimals}, but {decimals} was specified. \
Please use a smaller value."
)]
TokenDecimalsOverLimit {
decimals: u8,
max_decimals: u8,
#[source]
source_error: Box<SdkError>,
},
/// The token's base supply exceeds the platform limit.
#[error(
"The token base supply of {base_supply} is too large. \
Please use a smaller value."
)]
InvalidTokenBaseSupply {
base_supply: u64,
#[source]
source_error: Box<SdkError>,
},
// ──────────────────────────────────────────────────────────────────────────
// Contract errors
// ──────────────────────────────────────────────────────────────────────────
/// The requested data contract could not be found locally or on the platform.
#[error(
"The data contract could not be found. It may have been removed or the ID is incorrect."
)]
DataContractNotFound,
/// A user-driven mutation targeted a built-in system contract. System
/// contracts (DPNS, DashPay, withdrawals, token history, keyword search)
/// are managed by the application and cannot be modified or removed.
#[error(
"Contract {contract_id} is a built-in system contract and cannot be modified or removed. \
Use a different contract."
)]
SystemContractImmutable {
/// Identifier of the system contract whose mutation was rejected.
/// Rendered as Base58 in the user-facing message via `Identifier`'s
/// `Display` implementation.
contract_id: Identifier,
},
/// The same contract identifier appeared more than once in a single
/// add-contracts request.
#[error(
"Contract {contract_id} was entered more than once. Remove the duplicate entry before adding contracts."
)]
DuplicateContractInRequest {
/// Identifier of the duplicated contract. Rendered as Base58 in the
/// user-facing message via `Identifier`'s `Display` implementation.
contract_id: Identifier,
},
/// An add-contracts request referenced a contract that is already loaded
/// (either persisted in the local database or one of the built-in system
/// contracts).
#[error(
"Contract {contract_id} is already loaded. Select it from the existing contracts list or enter a different contract ID."
)]
ContractAlreadyLoaded {
/// Identifier of the already-loaded contract. Rendered as Base58 in
/// the user-facing message via `Identifier`'s `Display` implementation.
contract_id: Identifier,
},
// ──────────────────────────────────────────────────────────────────────────
// Serialization errors
// ──────────────────────────────────────────────────────────────────────────
/// A data serialization or deserialization operation failed (e.g. bincode).
#[error("Could not process the data. Please retry the operation.")]
SerializationError { detail: String },
// ──────────────────────────────────────────────────────────────────────────
// Identity creation / parsing errors
// ──────────────────────────────────────────────────────────────────────────
/// The provided identifier could not be parsed from the input.
#[error("The identifier you entered could not be read. Please check the format and try again.")]
IdentifierParsingError { input: String },
/// The identity could not be constructed from the given parameters.
#[error("Could not create the identity. Please check your input and try again.")]
IdentityCreationError {
#[source]
source: Box<ProtocolError>,
},
/// A private key could not be parsed or is invalid.
#[error("The private key you entered is invalid. Please check the format and try again.")]
InvalidPrivateKey { detail: String },
/// Fetching DPNS names for an identity failed.
#[error("Could not look up names for this identity. Please check your connection and retry.")]
DpnsFetchError {
#[source]
source: Box<SdkError>,
},
/// An asset lock's private key could not be matched to a wallet address.
#[error(
"The funding transaction does not match your wallet. \
Make sure you are using the correct wallet."
)]
AssetLockNotValidForWallet,
/// The instant lock proof has expired and the transaction is not yet chain-locked.
#[error(
"This funding transaction cannot be used right now. The verification has expired and the \
transaction is not yet confirmed. Please wait a few minutes and retry."
)]
AssetLockInstantLockExpiredNotChainlocked,
/// The instant lock proof signature could not be verified by the platform.
#[error(
"The transaction could not be verified instantly. \
Please wait for it to be included in a block and retry."
)]
AssetLockInstantLockProofInvalid {
#[source]
source_error: Box<SdkError>,
},
/// The identity doesn't have enough Platform credits for this operation.
#[error(
"Not enough balance. You have {available_dash} but this operation requires {required_dash}. \
Please top up your identity first.",
available_dash = format_credits_as_dash(*.available),
required_dash = format_credits_as_dash(*.required)
)]
IdentityInsufficientBalance {
available: u64,
required: u64,
#[source]
source_error: Box<SdkError>,
},
/// The asset lock transaction outpoint does not have enough remaining balance.
#[error(
"Not enough funds in this transaction to complete the operation. \
Available: {available_dash}, required: {required_dash}. \
Try using a different funding source or top up first.",
available_dash = format_credits_as_dash(*.available),
required_dash = format_credits_as_dash(*.required)
)]
AssetLockOutPointInsufficientBalance {
available: u64,
required: u64,
#[source]
source_error: Box<SdkError>,
},
/// Fetching address information from the platform failed.
#[error("Could not retrieve address information from the platform. Please retry.")]
PlatformFetchError {
#[source]
source: Box<SdkError>,
},
// ──────────────────────────────────────────────────────────────────────────
// Dash Core lifecycle errors
// ──────────────────────────────────────────────────────────────────────────
/// Dash Core could not be started (binary missing, config error, I/O failure).
#[error("Could not start Dash Core. Verify the installation and try again.")]
DashCoreStartError {
#[source]
source: std::io::Error,
},
// ──────────────────────────────────────────────────────────────────────────
// Network restriction errors
// ──────────────────────────────────────────────────────────────────────────
/// The requested operation is not available on the current network.
#[error(
"{operation} is only available on {allowed_networks}. Switch to a supported network and retry."
)]
OperationNotAvailableOnNetwork {
operation: &'static str,
allowed_networks: &'static str,
},
/// The requested operation requires Dash Core (RPC) and cannot run in light-wallet (SPV) mode.
///
/// The `operation` field is preserved for diagnostic purposes (Debug / log inspection)
/// but is intentionally omitted from the user-facing `Display` text so the message is a
/// single complete sentence — no fragment composition, safe for i18n extraction.
#[error(
"This action is only available when connected to Dash Core. Switch to Dash Core in Settings and retry."
)]
OperationRequiresDashCore { operation: &'static str },
// ──────────────────────────────────────────────────────────────────────────
// Platform info errors
// ──────────────────────────────────────────────────────────────────────────
/// Fetching platform information failed.
#[error("Could not retrieve platform information. Please check your connection and retry.")]
PlatformInfoFetchError {
#[source]
source: Box<SdkError>,
},
// ──────────────────────────────────────────────────────────────────────────
// Encryption errors
// ──────────────────────────────────────────────────────────────────────────
/// An encryption or decryption operation failed.
#[error("Could not process encrypted data. Please check your keys and try again.")]
EncryptionError { detail: String },
// ──────────────────────────────────────────────────────────────────────────
// Wallet persistence errors
// ──────────────────────────────────────────────────────────────────────────
/// A wallet record could not be found or updated in the local database.
#[error("Could not update wallet settings. Please restart the application and try again.")]
WalletDatabasePersistError,
// ──────────────────────────────────────────────────────────────────────────
// Identity key errors
// ──────────────────────────────────────────────────────────────────────────
/// The identity's master key was not found in the local key store.
#[error(
"The master key for this identity could not be found. Make sure the identity was created from this wallet."
)]
MasterKeyNotFound,
// ──────────────────────────────────────────────────────────────────────────
// Token query errors
// ──────────────────────────────────────────────────────────────────────────
/// Querying token data from the platform failed.
#[error("Could not retrieve token information from the platform. Please retry.")]
TokenQueryError { detail: String },
/// The token does not have a perpetual distribution configured — no rewards to claim.
#[error("This token does not have perpetual distribution, so there are no rewards to claim.")]
TokenNoPerpetualDistribution,
/// The recipient identity does not exist on Platform (e.g. during a token mint).
#[error(
"The recipient identity `{recipient_id}` does not exist on the platform. \
Check the ID and try again, or create the identity first."
)]
TokenRecipientIdentityNotFound {
recipient_id: String,
#[source]
source_error: Box<SdkError>,
},
/// The identity's token account is not frozen, so an unfreeze / destroy-frozen action
/// cannot proceed.
#[error(
"Identity `{identity_id}` is not frozen for token `{token_id}`, so `{action}` cannot proceed. \
Refresh the frozen-account list and try again."
)]
TokenAccountNotFrozen {
identity_id: String,
token_id: String,
action: String,
#[source]
source_error: Box<SdkError>,
},
// ──────────────────────────────────────────────────────────────────────────
// Contract schema errors
// ──────────────────────────────────────────────────────────────────────────
/// The contract structure does not match expectations (e.g. missing contested index).
#[error("The contract structure is unexpected. Please update the application.")]
ContractSchemaMismatch { detail: &'static str },
// ──────────────────────────────────────────────────────────────────────────
// Withdrawal document parsing errors
// ──────────────────────────────────────────────────────────────────────────
/// A withdrawal document could not be fully read (missing timestamp, invalid status, etc.).
#[error(
"Could not read the withdrawal details. The data may be incomplete or in an unexpected format. Please retry."
)]
WithdrawalDocumentParsingError { detail: String },
// ──────────────────────────────────────────────────────────────────────────
// SDK / RPC setup errors
// ──────────────────────────────────────────────────────────────────────────
/// The Dash Platform SDK could not be initialised with the current config,
/// or a context provider could not be bound to the current AppContext.
#[error(
"Could not connect to the Dash network. Please check your network settings and restart the application."
)]
SdkInitializationFailed { detail: String },
/// An RPC context provider or Core RPC client could not be constructed.
#[error("Could not set up the Dash Core connection. Please check your settings and retry.")]
RpcProviderCreationFailed { detail: String },
/// The Core wallet name supplied by the user is syntactically invalid.
#[error("The Core wallet name '{name}' is invalid. Please check your wallet configuration.")]
InvalidCoreWalletName { name: String },
/// Dash Core has no wallets loaded — required for wallet-scoped RPC calls.
#[error("No wallets are loaded in Dash Core. Please open a wallet in Dash Core and retry.")]
NoCoreWalletsLoaded,
// ──────────────────────────────────────────────────────────────────────────
// SPV operation errors
// ──────────────────────────────────────────────────────────────────────────
/// The SPV data directory could not be cleared.
#[error(
"Could not clear SPV data. Please close the application and manually delete the SPV data directory."
)]
SpvClearDataFailed { detail: String },
/// The SPV client could not be started.
#[error("Could not start the SPV client. Please check your network settings and retry.")]
SpvStartFailed { detail: String },
/// A transaction could not be broadcast via the SPV client.
#[error("Could not broadcast the transaction. Please check your connection and retry.")]
SpvBroadcastFailed { detail: String },
// ──────────────────────────────────────────────────────────────────────────
// UTXO / asset-lock transaction build errors
// ──────────────────────────────────────────────────────────────────────────
/// A UTXO reload or removal operation failed.
#[error(
"Could not update your unspent transaction outputs. Please check your connection and retry."
)]
UtxoUpdateFailed { detail: String },
/// An asset lock transaction could not be built from the current wallet state.
#[error(
"Could not prepare the funding transaction. Please check your wallet balance and retry."
)]
AssetLockTransactionBuildFailed { detail: String },
// ──────────────────────────────────────────────────────────────────────────
// Wallet key / address errors
// ──────────────────────────────────────────────────────────────────────────
/// A private key for a wallet address could not be found.
#[error(
"Could not find the key for this address in your wallet. Please check your wallet and retry."
)]
WalletKeyLookupFailed { detail: String },
/// A new receive or change address could not be derived from the wallet.
#[error("Could not generate a wallet address. Please check your wallet and retry.")]
WalletAddressDerivationFailed { detail: String },
// ──────────────────────────────────────────────────────────────────────────
// Payment errors
// ──────────────────────────────────────────────────────────────────────────
/// A recipient address could not be parsed or is invalid.
#[error("The recipient address '{address}' is not valid. Please check the address and retry.")]
InvalidRecipientAddress {
address: String,
#[source]
source: dashcore::address::Error,
},
/// A recipient address was parsed but does not match the current network.
#[error(
"The address does not match the current network. Please check that you are on the correct network."
)]
AddressNetworkMismatch {
#[source]
source: dashcore::address::Error,
},
/// The wallet has no UTXOs available to cover the payment.
#[error("Your wallet has no available funds to spend. Please receive some Dash first.")]
NoUtxosAvailable,
/// The wallet balance is too low to cover the requested amount plus fees.
#[error(
"You do not have enough Dash. You have {available} duffs but need {required} duffs. Please add more funds and retry."
)]
InsufficientFunds { available: u64, required: u64 },
/// The output amount is smaller than the transaction fee.
#[error(
"The amount is too small to cover the {fee} duff transaction fee. Please send a larger amount."
)]
OutputTooSmallForFee { fee: u64 },
/// A signature hash for a transaction input could not be computed.
#[error("Could not sign the transaction. Please retry.")]
SighashComputationFailed {
#[source]
source: dashcore::sighash::Error,
},
/// A wallet payment operation failed (covers SPV and RPC payment paths).
#[error("Could not complete the payment. Please check your wallet balance and retry.")]
WalletPaymentFailed { detail: String },
/// Could not access wallet information from the SPV manager.
#[error("Your wallet is still loading. Please wait a moment and try again.")]
WalletInfoUnavailable,
/// Expected BIP44 account not found at the given index.
#[error("Your wallet needs to be refreshed before sending. Please refresh and try again.")]
MissingBip44Account { index: u32 },
/// Could not derive a change address from the wallet account.
#[error("Could not prepare the transaction. Please refresh your wallet and try again.")]
ChangeAddressDerivation {
#[source]
source: dash_sdk::dpp::key_wallet::Error,
},
// ──────────────────────────────────────────────────────────────────────────
// Token query errors (identity / recipient validation)
// ──────────────────────────────────────────────────────────────────────────
/// No local identities are registered — a prerequisite for token queries.
#[error("No registered identities found. Please register an identity first.")]
NoIdentitiesFound,
/// The current identity is not the contract owner who can claim this token's distribution.
#[error(
"This token distribution can only be claimed by the contract owner ({contract_owner}). Your identity is not the contract owner."
)]
NotContractOwner { contract_owner: String },
/// The current identity is not the specific identity designated as the token distribution recipient.
#[error(
"This token distribution can only be claimed by the designated recipient ({designated_recipient}). Your identity is not the designated recipient."
)]
NotDesignatedTokenRecipient { designated_recipient: String },
/// The current identity is not an evonode, which is required for this token distribution.
#[error(
"This token distribution is only for evonode identities. Your identity is not registered as an evonode."
)]
NotEvonode,
// ──────────────────────────────────────────────────────────────────────────
// Wallet-based identity loading errors
// ──────────────────────────────────────────────────────────────────────────
/// No on-chain identity was found for the requested wallet derivation index.
#[error(
"Could not find an identity for wallet index {identity_index} after checking {auth_key_count} keys. Try expanding the search range."
)]
WalletIdentityNotFound {
identity_index: u32,
auth_key_count: usize,
},
/// The identity returned by the platform does not contain the queried authentication key.
#[error(
"The identity retrieved does not match your wallet key. Please check you are using the correct wallet."
)]
WalletIdentityKeyMismatch,
/// None of the identity's public keys could be matched to wallet derivation paths.
#[error(
"Could not match any identity keys to your wallet. Please check your wallet and retry."
)]
NoMatchingWalletKeys,
/// The derivation path for the queried identity key was not found in the wallet.
#[error(
"Could not locate this identity key's information in your wallet. Please check your wallet configuration."
)]
WalletKeyDerivationPathNotFound,
/// Wallet scan completed but no identities were found up to the requested index.
#[error("No identities found up to wallet index {max_index}. Try a higher search range.")]
NoWalletIdentitiesFound { max_index: u32 },
// ──────────────────────────────────────────────────────────────────────────
// Key input validation errors
// ──────────────────────────────────────────────────────────────────────────
/// A raw private-key input string failed format validation.
#[error("The {key_name} key is invalid: {detail}. Please check the key format and retry.")]
KeyInputValidationFailed { key_name: String, detail: String },
/// The identity's public keys could not be converted to the platform format.
#[error("Could not process the identity keys. Please check your key configuration and retry.")]
PublicKeyMapBuildFailed { detail: String },
/// The wallet-binding information for an identity could not be determined.
#[error(
"Could not read wallet information for this identity. Please check your wallet and retry."
)]
WalletInfoDeterminationFailed { detail: String },
// ──────────────────────────────────────────────────────────────────────────
// Voting / DPNS errors
// ──────────────────────────────────────────────────────────────────────────
/// A qualified identity does not have an associated voter identity.
#[error(
"The identity {identity_id} does not have a voting key. Please add a voting key to vote."
)]
NoVotingIdentity { identity_id: String },
/// No open vote poll was found on Platform for the given DPNS name.
///
/// Surfaced by the pre-flight existence check in `vote_on_dpns_name`,
/// before any state transition is broadcast. Short-circuits a ~70 s
/// retry chain that would otherwise expire with an opaque timeout.
#[error(
"The contested name \"{name}\" is not currently open for voting. It may have been resolved or may not exist. Refresh the contested names list and try again."
)]
VotePollNotFound { name: String },
/// The identity does not have an authentication key required to sign documents.
#[error(
"This identity does not have a key for signing documents. Please add an authentication key."
)]
NoDocumentSigningKey,
// ──────────────────────────────────────────────────────────────────────────
// Wallet creation / import errors
// ──────────────────────────────────────────────────────────────────────────
/// The wallet has already been imported for this network.
#[error("This wallet has already been imported for this network.")]
WalletAlreadyImported,
/// Wallet key derivation failed during construction.
#[error("Could not create the wallet. Key derivation failed — please try again.")]
WalletKeyDerivationFailed {
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
// ──────────────────────────────────────────────────────────────────────────
// Shielded pool errors
// ──────────────────────────────────────────────────────────────────────────
/// No unspent shielded notes are available.
#[error("You have no shielded funds available. Please shield some credits first.")]
ShieldedNoUnspentNotes,
/// Insufficient shielded balance to cover the requested amount.
#[error(
"Insufficient shielded balance: you have {available} credits but need {required}. Please shield more credits."
)]
ShieldedInsufficientBalance { available: u64, required: u64 },
/// The platform address was not found in the wallet's platform address info.
#[error("The platform address could not be found in your wallet. Please refresh and retry.")]
PlatformAddressNotFound,
/// A Merkle witness could not be obtained for a shielded note.
#[error("Could not prepare the shielded transaction. Please sync your notes and retry.")]
ShieldedMerkleWitnessUnavailable { detail: String },
/// Failed to build a shielded state transition (shield, transfer, unshield, withdrawal).
#[error("Could not build the shielded transaction. Please retry.")]
ShieldedTransitionBuildFailed { detail: String },
/// The shielded note witnesses are stale — the commitment tree changed since sync.
#[error("Your wallet data is slightly outdated. Please wait a moment and try again.")]
ShieldedAnchorMismatch { detail: String },
/// The amount plus network fee exceeds the spendable shielded balance.
#[error(
"The amount plus the network fee ({fee_dash}) exceeds your available balance. Reduce the amount or add more funds.",
fee_dash = format_credits_as_dash(*.fee)
)]
ShieldedFeeExceedsBalance {
amount: u64,
fee: u64,
spendable: u64,
},
/// Failed to broadcast a shielded state transition.
#[error(
"Could not broadcast the shielded transaction. Please check your connection and retry."
)]
ShieldedBroadcastFailed {
#[source]
source: Box<dash_sdk::Error>,
},