Skip to content

Hash newtypes that only hash one type of data should have a From impl #1909

@stevenroose

Description

@stevenroose

For example, all these:

        /// A hash of a public key.
        pub struct PubkeyHash(hash160::Hash);
        /// A hash of Bitcoin Script bytecode.
        pub struct ScriptHash(hash160::Hash);
        /// SegWit version of a public key hash.
        pub struct WPubkeyHash(hash160::Hash);
        /// SegWit version of a Bitcoin Script bytecode hash.
        pub struct WScriptHash(sha256::Hash);

should have implementations using From for the types they are supposed to has. So you can use pk.into() to provide a WPubkeyHash, f.e..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions