Roman Zeyde
5 years ago
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with
4 additions and
4 deletions
-
src/query.rs
-
src/rpc.rs
|
@ -503,7 +503,7 @@ impl Query { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Fee rate [BTC/kB] to be confirmed in `blocks` from now.
|
|
|
// Fee rate [BTC/kB] to be confirmed in `blocks` from now.
|
|
|
pub fn estimate_fee(&self, blocks: usize) -> f32 { |
|
|
pub fn estimate_fee(&self, blocks: usize) -> f64 { |
|
|
let mut total_vsize = 0u32; |
|
|
let mut total_vsize = 0u32; |
|
|
let mut last_fee_rate = 0.0; |
|
|
let mut last_fee_rate = 0.0; |
|
|
let blocks_in_vbytes = (blocks * 1_000_000) as u32; // assume ~1MB blocks
|
|
|
let blocks_in_vbytes = (blocks * 1_000_000) as u32; // assume ~1MB blocks
|
|
@ -514,7 +514,7 @@ impl Query { |
|
|
break; // under-estimate the fee rate a bit
|
|
|
break; // under-estimate the fee rate a bit
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
last_fee_rate * 1e-5 // [BTC/kB] = 10^5 [sat/B]
|
|
|
(last_fee_rate as f64) * 1e-5 // [BTC/kB] = 10^5 [sat/B]
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pub fn get_banner(&self) -> Result<String> { |
|
|
pub fn get_banner(&self) -> Result<String> { |
|
|
|
@ -194,11 +194,11 @@ impl Connection { |
|
|
fn blockchain_estimatefee(&self, params: &[Value]) -> Result<Value> { |
|
|
fn blockchain_estimatefee(&self, params: &[Value]) -> Result<Value> { |
|
|
let blocks_count = usize_from_value(params.get(0), "blocks_count")?; |
|
|
let blocks_count = usize_from_value(params.get(0), "blocks_count")?; |
|
|
let fee_rate = self.query.estimate_fee(blocks_count); // in BTC/kB
|
|
|
let fee_rate = self.query.estimate_fee(blocks_count); // in BTC/kB
|
|
|
Ok(json!(fee_rate)) |
|
|
Ok(json!(fee_rate.max(self.relayfee))) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fn blockchain_relayfee(&self) -> Result<Value> { |
|
|
fn blockchain_relayfee(&self) -> Result<Value> { |
|
|
Ok(json!(self.relayfee)) |
|
|
Ok(json!(self.relayfee)) // in BTC/kB
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fn blockchain_scripthash_subscribe(&mut self, params: &[Value]) -> Result<Value> { |
|
|
fn blockchain_scripthash_subscribe(&mut self, params: &[Value]) -> Result<Value> { |
|
|