diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index fff6d659c78..179e76cd61a 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -3670,7 +3670,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do (_, policyKeyHashPayload) <- unsafeRequest @ApiPolicyKey ctx policyWithHash Empty - let postPolicyKey = Link.postPolicyKey @'Shelley wa + let postPolicyKey = Link.postPolicyKey @'Shelley wa (Just True) let passwdPayload = Json [json| { "passphrase": #{fixturePassphrase} } |] diff --git a/lib/core/src/Cardano/Wallet/Api.hs b/lib/core/src/Cardano/Wallet/Api.hs index 5c2eec25d5b..f6b39c56960 100644 --- a/lib/core/src/Cardano/Wallet/Api.hs +++ b/lib/core/src/Cardano/Wallet/Api.hs @@ -444,6 +444,7 @@ type GetPolicyKey = "wallets" type PostPolicyKey = "wallets" :> Capture "walletId" (ApiT WalletId) :> "policy-key" + :> QueryParam "hash" Bool :> ReqBody '[JSON] ApiPostPolicyKeyData :> PostAccepted '[JSON] ApiPolicyKey diff --git a/lib/core/src/Cardano/Wallet/Api/Link.hs b/lib/core/src/Cardano/Wallet/Api/Link.hs index 40a012519c0..5858bbd7bd4 100644 --- a/lib/core/src/Cardano/Wallet/Api/Link.hs +++ b/lib/core/src/Cardano/Wallet/Api/Link.hs @@ -419,9 +419,10 @@ postPolicyKey , HasType (ApiT WalletId) w ) => w + -> Maybe Bool -> (Method, Text) -postPolicyKey w = discriminate @style - (endpoint @Api.PostPolicyKey (wid &)) +postPolicyKey w hashed = discriminate @style + (endpoint @Api.PostPolicyKey (\mk -> mk wid hashed)) (notSupported "Byron") (notSupported "Shared") where diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index 2d627384000..aedad74d4a0 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -242,7 +242,6 @@ import Cardano.Wallet.Api.Types , ApiNetworkClock (..) , ApiNetworkInformation , ApiNetworkParameters (..) - , ApiPostPolicyKeyData (..) , ApiNullStakeKey (..) , ApiOurStakeKey (..) , ApiPaymentDestination (..) @@ -251,6 +250,7 @@ import Cardano.Wallet.Api.Types , ApiPolicyScript (..) , ApiPoolId (..) , ApiPostAccountKeyDataWithPurpose (..) + , ApiPostPolicyKeyData (..) , ApiPostRandomAddressData (..) , ApiPutAddressesData (..) , ApiRedeemer (..) @@ -3370,15 +3370,15 @@ postPolicyKey ) => ctx -> ApiT WalletId + -> Maybe Bool -> ApiPostPolicyKeyData -> Handler ApiPolicyKey -postPolicyKey ctx (ApiT wid) apiPassphrase = +postPolicyKey ctx (ApiT wid) hashed apiPassphrase = withWorkerCtx @_ @s @ShelleyKey ctx wid liftE liftE $ \wrk -> do k <- liftHandler $ W.writePolicyPublicKey @_ @s @n wrk wid pwd pure $ uncurry ApiPolicyKey (computeKeyPayload hashed (getRawKey k)) where pwd = getApiT (apiPassphrase ^. #passphrase) - hashed = Just True {------------------------------------------------------------------------------- Helpers diff --git a/lib/core/src/Cardano/Wallet/Api/Types.hs b/lib/core/src/Cardano/Wallet/Api/Types.hs index f47bd231a23..c53badd573c 100644 --- a/lib/core/src/Cardano/Wallet/Api/Types.hs +++ b/lib/core/src/Cardano/Wallet/Api/Types.hs @@ -1227,8 +1227,8 @@ data ApiPolicyScript = ApiPolicyScript deriving (Eq, Generic, Show) deriving anyclass NFData -data ApiPostPolicyKeyData = ApiPostPolicyKeyData - { passphrase :: !(ApiT (Passphrase "raw")) +newtype ApiPostPolicyKeyData = ApiPostPolicyKeyData + { passphrase :: (ApiT (Passphrase "raw")) } deriving (Eq, Generic, Show) deriving anyclass NFData diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index 78a5a29a5f3..f7b5249614d 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -6047,13 +6047,20 @@ paths: /wallets/{walletId}/policy-key: post: operationId: postPolicyKey - tags: ["Transactions"] - summary: Create + tags: ["Keys"] + summary: Create Policy Key description: |
status: stable
- Create policy key for the wallet. Used for public account key derived - wallets or already instantiated mnemonic wallets to set policy public key + Create policy key for the wallet. + + In order to be able to mint/burn assets with `POST Construct` endpoint there needs to be + a policy key set for the wallet. Invoking this endpoint would be required for all wallets instantiated + before introducing mint/burn feature prior to making a mint/burn transaction from them. + + To get a hash of the policy key instead of the policy key, + use query parameter `hash=true`. + parameters: - *parametersWalletId requestBody: