mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-01 11:23:55 +01:00
fixfees on grin-wallet (#526)
* change fee to fee_fields in various structs and fix tests for new fee calculation * set up accept_fee_base param in grin-wallet.toml * fix bug and adopt new tx_fee interface * Fix doctests * Remove left over debug statement * revert field name feef to fee to remain slate compatible * use into() for some literal fee_fields * add height arguments to FeeFields methods where necessary * Fix tests * Rename fee_fields -> fee on Context * Rename fee_fields -> fee on TxLogEntry * Update to grin master * replace fee(0) by fee(2*YEAR_HEIGHT) to get fee masking * Fix compilation error and revert Cargo lock * fix wrong height passed into next_difficulty Co-authored-by: Jasper van der Maarel <j@sper.dev>
This commit is contained in:
co-authored by
Jasper van der Maarel
parent
429db61bb7
commit
8334304c16
@@ -17,6 +17,7 @@
|
||||
use crate::api::TLSConfig;
|
||||
use crate::apiwallet::{try_slatepack_sync_workflow, Owner};
|
||||
use crate::config::{TorConfig, WalletConfig, WALLET_CONFIG_FILE_NAME};
|
||||
use crate::core::core::FeeFields;
|
||||
use crate::core::{core, global};
|
||||
use crate::error::{Error, ErrorKind};
|
||||
use crate::impls::PathToSlatepack;
|
||||
@@ -277,7 +278,7 @@ where
|
||||
let mut slate = Slate::blank(2, false);
|
||||
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
||||
if args.estimate_selection_strategies {
|
||||
let strategies = vec!["smallest", "all"]
|
||||
let strategies: Vec<(&str, u64, FeeFields)> = vec!["smallest", "all"]
|
||||
.into_iter()
|
||||
.map(|strategy| {
|
||||
let init_args = InitTxArgs {
|
||||
@@ -291,7 +292,7 @@ where
|
||||
..Default::default()
|
||||
};
|
||||
let slate = api.init_send_tx(m, init_args).unwrap();
|
||||
(strategy, slate.amount, slate.fee)
|
||||
(strategy, slate.amount, slate.fee_fields)
|
||||
})
|
||||
.collect();
|
||||
display::estimate(args.amount, strategies, dark_scheme);
|
||||
@@ -848,7 +849,7 @@ where
|
||||
..Default::default()
|
||||
};
|
||||
let slate = api.init_send_tx(m, init_args).unwrap();
|
||||
(strategy, slate.amount, slate.fee)
|
||||
(strategy, slate.amount, slate.fee_fields)
|
||||
})
|
||||
.collect();
|
||||
display::estimate(slate.amount, strategies, dark_scheme);
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::core::consensus::YEAR_HEIGHT;
|
||||
use crate::core::core::FeeFields;
|
||||
use crate::core::core::{self, amount_to_hr_string};
|
||||
use crate::core::global;
|
||||
use crate::libwallet::{
|
||||
@@ -189,7 +191,7 @@ pub fn txs(
|
||||
let amount_debited_str = core::amount_to_hr_string(t.amount_debited, true);
|
||||
let amount_credited_str = core::amount_to_hr_string(t.amount_credited, true);
|
||||
let fee = match t.fee {
|
||||
Some(f) => format!("{}", core::amount_to_hr_string(f, true)),
|
||||
Some(f) => format!("{}", core::amount_to_hr_string(f.fee(cur_height), true)),
|
||||
None => "None".to_owned(),
|
||||
};
|
||||
let net_diff = if t.amount_credited >= t.amount_debited {
|
||||
@@ -393,9 +395,9 @@ pub fn info(
|
||||
pub fn estimate(
|
||||
amount: u64,
|
||||
strategies: Vec<(
|
||||
&str, // strategy
|
||||
u64, // total amount to be locked
|
||||
u64, // fee
|
||||
&str, // strategy
|
||||
u64, // total amount to be locked
|
||||
FeeFields, // fee
|
||||
)>,
|
||||
dark_background_color_scheme: bool,
|
||||
) {
|
||||
@@ -412,17 +414,17 @@ pub fn estimate(
|
||||
bMG->"Will be locked",
|
||||
]);
|
||||
|
||||
for (strategy, total, fee) in strategies {
|
||||
for (strategy, total, fee_fields) in strategies {
|
||||
if dark_background_color_scheme {
|
||||
table.add_row(row![
|
||||
bFC->strategy,
|
||||
FR->amount_to_hr_string(fee, false),
|
||||
FR->amount_to_hr_string(fee_fields.fee(2*YEAR_HEIGHT), false), // apply fee mask past HF4
|
||||
FY->amount_to_hr_string(total, false),
|
||||
]);
|
||||
} else {
|
||||
table.add_row(row![
|
||||
bFD->strategy,
|
||||
FR->amount_to_hr_string(fee, false),
|
||||
FR->amount_to_hr_string(fee_fields.fee(2*YEAR_HEIGHT), false), // apply fee mask past HF4
|
||||
FY->amount_to_hr_string(total, false),
|
||||
]);
|
||||
}
|
||||
@@ -484,7 +486,7 @@ pub fn payment_proof(tx: &TxLogEntry) -> Result<(), Error> {
|
||||
None => "None".to_owned(),
|
||||
};
|
||||
let fee = match tx.fee {
|
||||
Some(f) => f,
|
||||
Some(f) => f.fee(2 * YEAR_HEIGHT), // apply fee mask past HF4
|
||||
None => 0,
|
||||
};
|
||||
let amount = if tx.amount_credited >= tx.amount_debited {
|
||||
|
||||
Reference in New Issue
Block a user