GithubHelp home page GithubHelp logo

Comments (8)

apoelstra avatar apoelstra commented on June 25, 2024

Ouch. I think these De/serialize implementations are really weird and we shouldn't have released them.

For the two LockTime types I think we should de/serialize both as consensus-encoded u32s with checks. For Height and Time we should just use #[serde(from = LockTime)] and #[serde(try_into = LockTime)] (and we should implement the appropriate From/TryInto to make this work).

And for relative::LockTime we should in turn use #[serde(try_from = Sequence)] and #[serde(into = Sequence)].

In other words everything just passes through to the "real" type that's part of a transaction.

from rust-bitcoin.

apoelstra avatar apoelstra commented on June 25, 2024

Other options are:

  • Keep the current situation, which for relative::LockTime is actually fine (both Height and Time are represented as u16s and all values are legal). For absolute we have to add error checking as you say.
  • Drop Deserialize and Serialize for Height and Time in both modules, since it's weird to be using these types outside of a LockTime.

from rust-bitcoin.

tcharding avatar tcharding commented on June 25, 2024

Flagging that, as mentioned above, this issue should only relate to absolute::{Height, Time} types.

from rust-bitcoin.

Kixunil avatar Kixunil commented on June 25, 2024

OK, I suggest serde(try_from = "LockTime") for the absolute types and don't touch others.

from rust-bitcoin.

apoelstra avatar apoelstra commented on June 25, 2024

Yeah, that seems reasonable to me, if a little inconsistent between the two locktime types.

My preference would be to either to try_from = "LockTime" for both relative and absolute, or drop Deserialize/Serialize for Height and Time for both relative and absolute.

from rust-bitcoin.

Kixunil avatar Kixunil commented on June 25, 2024

a little inconsistent between the two locktime types.

Oh, I now realized why. It's a good question which is better.

from rust-bitcoin.

tcharding avatar tcharding commented on June 25, 2024

OK, I suggest serde(try_from = "LockTime") for the absolute types and don't touch others.

I don't understand this statement, I changed the issue description to be only about Height and Time - are you saying you disagree with the change?

IMO the serde stuff for both LockTime structs is correct as is.

from rust-bitcoin.

tcharding avatar tcharding commented on June 25, 2024

Could be considered as part of #2612

from rust-bitcoin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.