fn balance(&self, req: &mut Request) -> IronResult<Response> {
        use self::iron::modifiers::Header;

        let path = req.url.path();
        let wallet_key = path.last().unwrap();
        let public_key = PublicKey::from_hex(wallet_key).map_err(|e| {
            IronError::new(e, (
                Status::BadRequest,
                Header(ContentType::json()),
                "\"Invalid request param: `pub_key`\"",
            ))
        })?;
        if let Some(wallet) = self.wallet(&public_key) {
            let height = CoreSchema::new(self.blockchain.snapshot()).height();
            self.ok_response(&serde_json::to_value(wallet.actual_balance(height))
                .unwrap())
        } else {
            self.not_found_response(&serde_json::to_value("Wallet not found").unwrap())
        }
    }
/// Endpoint for retrieving a single wallet.
Endpoint for retrieving a single wallet.
Endpoint for retrieving a single wallet .
fn balance(&self, req: &mut Request) -> IronResult<Response> {
        use self::iron::modifiers::Header;
        let path = req.url.path();
        let wallet_key = path.last().unwrap();
        let public_key = PublicKey::from_hex(wallet_key).map_err(|e| {
            IronError::new(e, (
                Status::BadRequest,
                Header(ContentType::json()),
                "\"Invalid request param: `pub_key`\"",
            ))
        })?;
        if let Some(wallet) = self.wallet(&public_key) {
            let height = CoreSchema::new(self.blockchain.snapshot()).height();
            self.ok_response(&serde_json::to_value(wallet.actual_balance(height))
                .unwrap())
        } else {
            self.not_found_response(&serde_json::to_value("Wallet not found").unwrap())
        }
    }
fn balance ( & self , req : & mut Request ) -> IronResult < Response > { use self :: iron :: modifiers :: Header ; let path = req . url . path ( ) ; let wallet_key = path . last ( ) . unwrap ( ) ; let public_key = PublicKey :: from_hex ( wallet_key ) . map_err ( | e | { IronError :: new ( e , ( Status :: BadRequest , Header ( ContentType :: json ( ) ) , " \" \" " , ) ) } ) ? ; if let Some ( wallet ) = self . wallet ( & public_key ) { let height = CoreSchema :: new ( self . blockchain . snapshot ( ) ) . height ( ) ; self . ok_response ( & serde_json :: to_value ( wallet . actual_balance ( height ) ) . unwrap ( ) ) } else { self . not_found_response ( & serde_json :: to_value ( " " ) . unwrap ( ) ) } }
Endpoint for retrieving a single wallet.
Endpoint for retrieving a single wallet .
&self
req
&mut Request
&self
req
&mut Request