Skip to content

Commit

Permalink
Merge pull request #20 from Alesfatalis/develop
Browse files Browse the repository at this point in the history
add fn for wallet/unlock endpoint
  • Loading branch information
ross-weir authored Dec 27, 2023
2 parents 357520f + b5dca3f commit 0abb870
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/node_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,23 @@ impl NodeInterface {
Err(NodeError::FailedParsingWalletStatus(res_json.pretty(2)))
}
}

/// Unlock wallet
pub fn wallet_unlock(&self, password: &str) -> Result<bool> {
let endpoint = "/wallet/unlock";
let body = object! {
pass: password,
};

let res = self.send_post_req(endpoint, body.to_string())?;

if res.status().is_success() {
Ok(true)
} else {
let json = self.parse_response_to_json(Ok(res))?;
Err(NodeError::BadRequest(json["error"].to_string()))
}
}
}

#[serde_as]
Expand Down

0 comments on commit 0abb870

Please sign in to comment.