Skip to content

Commit 443c4a0

Browse files
committed
feat(cli): change cli 'sign' command for TAPSIGNER and SATSCHIP to sign a PSBT instead of a digest
1 parent 556e6d3 commit 443c4a0

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

cli/src/main.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ enum TapSignerCommand {
108108
Backup,
109109
/// Change the PIN (CVC) used for card authentication to a new user provided one
110110
Change { new_cvc: String },
111-
/// Sign a digest
112-
Sign { to_sign: String },
111+
/// Sign a PSBT
112+
Sign { psbt: String },
113113
/// Call wait command until no auth delay
114114
Wait,
115115
/// Get the card's nfc URL
@@ -150,8 +150,8 @@ enum SatsChipCommand {
150150
},
151151
/// Change the PIN (CVC) used for card authentication to a new user provided one
152152
Change { new_cvc: String },
153-
/// Sign a digest
154-
Sign { to_sign: String },
153+
/// Sign a PSBT
154+
Sign { psbt: String },
155155
/// Call wait command until no auth delay
156156
Wait,
157157
/// Get the card's nfc URL
@@ -241,12 +241,10 @@ async fn main() -> Result<(), CliError> {
241241
let response = &ts.change(&new_cvc, &cvc()).await;
242242
println!("{response:?}");
243243
}
244-
TapSignerCommand::Sign { to_sign } => {
245-
let digest: [u8; 32] =
246-
rust_cktap::Hash::hash(to_sign.as_bytes()).to_byte_array();
247-
248-
let response = &ts.sign(digest, vec![], &cvc()).await;
249-
println!("{response:?}");
244+
TapSignerCommand::Sign { psbt } => {
245+
let psbt = Psbt::from_str(&psbt)?;
246+
let signed_psbt = ts.sign_psbt(psbt, &cvc()).await?;
247+
println!("signed_psbt: {signed_psbt}");
250248
}
251249
TapSignerCommand::Wait => wait(ts).await,
252250
TapSignerCommand::Nfc => nfc(ts).await,
@@ -274,12 +272,10 @@ async fn main() -> Result<(), CliError> {
274272
let response = &sc.change(&new_cvc, &cvc()).await;
275273
println!("{response:?}");
276274
}
277-
SatsChipCommand::Sign { to_sign } => {
278-
let digest: [u8; 32] =
279-
rust_cktap::Hash::hash(to_sign.as_bytes()).to_byte_array();
280-
281-
let response = &sc.sign(digest, vec![], &cvc()).await;
282-
println!("{response:?}");
275+
SatsChipCommand::Sign { psbt } => {
276+
let psbt = Psbt::from_str(&psbt)?;
277+
let signed_psbt = sc.sign_psbt(psbt, &cvc()).await?;
278+
println!("signed_psbt: {signed_psbt}");
283279
}
284280
SatsChipCommand::Wait => wait(sc).await,
285281
SatsChipCommand::Nfc => nfc(sc).await,

0 commit comments

Comments
 (0)