mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 05:09:22 +00:00
Remove the DecoySelection trait
This commit is contained in:
@@ -28,18 +28,17 @@ test!(
|
||||
// Then make a second tx1
|
||||
|rct_type: RctType, rpc: SimpleRequestRpc, mut builder: Builder, addr, state: _| async move {
|
||||
let output_tx0: WalletOutput = state;
|
||||
let decoys = Decoys::fingerprintable_canonical_select(
|
||||
|
||||
let input = OutputWithDecoys::fingerprintable_deterministic_new(
|
||||
&mut OsRng,
|
||||
&rpc,
|
||||
ring_len(rct_type),
|
||||
rpc.get_height().await.unwrap(),
|
||||
&[output_tx0.clone()],
|
||||
output_tx0.clone(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let inputs = [output_tx0.clone()].into_iter().zip(decoys).collect::<Vec<_>>();
|
||||
builder.add_inputs(&inputs);
|
||||
builder.add_input(input);
|
||||
builder.add_payment(addr, 1000000000000);
|
||||
|
||||
(builder.build().unwrap(), (rct_type, output_tx0))
|
||||
@@ -66,17 +65,19 @@ test!(
|
||||
let mut selected_fresh_decoy = false;
|
||||
let mut attempts = 1000;
|
||||
while !selected_fresh_decoy && attempts > 0 {
|
||||
let decoys = Decoys::fingerprintable_canonical_select(
|
||||
let decoys = OutputWithDecoys::fingerprintable_deterministic_new(
|
||||
&mut OsRng, // TODO: use a seeded RNG to consistently select the latest output
|
||||
&rpc,
|
||||
ring_len(rct_type),
|
||||
height,
|
||||
&[output_tx0.clone()],
|
||||
output_tx0.clone(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
.unwrap()
|
||||
.decoys()
|
||||
.clone();
|
||||
|
||||
selected_fresh_decoy = decoys[0].positions().contains(&most_recent_o_index);
|
||||
selected_fresh_decoy = decoys.positions().contains(&most_recent_o_index);
|
||||
attempts -= 1;
|
||||
}
|
||||
|
||||
@@ -107,18 +108,16 @@ test!(
|
||||
|rct_type: RctType, rpc, mut builder: Builder, addr, output_tx0: WalletOutput| async move {
|
||||
let rpc: SimpleRequestRpc = rpc;
|
||||
|
||||
let decoys = Decoys::select(
|
||||
let input = OutputWithDecoys::new(
|
||||
&mut OsRng,
|
||||
&rpc,
|
||||
ring_len(rct_type),
|
||||
rpc.get_height().await.unwrap(),
|
||||
&[output_tx0.clone()],
|
||||
output_tx0.clone(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let inputs = [output_tx0.clone()].into_iter().zip(decoys).collect::<Vec<_>>();
|
||||
builder.add_inputs(&inputs);
|
||||
builder.add_input(input);
|
||||
builder.add_payment(addr, 1000000000000);
|
||||
|
||||
(builder.build().unwrap(), (rct_type, output_tx0))
|
||||
@@ -145,17 +144,19 @@ test!(
|
||||
let mut selected_fresh_decoy = false;
|
||||
let mut attempts = 1000;
|
||||
while !selected_fresh_decoy && attempts > 0 {
|
||||
let decoys = Decoys::select(
|
||||
let decoys = OutputWithDecoys::new(
|
||||
&mut OsRng, // TODO: use a seeded RNG to consistently select the latest output
|
||||
&rpc,
|
||||
ring_len(rct_type),
|
||||
height,
|
||||
&[output_tx0.clone()],
|
||||
output_tx0.clone(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
.unwrap()
|
||||
.decoys()
|
||||
.clone();
|
||||
|
||||
selected_fresh_decoy = decoys[0].positions().contains(&most_recent_o_index);
|
||||
selected_fresh_decoy = decoys.positions().contains(&most_recent_o_index);
|
||||
attempts -= 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use zeroize::{Zeroize, Zeroizing};
|
||||
|
||||
use monero_wallet::{
|
||||
primitives::Decoys,
|
||||
ringct::RctType,
|
||||
rpc::FeeRate,
|
||||
address::MoneroAddress,
|
||||
WalletOutput,
|
||||
OutputWithDecoys,
|
||||
send::{Change, SendError, SignableTransaction},
|
||||
extra::MAX_ARBITRARY_DATA_SIZE,
|
||||
};
|
||||
@@ -15,7 +14,7 @@ use monero_wallet::{
|
||||
pub struct SignableTransactionBuilder {
|
||||
rct_type: RctType,
|
||||
outgoing_view_key: Zeroizing<[u8; 32]>,
|
||||
inputs: Vec<(WalletOutput, Decoys)>,
|
||||
inputs: Vec<OutputWithDecoys>,
|
||||
payments: Vec<(MoneroAddress, u64)>,
|
||||
change: Change,
|
||||
data: Vec<Vec<u8>>,
|
||||
@@ -40,12 +39,12 @@ impl SignableTransactionBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_input(&mut self, input: (WalletOutput, Decoys)) -> &mut Self {
|
||||
pub fn add_input(&mut self, input: OutputWithDecoys) -> &mut Self {
|
||||
self.inputs.push(input);
|
||||
self
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn add_inputs(&mut self, inputs: &[(WalletOutput, Decoys)]) -> &mut Self {
|
||||
pub fn add_inputs(&mut self, inputs: &[OutputWithDecoys]) -> &mut Self {
|
||||
self.inputs.extend(inputs.iter().cloned());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -198,13 +198,10 @@ macro_rules! test {
|
||||
};
|
||||
|
||||
use monero_wallet::{
|
||||
primitives::Decoys,
|
||||
ringct::RctType,
|
||||
rpc::FeePriority,
|
||||
address::Network,
|
||||
ViewPair,
|
||||
DecoySelection,
|
||||
Scanner,
|
||||
ViewPair, Scanner, OutputWithDecoys,
|
||||
send::{Change, SignableTransaction, Eventuality},
|
||||
};
|
||||
|
||||
@@ -300,16 +297,14 @@ macro_rules! test {
|
||||
let temp = Box::new({
|
||||
let mut builder = builder.clone();
|
||||
|
||||
let decoys = Decoys::fingerprintable_canonical_select(
|
||||
let input = OutputWithDecoys::fingerprintable_deterministic_new(
|
||||
&mut OsRng,
|
||||
&rpc,
|
||||
ring_len(rct_type),
|
||||
rpc.get_height().await.unwrap(),
|
||||
&[miner_tx.clone()],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
builder.add_input((miner_tx, decoys.first().unwrap().clone()));
|
||||
miner_tx,
|
||||
).await.unwrap();
|
||||
builder.add_input(input);
|
||||
|
||||
let (tx, state) = ($first_tx)(rpc.clone(), builder, next_addr).await;
|
||||
let fee_rate = tx.fee_rate().clone();
|
||||
|
||||
@@ -4,8 +4,8 @@ use rand_core::OsRng;
|
||||
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::{
|
||||
primitives::Decoys, ringct::RctType, transaction::Transaction, rpc::Rpc,
|
||||
address::SubaddressIndex, extra::Extra, WalletOutput, DecoySelection,
|
||||
ringct::RctType, transaction::Transaction, rpc::Rpc, address::SubaddressIndex, extra::Extra,
|
||||
WalletOutput, OutputWithDecoys,
|
||||
};
|
||||
|
||||
mod runner;
|
||||
@@ -18,19 +18,19 @@ async fn add_inputs(
|
||||
outputs: Vec<WalletOutput>,
|
||||
builder: &mut SignableTransactionBuilder,
|
||||
) {
|
||||
let decoys = Decoys::fingerprintable_canonical_select(
|
||||
&mut OsRng,
|
||||
rpc,
|
||||
ring_len(rct_type),
|
||||
rpc.get_height().await.unwrap(),
|
||||
&outputs,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let inputs = outputs.into_iter().zip(decoys).collect::<Vec<_>>();
|
||||
|
||||
builder.add_inputs(&inputs);
|
||||
for output in outputs {
|
||||
builder.add_input(
|
||||
OutputWithDecoys::fingerprintable_deterministic_new(
|
||||
&mut OsRng,
|
||||
rpc,
|
||||
ring_len(rct_type),
|
||||
rpc.get_height().await.unwrap(),
|
||||
output,
|
||||
)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
test!(
|
||||
|
||||
Reference in New Issue
Block a user