1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
crate::ix!();
#[derive(Default)]
pub struct GenerateToAddressRequestHandler {
address_str: String,
}
impl BaseRequestHandler for GenerateToAddressRequestHandler {
fn prepare_request(&mut self,
method: &str,
args: &Vec<String>) -> Result<UniValue,StdException> {
self.address_str = args[1].to_string();
let params: UniValue = UniValue::from(
rpc_convert_values(
"generatetoaddress",
args
)
);
Ok(
jsonrpc_request_obj(
"generatetoaddress",
¶ms,
&UniValue::from(1_i32)
)
)
}
fn process_reply(&mut self, reply: &UniValue) -> Result<UniValue,StdException> {
let mut result: UniValue = UniValue::from(uni_value::VType::VOBJ);
result.pushkv("address", &self.address_str);
result.pushkv("blocks", &reply.get_obj()["result"]);
Ok(jsonrpc_reply_obj(
&result,
&NULL_UNI_VALUE,
&UniValue::from(1_i32)
))
}
}