to_u32

Function to_u32 

Source
pub fn to_u32(value: i64, field: &str) -> Result<u32, NumericError>
Expand description

Converts an i64 numeric type to a u32.

The Bitcoin Core JSONRPC API has fields marked as ‘numeric’. It is not obvious what Rust type these fields should be.

We want the version specific JSON types to just work (TM).

  1. We use an i64 because its the biggest signed integer on “common” machines.
  2. We use a signed integer because Core sometimes returns -1.

(2) was discovered in the wild but is hard to test for.