@@ -56,6 +56,9 @@ use bdk_wallet::descriptor::Segwitv0;
5656use bdk_wallet:: keys:: { GeneratableKey , GeneratedKey , bip39:: WordCount } ;
5757use serde_json:: { Value , json} ;
5858
59+ #[ cfg( feature = "bip322" ) ]
60+ use bdk_bip322:: SignatureFormat ;
61+
5962/// Parse the recipient (Address,Amount) argument from cli input.
6063pub ( crate ) fn parse_recipient ( s : & str ) -> Result < ( ScriptBuf , u64 ) , String > {
6164 let parts: Vec < _ > = s. split ( ':' ) . collect ( ) ;
@@ -95,6 +98,21 @@ pub(crate) fn parse_address(address_str: &str) -> Result<Address, Error> {
9598 Ok ( unchecked_address. assume_checked ( ) )
9699}
97100
101+ /// Function to parse the signature format from a string
102+ #[ cfg( feature = "bip322" ) ]
103+ pub ( crate ) fn parse_signature_format ( format_str : & str ) -> Result < SignatureFormat , Error > {
104+ match format_str. to_lowercase ( ) . as_str ( ) {
105+ "legacy" => Ok ( SignatureFormat :: Legacy ) ,
106+ "simple" => Ok ( SignatureFormat :: Simple ) ,
107+ "full" => Ok ( SignatureFormat :: Full ) ,
108+ "fullproofoffunds" => Ok ( SignatureFormat :: FullProofOfFunds ) ,
109+ _ => Err ( Error :: Generic (
110+ "Invalid signature format. Use 'legacy', 'simple', 'full', or 'fullproofoffunds'"
111+ . to_string ( ) ,
112+ ) ) ,
113+ }
114+ }
115+
98116/// Prepare bdk-cli home directory
99117///
100118/// This function is called to check if [`crate::CliOpts`] datadir is set.
0 commit comments