mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-22 11:39:35 +00:00
monero: Use fee priority enums from monero repo CLI/RPC wallets (#499)
* monero: Use fee priority enums from monero repo CLI/RPC wallets * Update processor for fee priority change * Remove FeePriority::Default Done in consultation with @j-berman. The RPC/CLI/GUI almost always adjust up except barring very explicit commands, hence why FeePriority 0 is now only exposed via the explicit command of FeePriority::Custom { priority: 0 }. Also helps with terminology. --------- Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
This commit is contained in:
parent
6f5d794f10
commit
cda14ac8b9
7 changed files with 17 additions and 17 deletions
|
@ -274,20 +274,22 @@ impl Fee {
|
|||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum FeePriority {
|
||||
Lowest,
|
||||
Low,
|
||||
Medium,
|
||||
High,
|
||||
Unimportant,
|
||||
Normal,
|
||||
Elevated,
|
||||
Priority,
|
||||
Custom { priority: u32 },
|
||||
}
|
||||
|
||||
/// https://github.com/monero-project/monero/blob/ac02af92867590ca80b2779a7bbeafa99ff94dcb/
|
||||
/// src/simplewallet/simplewallet.cpp#L161
|
||||
impl FeePriority {
|
||||
pub(crate) fn fee_priority(&self) -> u32 {
|
||||
match self {
|
||||
FeePriority::Lowest => 0,
|
||||
FeePriority::Low => 1,
|
||||
FeePriority::Medium => 2,
|
||||
FeePriority::High => 3,
|
||||
FeePriority::Unimportant => 1,
|
||||
FeePriority::Normal => 2,
|
||||
FeePriority::Elevated => 3,
|
||||
FeePriority::Priority => 4,
|
||||
FeePriority::Custom { priority, .. } => *priority,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ macro_rules! test {
|
|||
|
||||
let builder = SignableTransactionBuilder::new(
|
||||
protocol,
|
||||
rpc.get_fee(protocol, FeePriority::Low).await.unwrap(),
|
||||
rpc.get_fee(protocol, FeePriority::Unimportant).await.unwrap(),
|
||||
Change::new(
|
||||
&ViewPair::new(
|
||||
&random_scalar(&mut OsRng) * ED25519_BASEPOINT_TABLE,
|
||||
|
|
|
@ -110,7 +110,7 @@ test!(
|
|||
|
||||
let mut builder = SignableTransactionBuilder::new(
|
||||
protocol,
|
||||
rpc.get_fee(protocol, FeePriority::Low).await.unwrap(),
|
||||
rpc.get_fee(protocol, FeePriority::Unimportant).await.unwrap(),
|
||||
Change::new(&change_view, false),
|
||||
);
|
||||
add_inputs(protocol, &rpc, vec![outputs.first().unwrap().clone()], &mut builder).await;
|
||||
|
@ -294,7 +294,7 @@ test!(
|
|||
|
||||
let mut builder = SignableTransactionBuilder::new(
|
||||
protocol,
|
||||
rpc.get_fee(protocol, FeePriority::Low).await.unwrap(),
|
||||
rpc.get_fee(protocol, FeePriority::Unimportant).await.unwrap(),
|
||||
Change::fingerprintable(None),
|
||||
);
|
||||
add_inputs(protocol, &rpc, vec![outputs.first().unwrap().clone()], &mut builder).await;
|
||||
|
|
|
@ -90,9 +90,7 @@ async fn from_wallet_rpc_to_self(spec: AddressSpec) {
|
|||
|
||||
// TODO: Needs https://github.com/monero-project/monero/pull/8882
|
||||
// let fee_rate = daemon_rpc
|
||||
// // Uses `FeePriority::Low` instead of `FeePriority::Lowest` because wallet RPC
|
||||
// // adjusts `monero_rpc::TransferPriority::Default` up by 1
|
||||
// .get_fee(daemon_rpc.get_protocol().await.unwrap(), FeePriority::Low)
|
||||
// .get_fee(daemon_rpc.get_protocol().await.unwrap(), FeePriority::Unimportant)
|
||||
// .await
|
||||
// .unwrap();
|
||||
|
||||
|
|
|
@ -761,7 +761,7 @@ impl Network for Monero {
|
|||
vec![(address.into(), amount - fee)],
|
||||
&Change::fingerprintable(Some(Self::test_address().into())),
|
||||
vec![],
|
||||
self.rpc.get_fee(protocol, FeePriority::Low).await.unwrap(),
|
||||
self.rpc.get_fee(protocol, FeePriority::Unimportant).await.unwrap(),
|
||||
)
|
||||
.unwrap()
|
||||
.sign(&mut OsRng, &Zeroizing::new(Scalar::ONE.0))
|
||||
|
|
|
@ -389,7 +389,7 @@ async fn mint_and_burn_test() {
|
|||
)],
|
||||
&Change::new(&view_pair, false),
|
||||
vec![Shorthand::transfer(None, serai_addr).encode()],
|
||||
rpc.get_fee(Protocol::v16, FeePriority::Low).await.unwrap(),
|
||||
rpc.get_fee(Protocol::v16, FeePriority::Unimportant).await.unwrap(),
|
||||
)
|
||||
.unwrap()
|
||||
.sign(&mut OsRng, &Zeroizing::new(Scalar::ONE))
|
||||
|
|
|
@ -342,7 +342,7 @@ impl Wallet {
|
|||
vec![(to_addr, AMOUNT)],
|
||||
&Change::new(view_pair, false),
|
||||
data,
|
||||
rpc.get_fee(Protocol::v16, FeePriority::Low).await.unwrap(),
|
||||
rpc.get_fee(Protocol::v16, FeePriority::Unimportant).await.unwrap(),
|
||||
)
|
||||
.unwrap()
|
||||
.sign(&mut OsRng, spend_key)
|
||||
|
|
Loading…
Reference in a new issue