File tree Expand file tree Collapse file tree 2 files changed +6
-17
lines changed
stacks-node/src/burnchains/rpc/bitcoin_rpc_client Expand file tree Collapse file tree 2 files changed +6
-17
lines changed Original file line number Diff line number Diff line change @@ -180,13 +180,9 @@ where
180180 D : Deserializer < ' de > ,
181181{
182182 let addr_str: String = Deserialize :: deserialize ( deserializer) ?;
183- if let Some ( addr) = BitcoinAddress :: from_string ( & addr_str) {
184- Ok ( addr)
185- } else {
186- Err ( serde:: de:: Error :: custom (
187- "BitcoinAddress failed to create from string" ,
188- ) )
189- }
183+ BitcoinAddress :: from_string ( & addr_str) . ok_or ( serde:: de:: Error :: custom (
184+ "BitcoinAddress failed to create from string" ,
185+ ) )
190186}
191187
192188/// Deserializes a JSON string into [`Script`]
Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ use stacks::burnchains::bitcoin::address::BitcoinAddress;
2121use stacks:: burnchains:: bitcoin:: BitcoinNetworkType ;
2222use stacks:: burnchains:: Txid ;
2323use stacks:: types:: chainstate:: BurnchainHeaderHash ;
24- use stacks:: types:: Address ;
2524use stacks_common:: deps_common:: bitcoin:: blockdata:: transaction:: Transaction ;
2625use stacks_common:: deps_common:: bitcoin:: network:: serialize:: deserialize_hex;
2726
2827use crate :: burnchains:: rpc:: bitcoin_rpc_client:: {
29- BitcoinRpcClient , BitcoinRpcClientResult , TxidWrapperResponse ,
28+ deserialize_string_to_bitcoin_address, BitcoinRpcClient , BitcoinRpcClientResult ,
29+ TxidWrapperResponse ,
3030} ;
3131
3232/// Represents the response returned by the `getblockchaininfo` RPC call.
@@ -122,14 +122,7 @@ impl<'de> Deserialize<'de> for GetNewAddressResponse {
122122 where
123123 D : Deserializer < ' de > ,
124124 {
125- let addr_str: String = Deserialize :: deserialize ( deserializer) ?;
126- if let Some ( addr) = BitcoinAddress :: from_string ( & addr_str) {
127- Ok ( GetNewAddressResponse ( addr) )
128- } else {
129- Err ( serde:: de:: Error :: custom (
130- "BitcoinAddress failed to create from string" ,
131- ) )
132- }
125+ deserialize_string_to_bitcoin_address ( deserializer) . map ( GetNewAddressResponse )
133126 }
134127}
135128
You can’t perform that action at this time.
0 commit comments