Skip to content

Commit

Permalink
psbt: Replace optional argument compressed with flag --uncompressed
Browse files Browse the repository at this point in the history
Using uncompressed keys is so uncommon it shouldn't be a full argument.
  • Loading branch information
stevenroose committed Oct 23, 2023
1 parent 6edca6b commit 41591f4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/bin/hal/cmd/psbt.rs
Expand Up @@ -454,16 +454,15 @@ fn cmd_rawsign<'a>() -> clap::App<'a, 'a> {
args::arg("psbt", "PSBT to finalize, either base64/hex or a file path").required(false),
args::arg("input-idx", "the input index to edit").required(true),
args::arg("priv-key", "the private key in WIF/hex").required(true),
args::arg("compressed", "Whether the corresponding pk is compressed")
.required(false)
.default_value("true"),
args::opt("raw-stdout", "output the raw bytes of the result to stdout")
.short("r")
.required(false),
args::opt("output", "where to save the resulting PSBT file -- in place if omitted")
.short("o")
.takes_value(true)
.required(false),
args::opt("uncompressed", "Whether the corresponding pubkey should be used uncompressed")
.takes_value(false),
])
}

Expand All @@ -475,8 +474,7 @@ fn exec_rawsign<'a>(args: &clap::ArgMatches<'a>) {
let sk = args.need_privkey("priv-key").inner;
let i = args.value_of("input-idx").need("Input index not provided")
.parse::<usize>().need("input-idx must be a positive integer");
let compressed = args.value_of("compressed").unwrap()
.parse::<bool>().need("Compressed must be boolean");
let uncompressed = args.is_present("uncompressed");

if i >= psbt.inputs.len() {
panic!("PSBT input index out of range")
Expand All @@ -487,7 +485,7 @@ fn exec_rawsign<'a>(args: &clap::ArgMatches<'a>) {

let pk = secp256k1::PublicKey::from_secret_key(&SECP, &sk);
let pk = bitcoin::PublicKey {
compressed: compressed,
compressed: !uncompressed,
inner: pk,
};
let msg = psbt.sighash_msg(i, &mut cache, None)
Expand Down

0 comments on commit 41591f4

Please sign in to comment.