Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 34 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ version = "27.0.0"

# Dependencies from elsewhere shared by crates:
[workspace.dependencies]
stellar-strkey = "0.0.16"
stellar-strkey = "0.0.18"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Regenerate strkey command docs for stdin input

This bump changes the embedded strkey encode/decode CLI to read its payload from stdin (the updated integration tests now use .write_stdin(...), matching the v0.0.18 upstream examples), but the checked-in help docs still advertise positional arguments at FULL_HELP_DOCS.md:4412 and FULL_HELP_DOCS.md:4422. Since the README links users to that generated file, anyone following the release docs will run stellar strkey decode <STRKEY> / encode <JSON>, which no longer matches the command behavior; please regenerate FULL_HELP_DOCS.md with this dependency bump.

Useful? React with 👍 / 👎.

sep5 = "0.1.0"
base64 = "0.21.2"
thiserror = "1.0.46"
Expand Down
18 changes: 9 additions & 9 deletions FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4396,7 +4396,7 @@ Print version information

Decode and encode strkey

**Usage:** `stellar strkey <COMMAND>`
**Usage:** `stellar strkey [OPTIONS] <COMMAND>`

###### **Subcommands:**

Expand All @@ -4405,25 +4405,25 @@ Decode and encode strkey
- `zero` — Generate the zero strkey
- `version` — Print version information

###### **Options:**

- `-q`, `--quiet` — Suppress stderr log and warning output

## `stellar strkey decode`

Decode strkey

**Usage:** `stellar strkey decode <STRKEY>`
Reads the strkey from stdin.

###### **Arguments:**

- `<STRKEY>` — Strkey to decode
**Usage:** `stellar strkey decode`

## `stellar strkey encode`

Encode strkey

**Usage:** `stellar strkey encode <JSON>`

###### **Arguments:**
Reads the JSON from stdin.

- `<JSON>` — JSON for Strkey to encode
**Usage:** `stellar strkey encode`

## `stellar strkey zero`

Expand Down
6 changes: 3 additions & 3 deletions cmd/crates/soroban-spec-tools/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ pub fn contract_id_from_str(contract_id: &str) -> Result<[u8; 32], stellar_strke
.or_else(|_| {
// strkey failed, try to parse it as a hex string, for backwards compatibility.
padded_hex_from_str(contract_id, 32)
.map_err(|_| stellar_strkey::DecodeError::Invalid)?
.map_err(|_| stellar_strkey::DecodeError::InvalidPayloadLength)?
.try_into()
.map_err(|_| stellar_strkey::DecodeError::Invalid)
.map_err(|_| stellar_strkey::DecodeError::InvalidPayloadLength)
})
.map_err(|_| stellar_strkey::DecodeError::Invalid)
.map_err(|_| stellar_strkey::DecodeError::InvalidPayloadLength)
}
1 change: 1 addition & 0 deletions cmd/crates/soroban-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ impl TestEnv {
self.cmd::<keys::secret::Cmd>(&format!("--hd-path={hd_path}"))
.private_key()
.unwrap()
.as_unredacted()
)
}

Expand Down
9 changes: 4 additions & 5 deletions cmd/crates/soroban-test/tests/it/strkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ fn decode() {
let sandbox = TestEnv::default();
sandbox
.new_assert_cmd("strkey")
.args([
"decode",
"GAZTAML6YJA5PGKDXONKPSHKL6FYT6OG5I2R7YB7R3B5CETRG7KIJONK",
])
.args(["decode"])
.write_stdin("GAZTAML6YJA5PGKDXONKPSHKL6FYT6OG5I2R7YB7R3B5CETRG7KIJONK")
.assert()
.success()
.stdout(
Expand All @@ -24,7 +22,8 @@ fn encode() {
let sandbox = TestEnv::default();
sandbox
.new_assert_cmd("strkey")
.args(["encode", r#"{"public_key_ed25519":"3330317ec241d79943bb9aa7c8ea5f8b89f9c6ea351fe03f8ec3d1127137d484"}"#])
.args(["encode"])
.write_stdin(r#"{"public_key_ed25519":"3330317ec241d79943bb9aa7c8ea5f8b89f9c6ea351fe03f8ec3d1127137d484"}"#)
.assert()
.success()
.stdout("GAZTAML6YJA5PGKDXONKPSHKL6FYT6OG5I2R7YB7R3B5CETRG7KIJONK\n");
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/keys/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Cmd {
if self.phrase {
println!("{}", self.seed_phrase()?);
} else {
println!("{}", self.private_key()?);
println!("{}", self.private_key()?.as_unredacted());
}

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Cmd {
pub fn run(&self) -> Result<(), Error> {
let root_key = self.args.root_key()?;
let private_key = PrivateKey::from_payload(&root_key)?;
println!("{private_key}");
println!("{}", private_key.as_unredacted());
Ok(())
}
}
5 changes: 4 additions & 1 deletion cmd/soroban-cli/src/config/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ mod test {
}
#[test]
fn secret_key() {
let secret_key = format!("{}", stellar_strkey::ed25519::PrivateKey([0; 32]));
let secret_key = format!(
"{}",
stellar_strkey::ed25519::PrivateKey([0; 32]).as_unredacted()
);
let secret = Secret::SecretKey { secret_key };
let key = Key::Secret(secret);
round_trip(&key);
Expand Down
8 changes: 4 additions & 4 deletions cmd/soroban-cli/src/config/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl FromStr for Secret {
impl From<PrivateKey> for Secret {
fn from(value: PrivateKey) -> Self {
Secret::SecretKey {
secret_key: format!("{value}"),
secret_key: format!("{}", value.as_unredacted()),
}
}
}
Expand Down Expand Up @@ -285,7 +285,7 @@ mod tests {

assert!(matches!(secret, Secret::SecretKey { .. }));
assert_eq!(public_key.to_string(), TEST_PUBLIC_KEY);
assert_eq!(private_key.to_string(), TEST_SECRET_KEY);
assert_eq!(private_key.as_unredacted().to_string(), TEST_SECRET_KEY);
}

#[test]
Expand All @@ -296,7 +296,7 @@ mod tests {

assert!(matches!(secret, Secret::SeedPhrase { .. }));
assert_eq!(public_key.to_string(), TEST_PUBLIC_KEY);
assert_eq!(private_key.to_string(), TEST_SECRET_KEY);
assert_eq!(private_key.as_unredacted().to_string(), TEST_SECRET_KEY);
}

#[test]
Expand Down Expand Up @@ -463,7 +463,7 @@ mod tests {
let pk = secret.public_key(Some(0)).unwrap();
let sk = secret.private_key(Some(0)).unwrap();
assert_eq!(pk.to_string(), TEST_PUBLIC_KEY);
assert_eq!(sk.to_string(), TEST_SECRET_KEY);
assert_eq!(sk.as_unredacted().to_string(), TEST_SECRET_KEY);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ pub fn contract_id_from_str(
// strkey failed, try to parse it as a hex string, for backwards compatibility.
stellar_strkey::Contract(
soroban_spec_tools::utils::padded_hex_from_str(contract_id, 32)
.map_err(|_| stellar_strkey::DecodeError::Invalid)?
.map_err(|_| stellar_strkey::DecodeError::InvalidPayloadLength)?
.try_into()
.map_err(|_| stellar_strkey::DecodeError::Invalid)?,
.map_err(|_| stellar_strkey::DecodeError::InvalidPayloadLength)?,
)
},
)
Expand Down
Loading