Skip to content

Commit

Permalink
Return fake results for validateaddress and getdifficulty RPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Feb 1, 2023
1 parent bab16f8 commit cd5c308
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions zebra-rpc/src/methods/get_block_template_rpcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ pub trait GetBlockTemplateRpc {
/// zcashd reference: [`getblocksubsidy`](https://zcash.github.io/rpc/getblocksubsidy.html)
#[rpc(name = "getblocksubsidy")]
fn get_block_subsidy(&self, height: Option<u32>) -> BoxFuture<Result<BlockSubsidy>>;

/// Stub for validate address RPC.
#[rpc(name = "validateaddress")]
fn validate_address(&self, address: String) -> BoxFuture<Result<ValidateAddressStub>>;

/// Stub for difficulty RPC.
#[rpc(name = "getdifficulty")]
fn get_difficulty(&self) -> BoxFuture<Result<f64>>;
}

/// RPC method implementations.
Expand Down Expand Up @@ -829,6 +837,30 @@ where
}
.boxed()
}

/// Stub for validate address RPC.
fn validate_address(&self, address: String) -> BoxFuture<Result<ValidateAddressStub>> {
// Just approve all addresses for now
async {
Ok(ValidateAddressStub {
is_valid: true,
address,
})
}
.boxed()
}

fn get_difficulty(&self) -> BoxFuture<Result<f64>> {
// Just give a dummy answer
async { Ok(1.0) }.boxed()
}
}

// Put support functions in a submodule, to keep this file small.

#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ValidateAddressStub {
#[serde(rename = "isvalid")]
pub is_valid: bool,
pub address: String,
}

0 comments on commit cd5c308

Please sign in to comment.