rust-bitcoin-unsafe-fast/internals
merge-script 515c0f584a
Merge rust-bitcoin/rust-bitcoin#3559: Replace `String` with `InputString`
3f2e760d1f Replace String with InputString in ParseIntError (Tobin C. Harding)
aa5c78430c Replace invalidInteger with ParseIntError (Tobin C. Harding)
9b7a706bfd Remove From<ParseIntError> (Tobin C. Harding)
c90f4b6033 Fix bug in error output (Tobin C. Harding)
c986b2f620 internals: Move error.rs to error/mod.rs (Tobin C. Harding)

Pull request description:

  This PR hopefully clears the way for removing many of the `alloc` feature gates in `units` and `primitives`

  The three final patches were tested by adding the following test to `units::locktime::absolute`:
  ```rust
      #[test]
      pub fn debug_absolute_error_conversion_height() {
          let invalid_height = LOCK_TIME_THRESHOLD + 1;
          let err = Height::from_consensus(invalid_height).unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let invalid_time =  LOCK_TIME_THRESHOLD - 1;
          let err = Time::from_consensus(invalid_time).unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let invalid_height = std::format!("{:x}", LOCK_TIME_THRESHOLD + 1);
          let err = Height::from_hex(&invalid_height).unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let invalid_time = std::format!("{:x}", LOCK_TIME_THRESHOLD - 1);
          let err = Time::from_hex(&invalid_time).unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let err = Height::from_hex("somerandomshit").unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);

          let err = Time::from_hex("somerandomshit").unwrap_err();
          std::println!("{:?}", err);
          std::println!("{}", err);
      }
  ```

  Gives the following output (the last four lines is the bit that changes, the rest just proves we don't break other variants)

  On commit: `d47ff1c25 Remove From<ParseIntError>`

  ConversionError { unit: Blocks, input: 500000001 }
  invalid lock time value 500000001, expected lock-by-blockheight (must be < 500000000)
  ConversionError { unit: Seconds, input: 499999999 }
  invalid lock time value 499999999, expected lock-by-blocktime (must be >= 500000000)
  ParseHeightError(Conversion(500000001))
  block height 500000001 is above limit 499999999
  ParseTimeError(Conversion(499999999))
  block height 499999999 is below limit 500000000
  ParseHeightError(InvalidInteger { source: ParseIntError { kind: InvalidDigit }, input: "somerandomshit" })
  failed to parse somerandomshit as block height
  ParseTimeError(InvalidInteger { source: ParseIntError { kind: InvalidDigit }, input: "somerandomshit" })
  failed to parse somerandomshit as block time

  On commit: `0155a0d9a Replace invalidInteger with ParseIntError`

  ConversionError { unit: Blocks, input: 500000001 }
  invalid lock time value 500000001, expected lock-by-blockheight (must be < 500000000)
  ConversionError { unit: Seconds, input: 499999999 }
  invalid lock time value 499999999, expected lock-by-blocktime (must be >= 500000000)
  ParseHeightError(Conversion(500000001))
  block height 500000001 is above limit 499999999
  ParseTimeError(Conversion(499999999))
  block height 499999999 is below limit 500000000
  ParseHeightError(ParseInt(ParseIntError { input: "somerandomshit", bits: 32, is_signed: true, source: ParseIntError { kind: InvalidDigit } }))
  failed to parse somerandomshit as block height
  ParseTimeError(ParseInt(ParseIntError { input: "somerandomshit", bits: 32, is_signed: true, source: ParseIntError { kind: InvalidDigit } }))
  failed to parse somerandomshit as block time

  On Commit: `3f2e760d1 Replace String with InputString in ParseIntError`

  ConversionError { unit: Blocks, input: 500000001 }
  invalid lock time value 500000001, expected lock-by-blockheight (must be < 500000000)
  ConversionError { unit: Seconds, input: 499999999 }
  invalid lock time value 499999999, expected lock-by-blocktime (must be >= 500000000)
  ParseHeightError(Conversion(500000001))
  block height 500000001 is above limit 499999999
  ParseTimeError(Conversion(499999999))
  block time 499999999 is below limit 500000000
  ParseHeightError(ParseInt(ParseIntError { input: InputString("somerandomshit"), bits: 32, is_signed: true, source: ParseIntError { kind: InvalidDigit } }))
  failed to parse 'somerandomshit' as absolute Height/Time (block height)
  ParseTimeError(ParseInt(ParseIntError { input: InputString("somerandomshit"), bits: 32, is_signed: true, source: ParseIntError { kind: InvalidDigit } }))
  failed to parse 'somerandomshit' as absolute Height/Time (block time)

ACKs for top commit:
  apoelstra:
    ACK 3f2e760d1fef2951f93a2554cd53340b0d7a6e0b; successfully ran local tests; nice!

Tree-SHA512: f7fd55acfb83082419db22c24a6b375c20e2631263401e500410c5b5659463f06dc4bdb145621e475dc15d75e764668cdcbf8f88006a487248a05fdb237ad136
2024-11-01 16:27:07 +00:00
..
contrib CI: Remove shebang from non-executable scripts 2024-05-31 10:10:00 +10:00
src Merge rust-bitcoin/rust-bitcoin#3559: Replace `String` with `InputString` 2024-11-01 16:27:07 +00:00
CHANGELOG.md Bump version of internals to 0.4.0 2024-09-18 12:22:59 +10:00
Cargo.toml Bump hex-conservative to 0.3.0 2024-10-31 03:36:22 +00:00
README.md chore: format and standardize all markdowns files 2024-04-27 06:29:23 -03:00
build.rs 2024-08-25 automated rustfmt nightly 2024-08-25 01:14:09 +00:00

README.md

Rust Bitcoin Internals

This crate is only meant to be used internally by crates in the rust-bitcoin ecosystem.

This crate will never be stabilized, depend on it at your own risk.