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
//! A tool to import a wallet public key with descriptors from many different formats seamlessly
//!
//!
//! # Supported formats
//!
//! - Descriptors
//! - Electrum
//! - Wasabi
//! - JSON
//!
//! # Supported descriptors
//!
//! - Single Sig
//!
//! # Examples
//!
//! ## Import in generic JSON format used by many wallets
//! ```rust
//! use pubport::Format;
//!
//! let string = std::fs::read_to_string("test/data/sparrow-export.json").unwrap();
//! let format = Format::try_new_from_str(&string);
//!
//! assert!(format.is_ok());
//!
//! let format = format.unwrap();
//! assert!(matches!(format, Format::Json(_)));
//! ```
//!
//! ## Import from file containing descriptors
//!
//! ***note: need external and internal descriptors, but can be single descriptor or multiple descriptor format***
//!
//! ```rust
//! use pubport::Format;
//!
//! let string = std::fs::read_to_string("test/data/descriptor.txt").unwrap();
//! let format = Format::try_new_from_str(&string);
//!
//! assert!(format.is_ok());
//!
//! let format = format.unwrap();
//! assert!(matches!(format, Format::Descriptor(_)));
//! ```
//!
//! ## Import from wasabi wallet format
//!
//! ```rust
//! use pubport::Format;
//!
//! let string = std::fs::read_to_string("test/data/new-wasabi.json").unwrap();
//! let format = Format::try_new_from_str(&string);
//!
//! assert!(format.is_ok());
//!
//! let format = format.unwrap();
//! assert!(matches!(format, Format::Wasabi(_)));
//! ```
//!
//! ## Import from electrum wallet format
//!
//! ```rust
//! use pubport::Format;
//!
//! let string = std::fs::read_to_string("test/data/new-electrum.json").unwrap();
//! let format = Format::try_new_from_str(&string);
//!
//! assert!(format.is_ok());
//!
//! let format = format.unwrap();
//! assert!(matches!(format, Format::Electrum(_)));
//! ```
pub type Format = Format;
pub type Error = Error;
setup_scaffolding!;