Comments (4)
Agree with the prioritization and high-level observations. Can you say more about:
- What
AsRawTransaction
would do? (Maybe this is not the issue for it.) - What features we'd want from
Hash
trait ideally. Somewhere I recall we came to a rough consensus that our 1.0 MSRV would be 1.6x or thereabouts.
from rust-bitcoin.
What
AsRawTransaction
would do?
Effectively a copy of AsTransaction
from #2347 with only modification being use of raw types (integers, byte slices) to resolve the dependency loop. It'd be considered an implementation detail and only stay there as long as other crates are unstable. Once stable, the implementation would change and the trait would get removed.
Basically what we want:
// in internals
pub struct TransactionEncoder<'a, T>(TransactionEncoderState<'a, T>);
impl<'a, T: AsRawTransaction> TransactionEncoder<'a, T> {
pub fn new(transaction: &'a T) -> Self { /* ... */ }
}
impl<'a, T: AsRawTransaction> Encoder for TransactionEncoder<'a, T> { /* ... */ }
// in primitives:
pub fn txid(&self) -> Txid {
struct Wrapper<'a>(&'a Transaction);
impl<'a> AsRawTransaction for Wrapper<'a> { /* ...*/ }
let mut encoder = TransactionEncoder::new(&Wrapper(self));
let mut engine = sha256::engine();
while !encoder.encoded_chunk().is_empty() {
engine.input(encoder.encoded_chunk());
if !encoder.next() { break }
}
Txid(engine.finalize())
}
- What features we'd want from
Hash
trait ideally. Somewhere I recall we came to a rough consensus that our 1.0 MSRV would be 1.6x or thereabouts.
Allow writing fn to_byte_array(self) -> [u8; Self::LEN]
, though IIRC it may require the feature that is not even in stable and is somewhat broken in nightly too. (I might be confusing this with something else.) But from what I can observe so far: both GAT and weak dependencies will be a must when fully stable, so 1.65 IIRC. But the leaf crates don't need this. Actually that's what I wanted to mention above and forgot.
from rust-bitcoin.
I think we should try the to_byte_array
thing. It doesn't look like it needs GATs, just regular ATs, which have been around for a long time.
The AsRawTransaction
thing makes sense, thanks. Though I wonder if we want to make this a permanent part of the API (and have a corresponding Raw
type for some other types, notably Block
and BlockHeader
). It seems like it may be useful in some obscure low-level usecases.
OTOH it would be easy to add (or expose) post-1.0 so this isn't a decision we need to make now.
from rust-bitcoin.
I don't see when it'd be useful. Script
is already freely convertible, so only Witness
is a bit obscure type. We could do something about that too. I was already thinking of having unsized Witness
for zero-copy deserialization however it'd loose the index which is non issue when serializing but can be a problem when accessing.
from rust-bitcoin.
Related Issues (20)
- What's the point of `Denomination::MilliSatoshi`? HOT 23
- `SegwitV0Sighash` is missing an `into_secp256k1_message` HOT 3
- Should be able to directly sign with sighashes HOT 7
- `Amount` should support milisats HOT 1
- Links to crate code inside `hash_newtype!` don't work HOT 3
- Mutation testing improvements (get rid of mutagen) HOT 9
- Fix bug in `pow.rs` HOT 3
- Consider Enabling explicitly formatting a derivation path with the `m/` prefix HOT 6
- Rustdoc: private doc tests lint HOT 2
- Add a script for common tasks updating lock files HOT 1
- Pin `cargo public-api` and other tools HOT 2
- Change `PushBytes::read_scriptint(x)` to `x.read_scriptint()`
- Displaying hex HOT 5
- No way to access `UnprefixedHexError` HOT 3
- Remove usage of wildcard imports
- Cannot get DerivationPath serialised from root anymore HOT 12
- psbt: it should fail when there is an extra data HOT 3
- Epic: Re-write the `hashes` API HOT 4
- Epic: Make it possible for `rust-bitcoin` to depend on `rust-miniscript` HOT 1
- `psbt::raw::Key`'s `type_value` field should be serialized as `VarInt` HOT 12
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.