From: Alekos Filini Date: Mon, 31 Aug 2020 08:49:44 +0000 (+0200) Subject: General cleanup for the docs X-Git-Tag: 0.1.0-beta.1~4 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.EncoderStringWriter.html?a=commitdiff_plain;h=9239b83c8c7a35a35e296f7b0d2d47bf5b6a559c;p=bdk-cli General cleanup for the docs --- diff --git a/Cargo.toml b/Cargo.toml index ec9624b..599e807 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,3 +83,10 @@ required-features = ["cli-utils"] [workspace] members = ["macros", "testutils", "testutils-macros"] + +# Generate docs with nightly to add the "features required" badge +# https://stackoverflow.com/questions/61417452/how-to-get-a-feature-requirement-tag-in-the-documentation-generated-by-cargo-do +[package.metadata.docs.rs] +features = ["compiler", "electrum", "esplora", "compact_filters", "key-value-db"] +# defines the configuration attribute `docsrs` +rustdoc-args = ["--cfg", "docsrs"] diff --git a/src/cli.rs b/src/cli.rs index f3b11ef..51c56ef 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -40,7 +40,7 @@ use crate::error::Error; use crate::types::ScriptType; use crate::{FeeRate, TxBuilder, Wallet}; -fn parse_addressee(s: &str) -> Result<(Address, u64), String> { +fn parse_recipient(s: &str) -> Result<(Address, u64), String> { let parts: Vec<_> = s.split(":").collect(); if parts.len() != 2 { return Err("Invalid format".to_string()); @@ -62,8 +62,8 @@ fn parse_outpoint(s: &str) -> Result { OutPoint::from_str(s).map_err(|e| format!("{:?}", e)) } -fn addressee_validator(s: String) -> Result<(), String> { - parse_addressee(&s).map(|_| ()) +fn recipient_validator(s: String) -> Result<(), String> { + parse_recipient(&s).map(|_| ()) } fn outpoint_validator(s: String) -> Result<(), String> { @@ -95,18 +95,18 @@ pub fn make_cli_subcommands<'a, 'b>() -> App<'a, 'b> { Arg::with_name("to") .long("to") .value_name("ADDRESS:SAT") - .help("Adds an addressee to the transaction") + .help("Adds a recipient to the transaction") .takes_value(true) .number_of_values(1) .required(true) .multiple(true) - .validator(addressee_validator), + .validator(recipient_validator), ) .arg( Arg::with_name("send_all") .short("all") .long("send_all") - .help("Sends all the funds (or all the selected utxos). Requires only one addressees of value 0"), + .help("Sends all the funds (or all the selected utxos). Requires only one recipients of value 0"), ) .arg( Arg::with_name("enable_rbf") @@ -382,13 +382,13 @@ where "satoshi": wallet.get_balance()? })) } else if let Some(sub_matches) = matches.subcommand_matches("create_tx") { - let addressees = sub_matches + let recipients = sub_matches .values_of("to") .unwrap() - .map(|s| parse_addressee(s)) + .map(|s| parse_recipient(s)) .collect::, _>>() .map_err(|s| Error::Generic(s))?; - let mut tx_builder = TxBuilder::from_addressees(addressees); + let mut tx_builder = TxBuilder::with_recipients(recipients); if sub_matches.is_present("send_all") { tx_builder = tx_builder.send_all(); @@ -503,13 +503,13 @@ where })) } else if let Some(sub_matches) = matches.subcommand_matches("finalize_psbt") { let psbt = base64::decode(&sub_matches.value_of("psbt").unwrap()).unwrap(); - let mut psbt: PartiallySignedTransaction = deserialize(&psbt).unwrap(); + let psbt: PartiallySignedTransaction = deserialize(&psbt).unwrap(); let assume_height = sub_matches .value_of("assume_height") .and_then(|s| Some(s.parse().unwrap())); - let finalized = wallet.finalize_psbt(&mut psbt, assume_height)?; + let (psbt, finalized) = wallet.finalize_psbt(psbt, assume_height)?; Ok(json!({ "psbt": base64::encode(&serialize(&psbt)), "is_finalized": finalized,