Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fn for transactions/getFee node endpoint #17

Merged
merged 2 commits into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@ impl NodeInterface {

Ok(res_json)
}

/// Gets the recommended fee for a transaction.
/// bytes - size of the transaction in bytes
/// wait_time - minutes to wait for the transaction to be included in the blockchain
pub fn get_recommended_fee(&self, bytes: u64, wait_time: u64) -> Result<u64> {
let endpoint = format!(
"/transactions/getFee?bytes={}&waitTime={}",
bytes, wait_time
);
let res = self.send_get_req(&endpoint);
let res_json = self.parse_response_to_json(res);
let fee = res_json?.as_u64().unwrap();
Ok(fee)
}
}

fn parse_tx_id_unsafe(mut res_json: JsonValue) -> TxId {
Expand Down