Skip to content

Commit

Permalink
Merge pull request #17 from zackbalbin/recommended-fee
Browse files Browse the repository at this point in the history
add fn for transactions/getFee node endpoint
  • Loading branch information
greenhat authored May 31, 2023
2 parents 08032d2 + 3088ebc commit 5404adf
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit 5404adf

Please sign in to comment.