Write a test runner for Monero transactions

Also includes a few fixes for the library itself. Supersedes #172.
This commit is contained in:
Luke Parker
2022-12-05 17:25:09 -05:00
parent 7a16ce78b0
commit 8f352353ba
6 changed files with 321 additions and 279 deletions

View File

@@ -27,7 +27,7 @@ pub struct JsonRpcResponse<T> {
#[derive(Deserialize, Debug)]
struct TransactionResponse {
tx_hash: String,
block_height: usize,
block_height: Option<usize>,
as_hex: String,
pruned_as_hex: String,
}
@@ -274,7 +274,7 @@ impl Rpc {
self.get_transactions(&[tx]).await.map(|mut txs| txs.swap_remove(0))
}
pub async fn get_transaction_block_number(&self, tx: &[u8]) -> Result<usize, RpcError> {
pub async fn get_transaction_block_number(&self, tx: &[u8]) -> Result<Option<usize>, RpcError> {
let txs: TransactionsResponse =
self.rpc_call("get_transactions", Some(json!({ "txs_hashes": [hex::encode(tx)] }))).await?;

View File

@@ -18,7 +18,7 @@ pub mod address;
use address::{Network, AddressType, AddressMeta, MoneroAddress};
mod scan;
pub use scan::SpendableOutput;
pub use scan::{ReceivedOutput, SpendableOutput};
pub(crate) mod decoys;
pub(crate) use decoys::Decoys;

View File

@@ -362,7 +362,7 @@ impl SignableTransaction {
/// Sign this transaction.
pub async fn sign<R: RngCore + CryptoRng>(
&mut self,
mut self,
rng: &mut R,
rpc: &Rpc,
spend: &Zeroizing<Scalar>,