Skip to content

Commit 112f87b

Browse files
committed
add fn for transactions/getFee node endpoint
1 parent 08032d2 commit 112f87b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/transactions.rs

+11
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ impl NodeInterface {
141141

142142
Ok(res_json)
143143
}
144+
145+
/// Gets the recommended fee for a transaction.
146+
/// bytes - size of the transaction in bytes
147+
/// wait_time - minutes to wait for the transaction to be included in the blockchain
148+
pub fn get_recommended_fee(&self, bytes: u64, wait_time: u64) -> Result<u64> {
149+
let endpoint = format!("/transactions/getFee?bytes={}&waitTime={}", bytes, wait_time);
150+
let res = self.send_get_req(&endpoint);
151+
let res_json = self.parse_response_to_json(res);
152+
let fee = res_json?.as_u64().unwrap();
153+
Ok(fee)
154+
}
144155
}
145156

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

0 commit comments

Comments
 (0)