Conversation
- `--fee_rate` was parsed as `f32` and cast with `as u64`, which is both truncating and saturating, and when `FeeRate::from_sat_per_vb` returned None the value was silently dropped. Update parsing fee_rate at the clap boundary instead and `FeeRate` counts sat/kwu, so fractional rates keep 1/250 sat/vB precision rather than being truncated, and anything that cannot be represented is rejected. - The `--add_data` and `--add_string` length was not checked. The limit is now 99994 data bytes, Core v30's default `-datacarriersize` of 100_000 minus the 6 bytes the `OP_RETURN` opcode and `OP_PUSHDATA4` prefix occupy, since Core measures the whole scriptPubKey. A unit test pins that arithmetic against `ScriptBuf::new_op_return`.
- update `create_tx`, `create_sp_tx`,` `bump_fee` commands where `unwrap()` was called on Results and panicked. - update fee_rate calculations accross create_tx, create_sp_tx - update OP_RETURN data parsing accross the commands - add test to check against panics and invalid fee_rates
- update fee_rate in dns module and payjoin - update error propagation in dns and payjoin - update CHANGELOG
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #326 +/- ##
==========================================
+ Coverage 57.78% 58.75% +0.97%
==========================================
Files 22 22
Lines 3733 3773 +40
==========================================
+ Hits 2157 2217 +60
+ Misses 1576 1556 -20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses input-validation problems on the transaction-building commands (create_tx, create_sp_tx, bump_fee), transaction fee rate and OP_RETURN data size:
create_txandbump_feecalled.unwrap()on Results so they panic (exit 101) instead of an error (exit 1).create_sp_txalready guarded these paths, but improvements were made to the error type been returned--fee_ratewas anf32cast withas u64, which truncates and saturates, and aNonefromfrom_sat_per_vbwas silently skipped. Parsing now happens in avalue_parser, so bad values are rejected witha usage message before a wallet is loaded. Because
FeeRatecounts sat/kwu, fractional rates keep 1/250 sat/vB precision instead of being truncated .--add_dataand--add_stringdocument "max 80 bytes" and neither enforced it. This has now been updated to 100_000 bytes and enforced in transaction building.create_dns_txwas had the same fee-rate bug and the same OP_RETURN handling, and has been fixed too.bump_fee --utxosandsend_payjoin -fare fixed by the same changes.Fixes #325
Notes to the reviewers
Changelog notice
create_txandbump_feepanicking on malformed--utxosand--add_datavalues instead of returning an error--fee_ratesilently truncating to a whole sat/vB, falling back to a default, or producing a zero-fee transaction; unusable values are now rejected--add_dataand--add_stringOP_RETURN payloadsChecklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes: