commit 9a4377fa16783f23271c9b4f0a85b10103ac798a
parent c246947222128b49ee3054525265cd57a2c54d14
Author: Joris Hartog <jorishartog@hotmail.com>
Date: Thu, 30 Jul 2026 05:45:48 +0200
Reject zero enabled burn rate
Diffstat:
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/adapters/http.rs b/src/adapters/http.rs
@@ -853,6 +853,9 @@ async fn set_burn_settings(
amount: Amount,
fee: Amount,
) -> Result<()> {
+ if enabled && amount == 0 {
+ bail!("IUNA per block must be greater than zero when finalization burns are on");
+ }
let result = {
let mut node = state.node.lock().await;
let result = node.set_automatic_burn_settings(enabled, amount, fee);
@@ -2531,7 +2534,7 @@ const INDEX_HTML: &str = r#"<!doctype html>
<div class="panel-description">Burn IUNA to compete for block finalization. Winning burns finalize PoB/VDF blocks and earn the transaction fees in those blocks.</div>
<form class="mining-form" @submit.prevent="saveBurn">
<div class="burn-fields">
- <label>IUNA per block<input x-model="burnAmountDraft" @input="burnAmountDirty = true; scheduleFeeEstimates()" type="number" min="0" step="0.000001"></label>
+ <label>IUNA per block<input x-model="burnAmountDraft" @input="burnAmountDirty = true; scheduleFeeEstimates()" type="number" min="0.000001" step="0.000001"></label>
<label>Fee / byte<input x-model="burnFeeDraft" @input="burnAmountDirty = true; scheduleFeeEstimates()" type="number" min="0" step="0.000001" required></label>
<button class="primary" type="submit">Save</button>
</div>
@@ -4002,6 +4005,25 @@ mod tests {
}
#[tokio::test]
+ async fn enabled_burn_settings_reject_zero_amount() {
+ let dir = tempfile::tempdir().unwrap();
+ let state = auth_test_state(
+ dir.path().join("config.json"),
+ UiConfig {
+ setup_complete: true,
+ ..UiConfig::default()
+ },
+ )
+ .await;
+
+ let error = super::set_burn_settings(&state, true, 0, MICRO_IUNA)
+ .await
+ .unwrap_err();
+
+ assert!(format!("{error:#}").contains("greater than zero"));
+ }
+
+ #[tokio::test]
async fn pow_mining_config_persistence_updates_config_file() {
let dir = tempfile::tempdir().unwrap();
let config_path = dir.path().join("config.json");
diff --git a/www/assets/iuna-ui.js b/www/assets/iuna-ui.js
@@ -812,6 +812,9 @@ window.iunaApp = function iunaApp() {
try {
const amount = this.parseiunaAmount(this.burnAmountDraft);
const fee = this.parseiunaAmountRequired(this.burnFeeDraft, "Burn fee per byte is required");
+ if (amount === 0) {
+ throw new Error("IUNA per block must be greater than zero");
+ }
this.burnAmountDraft = this.amountLabel(amount);
this.burnFeeDraft = this.amountLabel(fee);
await this.postForm(