export: add export xpub feature

This commit is contained in:
pythcoiner 2025-04-07 06:36:21 +02:00
parent 2485e250d6
commit 986a982d8e
No known key found for this signature in database
GPG Key ID: C1048AEEDF303B88
2 changed files with 7 additions and 2 deletions

View File

@ -43,6 +43,7 @@ impl ExportModal {
match self.import_export_type {
ImportExportType::Transactions => "Export Transactions",
ImportExportType::ExportPsbt(_) => "Export PSBT",
ImportExportType::ExportXpub(_) => "Export Xpub",
ImportExportType::ExportBackup(_) => "Export Backup",
ImportExportType::Descriptor(_) => "Export Descriptor",
ImportExportType::ExportProcessBackup(..) | ImportExportType::ExportLabels => {
@ -62,6 +63,7 @@ impl ExportModal {
format!("liana-txs-{date}.csv")
}
ImportExportType::ExportPsbt(_) => "psbt.psbt".into(),
ImportExportType::ExportXpub(_) => "liana.pub".into(),
ImportExportType::Descriptor(descriptor) => {
let checksum = descriptor
.to_string()

View File

@ -144,6 +144,7 @@ impl Display for Error {
pub enum ImportExportType {
Transactions,
ExportPsbt(String),
ExportXpub(String),
ExportBackup(String),
ExportProcessBackup(PathBuf, Network, Arc<Config>, Arc<Wallet>),
ImportBackup(
@ -165,6 +166,7 @@ impl ImportExportType {
| ImportExportType::ExportBackup(_)
| ImportExportType::Descriptor(_)
| ImportExportType::ExportProcessBackup(..)
| ImportExportType::ExportXpub(_)
| ImportExportType::ExportLabels => "Export successful!",
ImportExportType::ImportBackup(_, _)
| ImportExportType::ImportPsbt
@ -284,6 +286,7 @@ impl Export {
ImportExportType::ImportPsbt => import_psbt(&sender, path).await,
ImportExportType::ImportDescriptor => import_descriptor(&sender, path).await,
ImportExportType::ExportBackup(str) => export_string(&sender, path, str).await,
ImportExportType::ExportXpub(xpub_str) => export_string(&sender, path, xpub_str).await,
ImportExportType::ExportProcessBackup(datadir, network, config, wallet) => {
app_backup_export(
datadir,
@ -556,10 +559,10 @@ pub async fn export_descriptor(
pub async fn export_string(
sender: &UnboundedSender<Progress>,
path: PathBuf,
psbt: String,
str: String,
) -> Result<(), Error> {
let mut file = open_file_write(&path).await?;
file.write_all(psbt.as_bytes())?;
file.write_all(str.as_bytes())?;
send_progress!(sender, Progress(100.0));
send_progress!(sender, Ended);
Ok(())