blvm-node 0.1.2

Bitcoin Commons BLVM: Minimal Bitcoin node implementation using blvm-protocol and blvm-consensus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Fee estimation endpoints
//!
//! GET /api/v1/fees/estimate

use crate::rpc::mining::MiningRpc;
use anyhow::Result;
use serde_json::{json, Value};

/// Get fee estimate
pub async fn get_fee_estimate(mining: &MiningRpc, blocks: Option<u64>) -> Result<Value> {
    let params = if let Some(blocks) = blocks {
        json!([blocks])
    } else {
        json!([6]) // Default to 6 blocks
    };
    let estimate = mining.estimate_smart_fee(&params).await?;
    Ok(estimate)
}