Files
cdk/crates/cdk-cli/src/sub_commands/decode_token.rs
ok300 65c1aea408 CLI decode_token: use CBOR diagnostic format instead of pure JSON
This brings decoded TokenV4s in line with the format specified in NUT-00, especially around how byte array fields are handled.
2024-09-08 10:09:27 +01:00

20 lines
420 B
Rust

use std::str::FromStr;
use anyhow::Result;
use cdk::nuts::Token;
use cdk::util::serialize_to_cbor_diag;
use clap::Args;
#[derive(Args)]
pub struct DecodeTokenSubCommand {
/// Cashu Token
token: String,
}
pub fn decode_token(sub_command_args: &DecodeTokenSubCommand) -> Result<()> {
let token = Token::from_str(&sub_command_args.token)?;
println!("{:}", serialize_to_cbor_diag(&token)?);
Ok(())
}