diff --git a/lib/customer-deposit-wallet/rest/Cardano/Wallet/Deposit/REST.hs b/lib/customer-deposit-wallet/rest/Cardano/Wallet/Deposit/REST.hs index 6451653207d..d79aa1957f1 100644 --- a/lib/customer-deposit-wallet/rest/Cardano/Wallet/Deposit/REST.hs +++ b/lib/customer-deposit-wallet/rest/Cardano/Wallet/Deposit/REST.hs @@ -54,6 +54,7 @@ module Cardano.Wallet.Deposit.REST -- * Internals , onWalletInstance , resolveCurrentEraTx + , canSign ) where @@ -81,7 +82,8 @@ import Cardano.Wallet.Deposit.IO.Resource , ErrResourceMissing (..) ) import Cardano.Wallet.Deposit.Pure - ( Credentials + ( CanSign + , Credentials , CurrentEraResolvedTx , Customer , ErrCreatePayment @@ -452,6 +454,9 @@ getBIP32PathsForOwnedInputs getBIP32PathsForOwnedInputs = onWalletInstance . WalletIO.getBIP32PathsForOwnedInputs +canSign :: WalletResourceM CanSign +canSign = onWalletInstance WalletIO.canSign + signTx :: Write.Tx -> WalletResourceM (Maybe Write.Tx) diff --git a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO.hs b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO.hs index f8f74ad569b..7248d9fa951 100644 --- a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO.hs +++ b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO.hs @@ -50,6 +50,7 @@ module Cardano.Wallet.Deposit.IO , onWalletState , readWalletState , resolveCurrentEraTx + , canSign ) where import Prelude @@ -74,6 +75,9 @@ import Cardano.Wallet.Deposit.Pure.API.TxHistory , ByTime , LookupTimeFromSlot ) +import Cardano.Wallet.Deposit.Pure.State.Creation + ( CanSign + ) import Cardano.Wallet.Deposit.Read ( Address , TxId @@ -356,6 +360,10 @@ resolveCurrentEraTx tx w = Signing transactions ------------------------------------------------------------------------------} +canSign :: WalletInstance -> IO CanSign +canSign w = do + Wallet.canSign <$> readWalletState w + getBIP32PathsForOwnedInputs :: Write.Tx -> WalletInstance -> IO [BIP32Path] getBIP32PathsForOwnedInputs a w = diff --git a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Pure.hs b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Pure.hs index 5c6c2f2e6a0..67496327280 100644 --- a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Pure.hs +++ b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Pure.hs @@ -52,6 +52,8 @@ module Cardano.Wallet.Deposit.Pure , BIP32Path (..) , DerivationType (..) , ResolvedTx (..) + , canSign + , CanSign (..) , getBIP32PathsForOwnedInputs , signTx , addTxSubmission @@ -65,8 +67,10 @@ import Cardano.Wallet.Address.BIP32 , DerivationType (..) ) import Cardano.Wallet.Deposit.Pure.State.Creation - ( Credentials (..) + ( CanSign (..) + , Credentials (..) , WalletPublicIdentity (..) + , canSign , fromCredentialsAndGenesis ) import Cardano.Wallet.Deposit.Pure.State.Payment diff --git a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Pure/State/Creation.hs b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Pure/State/Creation.hs index e0a79950333..5424693a89c 100644 --- a/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Pure/State/Creation.hs +++ b/lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Pure/State/Creation.hs @@ -1,5 +1,6 @@ {-# LANGUAGE DeriveGeneric #-} {-# OPTIONS_GHC -Wno-orphans #-} +{-# LANGUAGE NamedFieldPuns #-} module Cardano.Wallet.Deposit.Pure.State.Creation ( WalletPublicIdentity (..) , fromCredentialsAndGenesis @@ -10,6 +11,8 @@ module Cardano.Wallet.Deposit.Pure.State.Creation , xprvFromCredentials , ErrDecodingXPub (..) , encodedXPubFromCredentials + , canSign + , CanSign (..) ) where import Prelude hiding @@ -112,6 +115,14 @@ credentialsFromMnemonics mnemonics passphrase = in XPrvCredentials encryptedXPrv (toXPub unencryptedXPrv) +data CanSign = CanSign | CannotSign + deriving (Eq, Show) + +canSign :: WalletState -> CanSign +canSign WalletState{rootXSignKey} = case rootXSignKey of + Nothing -> CannotSign + Just _ -> CanSign + -- | Create 'Credentials' from an extended public key failures to decode data ErrDecodingXPub = ErrFromXPubBase16 | ErrFromXPubDecodeKey deriving (Show, Eq)