- Fixed `key restore` ignoring `--password`, which restored passphrase-protected mnemonics to the wrong key
- Fixed `key generate` silently producing a 24-word mnemonic for any `--entropy` value other than 12; values other than 12 and 24 are now rejected
- Gated `full_scan`'s `--scan-stop-gap` to the Electrum and Esplora backends that use it; RPC and CBF wallets now reject the flag instead of silently ignoring it, while a `STOP_GAP` environment variable keeps working for supported backends and no longer breaks unsupported ones
+- Changed `payjoin history` to return JSON instead of a rendered table
## [4.0.0]
SignOptions, Wallet,
bitcoin::{FeeRate, Psbt, Txid, consensus::encode::serialize_hex},
};
-use cli_table::{Cell, CellStruct, Style, Table};
use payjoin::bitcoin::TxIn;
use payjoin::persist::{OptionalTransitionOutcome, SessionPersister};
use payjoin::receive::InputPair;
replay_event_log as replay_sender_event_log,
};
use payjoin::{HpkePublicKey, ImplementationError, UriExt};
+use serde::Serialize;
use serde_json::{json, to_string_pretty};
use std::{path::PathBuf, sync::Arc};
}
}
+#[derive(Serialize)]
+struct SessionHistory<'a> {
+ sessions: Vec<&'a SessionHistoryRow>,
+}
+
+#[derive(Serialize)]
struct SessionHistoryRow {
id: String,
role: &'static str,
});
}
- let rows: Vec<Vec<CellStruct>> = send_rows
- .iter()
- .chain(recv_rows.iter())
- .map(|row| {
- vec![
- row.id.as_str().cell(),
- row.role.cell(),
- row.completed_at
- .clone()
- .unwrap_or_else(|| "Not Completed".to_string())
- .cell(),
- row.status.as_str().cell(),
- ]
- })
- .collect();
+ let sessions: Vec<&SessionHistoryRow> = send_rows.iter().chain(recv_rows.iter()).collect();
- let table = rows
- .table()
- .title(vec![
- "Session ID".cell().bold(true),
- "Sender/Receiver".cell().bold(true),
- "Completed At".cell().bold(true),
- "Status".cell().bold(true),
- ])
- .display()
- .map_err(|e| Error::Generic(e.to_string()))?;
-
- Ok(format!("{table}"))
+ Ok(to_string_pretty(&SessionHistory { sessions })?)
}
}