diff --git a/CHANGELOG.md b/CHANGELOG.md index 47f3121..ba27fb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ names, environment variables, exit codes, error codes, and the shape of ## [Unreleased] +## [0.7.4] - 2026-10-19 + +### Fixed + +- `tx` no longer fails in the few seconds after a transaction's block is + found, when its time is not known yet; it says "time not known yet". + ## [0.7.3] - 2026-10-11 ### Changed @@ -174,7 +181,8 @@ names, environment variables, exit codes, error codes, and the shape of - Installers: Homebrew (`blockio/tap/dogechain`), npm (`dogechain`), shell script, PowerShell, and prebuilt binaries for macOS, Linux and Windows. -[Unreleased]: https://github.com/BlockIo/dogechain-cli/compare/v0.7.3...HEAD +[Unreleased]: https://github.com/BlockIo/dogechain-cli/compare/v0.7.4...HEAD +[0.7.4]: https://github.com/BlockIo/dogechain-cli/compare/v0.7.3...v0.7.4 [0.7.3]: https://github.com/BlockIo/dogechain-cli/compare/v0.7.2...v0.7.3 [0.7.2]: https://github.com/BlockIo/dogechain-cli/compare/v0.7.1...v0.7.2 [0.7.1]: https://github.com/BlockIo/dogechain-cli/compare/v0.7.0...v0.7.1 diff --git a/Cargo.lock b/Cargo.lock index 7d49f1b..b9fcc0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -342,7 +342,7 @@ dependencies = [ [[package]] name = "dogechain-cli" -version = "0.7.3" +version = "0.7.4" dependencies = [ "assert_cmd", "clap", diff --git a/Cargo.toml b/Cargo.toml index 9a182de..d3868b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dogechain-cli" -version = "0.7.3" +version = "0.7.4" edition = "2024" rust-version = "1.88" description = "Command-line interface for Dogechain.com" diff --git a/scripts/check-api-contract.py b/scripts/check-api-contract.py index 206a517..18e7397 100755 --- a/scripts/check-api-contract.py +++ b/scripts/check-api-contract.py @@ -19,7 +19,7 @@ ("/blocks/latest", [], ["blocks"]), ("/blocks/latest", ["blocks", "[]"], ["height", "time", "num_txs", "reward_and_fees"]), ("/tx/{txid}", [], ["transaction", "explain"]), - ("/tx/{txid}", ["transaction"], ["hash", "confirmations", "time", "fee", "size", + ("/tx/{txid}", ["transaction"], ["hash", "confirmations", "fee", "size", "inputs", "outputs"]), ("/tx/{txid}", ["transaction", "outputs", "[]"], ["index", "value"]), ("/tx/{txid}", ["explain"], ["headline", "detail"]), diff --git a/src/commands.rs b/src/commands.rs index c070981..80f1ed2 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -310,7 +310,11 @@ fn show_tx(out: &mut dyn Write, r: &TxReply, explain_only: bool) -> Result<()> { ), _ => "waiting in the mempool (unconfirmed)".into(), }; - writeln!(out, "Status {status} · {}", utc(tx.time))?; + let when = tx + .time + .map(utc) + .unwrap_or_else(|| "time not known yet".into()); + writeln!(out, "Status {status} · {when}")?; writeln!(out, "From:")?; for i in &tx.inputs { let who = i.address.as_deref().unwrap_or("newly mined coins"); diff --git a/src/model.rs b/src/model.rs index 43d5095..147bee0 100644 --- a/src/model.rs +++ b/src/model.rs @@ -82,7 +82,8 @@ pub struct Transaction { pub hash: String, pub confirmations: i64, pub block_height: Option, - pub time: i64, + /// None for a few seconds while the transaction's block is being added. + pub time: Option, pub fee: Doge, pub size: u64, pub inputs: Vec, diff --git a/src/schema.rs b/src/schema.rs index 0339b08..4825b03 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -62,7 +62,7 @@ pub fn schema() -> Value { "tx [--explain]": { "api": "GET /api/v3/tx/", "data": { - "transaction": "hash, confirmations, block_hash, block_height|null, time, fee, size, vsize, locktime, inputs[{index, address|null, value, previous_output{hash,index}}], outputs[{index, address|null, value, is_change, spent}]", + "transaction": "hash, confirmations, block_hash, block_height|null, time|null (briefly null while its block is being added), fee, size, vsize, locktime, inputs[{index, address|null, value, previous_output{hash,index}}], outputs[{index, address|null, value, is_change, spent}]", "explain": "headline, detail, sent, change, fee, change_outputs[index]", "warnings": "[{kind: \"lookalike_sender\", sender, imitates, receiver, shared_prefix, sender_kind, real_txid}]" }, diff --git a/tests/cli.rs b/tests/cli.rs index 66c452c..8d30600 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1109,3 +1109,16 @@ fn fees_lead_with_the_suggested_fee() { "{text}" ); } + +#[test] +fn tx_time_can_be_unknown_briefly() { + let mut t = tx(json!([])); + t["transaction"]["time"] = Value::Null; + dogechain(&mock(vec![ok(t)])) + .args(["tx", TXID]) + .assert() + .success() + .stdout(predicate::str::contains( + "Status waiting in the mempool (unconfirmed) · time not known yet", + )); +}