New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From trait implementation should not panic #629

bonomat opened this Issue Jan 8, 2019 · 0 comments


None yet
3 participants
Copy link

bonomat commented Jan 8, 2019

Replace the From implementation with a normal function as not all Payload types would allow a conversion to PubkeyHash.


  • clippy does not warn (no allow allowed)


In our current code we only support SegwitAddresses, hence, our code contains the following:

impl From<Address> for PubkeyHash {

impl From<Address> for PubkeyHash {
    fn from(address: Address) -> PubkeyHash {
        match address.payload {
            Payload::WitnessProgram(witness) => PubkeyHash(Hash160::from(witness.program())),
            // TODO: from/into should never fail. Remove this panic by
            // creating a PubkeyAddress type which is guaranteed to
            // have a PubkeyHash inside it.
            _ => panic!("Address {} isn't a pubkey address", address.to_string()),

Clippy detected this as an issue as the From trait should not panic:

@bonomat bonomat referenced this issue Jan 8, 2019


Add a few checks to clippy #625

1 of 1 task complete

@D4nte D4nte added the sprint-backlog label Jan 8, 2019

@D4nte D4nte modified the milestone: Sprint 5 📜🔓 Jan 8, 2019

@luckysori luckysori self-assigned this Jan 9, 2019

@luckysori luckysori referenced this issue Jan 9, 2019


Remove unnecessary From implementation #631

1 of 1 task complete

@wafflebot wafflebot bot added review and removed work-in-progress labels Jan 9, 2019

@mergify mergify bot closed this in #631 Jan 10, 2019

@wafflebot wafflebot bot removed the review label Jan 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment