remove height argument from fee related functions as per fixpastfees RFC (#602)

* remove height argument from fee related functions as per fixpastfees RFC

* Cargo.lock updated from cargo update -p grin_core
This commit is contained in:
John Tromp
2021-05-19 14:27:42 -04:00
committed by GitHub
parent 83fd8ffc86
commit b7f587f2b3
7 changed files with 36 additions and 43 deletions
+3 -4
View File
@@ -16,7 +16,6 @@
use uuid::Uuid;
use crate::grin_core::consensus::YEAR_HEIGHT;
use crate::grin_core::core::hash::Hashed;
use crate::grin_core::core::Transaction;
use crate::grin_util::secp::key::SecretKey;
@@ -404,7 +403,7 @@ where
tx.amount_credited - tx.amount_debited
} else {
let fee = match tx.fee {
Some(f) => f.fee(2 * YEAR_HEIGHT), // apply fee mask past HF4
Some(f) => f.fee(), // apply fee mask past HF4
None => 0,
};
tx.amount_debited - tx.amount_credited - fee
@@ -800,7 +799,7 @@ where
args.max_outputs as usize,
args.num_change_outputs as usize,
args.selection_strategy_is_use_all,
Some(context.fee.map(|f| f.fee(current_height)).unwrap_or(0)),
Some(context.fee.map(|f| f.fee()).unwrap_or(0)),
parent_key_id.clone(),
false,
true,
@@ -907,7 +906,7 @@ where
Some(tx) => {
let mut slate = Slate::blank(2, false);
slate.tx = Some(tx.clone());
slate.fee_fields = tx.aggregate_fee_fields(2 * YEAR_HEIGHT).unwrap(); // apply fee mask past HF4
slate.fee_fields = tx.aggregate_fee_fields().unwrap(); // apply fee mask past HF4
slate.id = id;
slate.offset = tx.offset;
slate.state = SlateState::Standard3;
+7 -11
View File
@@ -16,7 +16,6 @@
//! around during an interactive wallet exchange
use crate::error::{Error, ErrorKind};
use crate::grin_core::consensus::YEAR_HEIGHT;
use crate::grin_core::core::amount_to_hr_string;
use crate::grin_core::core::transaction::{
FeeFields, Input, Inputs, KernelFeatures, NRDRelativeHeight, Output, OutputFeatures,
@@ -552,21 +551,18 @@ impl Slate {
// we could just overwrite the fee here (but we won't) due to the sig
let fee = tx_fee(tx.inputs().len(), tx.outputs().len(), tx.kernels().len());
if fee > tx.fee(2 * YEAR_HEIGHT) {
if fee > tx.fee() {
// apply fee mask past HF4
return Err(ErrorKind::Fee(format!(
"Fee Dispute Error: {}, {}",
tx.fee(2 * YEAR_HEIGHT),
fee,
))
.into());
return Err(
ErrorKind::Fee(format!("Fee Dispute Error: {}, {}", tx.fee(), fee,)).into(),
);
}
if fee > self.amount + self.fee_fields.fee(2 * YEAR_HEIGHT) {
if fee > self.amount + self.fee_fields.fee() {
let reason = format!(
"Rejected the transfer because transaction fee ({}) exceeds received amount ({}).",
amount_to_hr_string(fee, false),
amount_to_hr_string(self.amount + self.fee_fields.fee(2 * YEAR_HEIGHT), false)
amount_to_hr_string(self.amount + self.fee_fields.fee(), false)
);
info!("{}", reason);
return Err(ErrorKind::Fee(reason).into());
@@ -675,7 +671,7 @@ impl Slate {
// confirm the overall transaction is valid (including the updated kernel)
// accounting for tx weight limits
if let Err(e) = final_tx.validate(Weighting::AsTransaction, 0) {
if let Err(e) = final_tx.validate(Weighting::AsTransaction) {
error!("Error with final tx validation: {}", e);
Err(e.into())
} else {
+1 -2
View File
@@ -14,7 +14,6 @@
//! Wraps a V4 Slate into a V4 Binary slate
use crate::grin_core::consensus::YEAR_HEIGHT;
use crate::grin_core::core::transaction::{FeeFields, OutputFeatures};
use crate::grin_core::ser as grin_ser;
use crate::grin_core::ser::{Readable, Reader, Writeable, Writer};
@@ -108,7 +107,7 @@ impl Writeable for SlateOptFields {
if self.amt > 0 {
status |= 0x02;
}
if self.fee.fee(2 * YEAR_HEIGHT) > 0 {
if self.fee.fee() > 0 {
// apply fee mask past HF4
status |= 0x04;
}