Support arbitrary RPC providers in monero-serai

Sets a clean path for no-std premised RPCs (buffers to an external RPC impl)/
Tor-based RPCs/client-side load balancing/...
This commit is contained in:
Luke Parker
2023-05-02 02:39:08 -04:00
parent 5765d1d278
commit adfbde6e24
10 changed files with 123 additions and 74 deletions

View File

@@ -33,7 +33,7 @@ use crate::{
RctBase, RctPrunable, RctSignatures,
},
transaction::{Input, Output, Timelock, TransactionPrefix, Transaction},
rpc::{Rpc, RpcError},
rpc::{RpcError, RpcConnection, Rpc},
wallet::{
address::{Network, AddressSpec, MoneroAddress},
ViewPair, SpendableOutput, Decoys, PaymentId, ExtraField, Extra, key_image_sort, uniqueness,
@@ -147,9 +147,9 @@ pub enum TransactionError {
FrostError(FrostError),
}
async fn prepare_inputs<R: RngCore + CryptoRng>(
async fn prepare_inputs<R: RngCore + CryptoRng, RPC: RpcConnection>(
rng: &mut R,
rpc: &Rpc,
rpc: &Rpc<RPC>,
ring_len: usize,
inputs: &[SpendableOutput],
spend: &Zeroizing<Scalar>,
@@ -663,10 +663,10 @@ impl SignableTransaction {
}
/// Sign this transaction.
pub async fn sign<R: RngCore + CryptoRng>(
pub async fn sign<R: RngCore + CryptoRng, RPC: RpcConnection>(
mut self,
rng: &mut R,
rpc: &Rpc,
rpc: &Rpc<RPC>,
spend: &Zeroizing<Scalar>,
) -> Result<Transaction, TransactionError> {
let mut images = Vec::with_capacity(self.inputs.len());

View File

@@ -30,7 +30,7 @@ use crate::{
RctPrunable,
},
transaction::{Input, Transaction},
rpc::Rpc,
rpc::{RpcConnection, Rpc},
wallet::{
TransactionError, InternalPayment, SignableTransaction, Decoys, key_image_sort, uniqueness,
},
@@ -74,9 +74,9 @@ pub struct TransactionSignatureMachine {
impl SignableTransaction {
/// Create a FROST signing machine out of this signable transaction.
/// The height is the Monero blockchain height to synchronize around.
pub async fn multisig(
pub async fn multisig<RPC: RpcConnection>(
self,
rpc: &Rpc,
rpc: &Rpc<RPC>,
keys: ThresholdKeys<Ed25519>,
mut transcript: RecommendedTranscript,
height: usize,