Skip to content

Commit

Permalink
add tx witness tag
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Jul 6, 2020
1 parent 9a910f3 commit ddd93c6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Expand Up @@ -51,8 +51,14 @@ import Cardano.Wallet.Primitive.AddressDerivation
, Passphrase
, WalletKey (..)
)
import Cardano.Wallet.Primitive.AddressDerivation.Byron
( ByronKey )
import Cardano.Wallet.Primitive.AddressDerivation.Icarus
( IcarusKey )
import Cardano.Wallet.Primitive.AddressDerivation.Shelley
( toChimericAccountRaw )
import Cardano.Wallet.Primitive.AddressDerivation.Shelley
( ShelleyKey )
import Cardano.Wallet.Primitive.CoinSelection
( CoinSelection (..), feeBalance )
import Cardano.Wallet.Primitive.Fee
Expand Down Expand Up @@ -159,6 +165,21 @@ data TxPayload c = TxPayload
emptyTxPayload :: Crypto c => TxPayload c
emptyTxPayload = TxPayload mempty mempty

data TxWitnessTag
= TxWitnessByronUTxO
| TxWitnessShelleyUTxO
deriving (Show, Eq)

-- | Provide a transaction witness for a given private key. The type of witness
-- is different between types of keys and, with backward-compatible support, we
-- need to support many types for one backend target.
class TxWitnessTagFor (k :: Depth -> * -> *) where
txWitnessTagFor :: TxWitnessTag

instance TxWitnessTagFor ShelleyKey where txWitnessTagFor = TxWitnessShelleyUTxO
instance TxWitnessTagFor IcarusKey where txWitnessTagFor = TxWitnessByronUTxO
instance TxWitnessTagFor ByronKey where txWitnessTagFor = TxWitnessByronUTxO

mkTx
:: forall (n :: NetworkDiscriminant) k. (Typeable n, WalletKey k)
=> Proxy n
Expand Down Expand Up @@ -197,6 +218,7 @@ mkTx proxy (TxPayload certs mkExtraWits) timeToLive (rewardAcnt, pwdAcnt) keyFro
newTransactionLayer
:: forall (n :: NetworkDiscriminant) k t.
( t ~ IO Shelley
, TxWitnessTagFor k
, WalletKey k
, Typeable n
)
Expand Down

0 comments on commit ddd93c6

Please sign in to comment.