Skip to content

Commit

Permalink
Allow to inspect reward accounts wrt IntersectMBO#46
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Aug 17, 2020
1 parent 2e2636a commit 17dfc99
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions command-line/test/Command/Address/InspectSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ spec = describeCmd [ "address", "inspect" ] $ do
specInspectAddress ["Shelley", "by pointer"]
"addr1gw2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer5ph3wczvf2x4v58t"

-- reward account: keyhash28
specInspectAddress ["Shelley", "by value"]
"addr1upshvetj09hxjcm9v9jxgunjv4ehxmr0d3hkcmmvdakx7mq726p32"

-- reward account: scripthash32
specInspectAddress ["Shelley", "by value"]
"addr17pshvetj09hxjcm9v9jxgunjv4ehxmr0d3hkcmmvdakx7mrgdp5xsnxe5e6"

specInspectMalformed
"💩"

Expand Down
17 changes: 17 additions & 0 deletions core/lib/Cardano/Address/Style/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module Cardano.Address.Style.Shelley
-- Internals
, minSeedLengthBytes
, pubkeyHashSize
, scriptHashSize
) where

import Prelude
Expand Down Expand Up @@ -507,6 +508,22 @@ inspectShelleyAddress addr
-- 1000: byron address
0b10000000 ->
inspectByronAddress addr <|> inspectIcarusAddress addr
-- 1110: reward account: keyhash28
0b11100000 | BS.length rest == pubkeyHashSize ->
Just $ Json.object
[ "address_style" .= Json.String "Shelley"
, "stake_reference" .= Json.String "by value"
, "stake_key_hash" .= base16 (BS.take pubkeyHashSize rest)
, "network_tag" .= network
]
-- 1111: reward account: scripthash32
0b11110000 | BS.length rest == scriptHashSize ->
Just $ Json.object
[ "address_style" .= Json.String "Shelley"
, "stake_reference" .= Json.String "by value"
, "script_hash" .= base16 (BS.take scriptHashSize rest)
, "network_tag" .= network
]
_ ->
Nothing
where
Expand Down

0 comments on commit 17dfc99

Please sign in to comment.