Fixfees (#3481)
* add FeeFields type
* use FeeFields with ::zero and try_into().unwrap()
* fixed tests
* avoid 0 accept_base_fee
* add aggregate_fee_fields method for transaction
* implement std::fmt::Display trait for FeeFields
* make base_fee argument non-optional in libtx::mod::tx_fee
* add global and thread local accept_fee_base; use to simplify tests
* set unusually high fee base for a change
* revert to optional base fee argument; default coming from either grin-{server,wallet}.toml
* remove optional base fee argument; can be set with global::set_local_accept_fee_base instead
* define constant global::DEFAULT_ACCEPT_FEE_BASE and set global value
* add Transaction::accept_fee() method and use
* Manual (de)ser impl on FeeFields
* fix comment bug
* Serialize FeeFields as int in tx
* allow feefields: u32:into() for tests
* try adding height args everywhere
* make FeeFields shift/fee methods height dependent
* prior to hf4 feefield testing
* rename selected fee_fields back to fee for serialization compatibility
* fix test_fee_fields test, merge conflict, and doctest use of obsolete fee_fields
* make accept_fee height dependent
* Accept any u64 in FeeFields deser
Co-authored-by: Jasper van der Maarel <j@sper.dev>
This commit is contained in:
+9
-3
@@ -13,9 +13,10 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::chain;
|
||||
use crate::core::consensus::YEAR_HEIGHT;
|
||||
use crate::core::core::hash::Hashed;
|
||||
use crate::core::core::merkle_proof::MerkleProof;
|
||||
use crate::core::core::{KernelFeatures, TxKernel};
|
||||
use crate::core::core::{FeeFields, KernelFeatures, TxKernel};
|
||||
use crate::core::{core, ser};
|
||||
use crate::p2p;
|
||||
use crate::util::secp::pedersen;
|
||||
@@ -499,6 +500,7 @@ impl<'de> serde::de::Deserialize<'de> for OutputPrintable {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct TxKernelPrintable {
|
||||
pub features: String,
|
||||
pub fee_shift: u8,
|
||||
pub fee: u64,
|
||||
pub lock_height: u64,
|
||||
pub excess: String,
|
||||
@@ -508,17 +510,21 @@ pub struct TxKernelPrintable {
|
||||
impl TxKernelPrintable {
|
||||
pub fn from_txkernel(k: &core::TxKernel) -> TxKernelPrintable {
|
||||
let features = k.features.as_string();
|
||||
let (fee, lock_height) = match k.features {
|
||||
let (fee_fields, lock_height) = match k.features {
|
||||
KernelFeatures::Plain { fee } => (fee, 0),
|
||||
KernelFeatures::Coinbase => (0, 0),
|
||||
KernelFeatures::Coinbase => (FeeFields::zero(), 0),
|
||||
KernelFeatures::HeightLocked { fee, lock_height } => (fee, lock_height),
|
||||
KernelFeatures::NoRecentDuplicate {
|
||||
fee,
|
||||
relative_height,
|
||||
} => (fee, relative_height.into()),
|
||||
};
|
||||
let height = 2 * YEAR_HEIGHT; // print as if post-HF4
|
||||
let fee = fee_fields.fee(height);
|
||||
let fee_shift: u8 = fee_fields.fee_shift(height);
|
||||
TxKernelPrintable {
|
||||
features,
|
||||
fee_shift,
|
||||
fee,
|
||||
lock_height,
|
||||
excess: k.excess.to_hex(),
|
||||
|
||||
Reference in New Issue
Block a user