Comments (12)
We have that usecase covered already, one can do:
struct GetTransactionInfo {
...
#[serde(with = "bitcoin::amount::serde::as_sat")]
pub fee: Amount,
...
}
I haven't thought it through for other unit types but we want to provide some way to be able to derive them too.
from rust-bitcoin.
I don't understand. Right now we have e.g. the amount::serde
module which lets them choose between sats and BTC. We should definitely keep that.
For the locktime types things are less clear (should we have serde on Height
/Time
or just on LockTime
).
from rust-bitcoin.
You were too quick. I've updated the issue
from rust-bitcoin.
Having an implementation is definitely valuable for auto-derive users. I can imagine something like
struct GetTransactionInfo {
pub reciever: Address,
pub fee: Amount,
pub sent_amount: Amount,
}
requiring an auto-derive.
from rust-bitcoin.
I just had a play and if we remove the serde imples it is annoying to not be able to do
#[derive(Debug, Serialize, Deserialize)]
struct Foo {
height: absolute::Height,
time: absolute::Time,
}
And it is surprising that
#[derive(Debug, Serialize, Deserialize)]
struct Bar {
lt: absolute::LockTime
}
is fine but using Height
and Time
is not (if we remove the impls).
Do we gain anything by not allowing Foo
to be defined like that? Seems to me like we will just be annoying users.
from rust-bitcoin.
Amount is probably the most important one. If we have that covered, I am okay dropping the serde requirement from units. Users dealing with Height and Time are advanced users that can do their own serde.
from rust-bitcoin.
Agreed. I do not think we should change Amount
. We spent forever implementing it, many people are using it (including me) and we have covered the multiple natural ways to implement it.
Meanwhile Height
and Time
have no natural ways to implement serde because they basically just exist to compensate for Rusts' lack of privacy on enum internals, and their serde implementations are confusingly inconsistent with that for LockTime
.
I'm fine keeping them, but they are a weird bit of API surface that if we commit to, we're stuck with forever.
You were too quick. I've updated the issue
It still seems to imply that we should get rid of serde
entirely in the units
crate.
from rust-bitcoin.
But It is possible that some users can just use Height
struct for simply representing the height of a block -> so will require its serde implementation.
from rust-bitcoin.
It still seems to imply that we should get rid of serde entirely in the units crate.
I re-edited the description, third time lucky.
from rust-bitcoin.
But It is possible that some users can just use
Height
struct for simply representing the height of a block -> so will require its serde implementation.
I agree, absolute::Height
seems totally likely to be put into a struct that wants to derive serde
traits.
from rust-bitcoin.
Closing, this does not seem to be going anywhere. We can re-visit this at a later time if needed.
from rust-bitcoin.
Note at this stage we do have serde
traits implemented and the bug that started this conversation is fixed by: #2582
from rust-bitcoin.
Related Issues (20)
- Do We require BIP324 implementation? HOT 1
- bip32: Understand and fix the `m/` problem HOT 4
- TX rejected: failed to validate input - signature not empty on failed checksig HOT 20
- Bug on witness verification (witness flag but empty witnesses) HOT 8
- Should document how to create a custom `Params` HOT 4
- Unpin `kani` once fix is released by them
- Make stuff in `Params` const
- `LockTime::from_height` could use a clarification for the meaning of height HOT 11
- Preparing taproot script spend to be signed HOT 6
- What are the `*_encode_signing_data_to` functions public for? HOT 4
- Schnorr - combine 2 signature HOT 5
- Actually validate taproot spends HOT 4
- `master` still has version set to `0.32.0-rc1` HOT 4
- `Script` should have accessors for hashes embedded in scriptpubkeys
- How to recover address from txn witness data? HOT 7
- ci: Consider shellcheck for bash/shell scripts linting HOT 5
- Support for testnet4 HOT 7
- Implement `ZERO_NORMAL` and `ZERO_HARDENED` constants (and variants for `ONE`) for BIP 32
- Implement constants for `PsbtSighashType` HOT 5
- `derive_xpriv` should not return a `Result` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-bitcoin.