Skip to content

Commit

Permalink
mkWitness -> mkShelleyWitness
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Jul 6, 2020
1 parent 04fcb56 commit 159f285
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
20 changes: 12 additions & 8 deletions lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Expand Up @@ -28,7 +28,7 @@ module Cardano.Wallet.Shelley.Transaction
, _decodeSignedTx
, _estimateMaxNumberOfInputs
, mkUnsignedTx
, mkWitness
, mkShelleyWitness
, mkTx
, TxPayload (..)
, emptyTxPayload
Expand Down Expand Up @@ -181,7 +181,11 @@ instance TxWitnessTagFor IcarusKey where txWitnessTagFor = TxWitnessByronUTxO
instance TxWitnessTagFor ByronKey where txWitnessTagFor = TxWitnessByronUTxO

mkTx
:: forall (n :: NetworkDiscriminant) k. (Typeable n, WalletKey k)
:: forall (n :: NetworkDiscriminant) k.
( Typeable n
, TxWitnessTagFor k
, WalletKey k
)
=> Proxy n
-> TxPayload TPraosStandardCrypto
-> SlotNo
Expand All @@ -201,12 +205,12 @@ mkTx proxy (TxPayload certs mkExtraWits) timeToLive (rewardAcnt, pwdAcnt) keyFro

addrWits <- fmap Set.fromList $ forM (CS.inputs cs) $ \(_, TxOut addr _) -> do
(k, pwd) <- lookupPrivateKey keyFrom addr
pure $ mkWitness unsigned (getRawKey k, pwd)
pure $ mkShelleyWitness unsigned (getRawKey k, pwd)

let withdrawalsWits
| Map.null withdrawals = Set.empty
| otherwise = Set.singleton $
mkWitness unsigned (getRawKey rewardAcnt, pwdAcnt)
mkShelleyWitness unsigned (getRawKey rewardAcnt, pwdAcnt)

let wits = (SL.WitnessSet (addrWits <> withdrawalsWits) mempty mempty)
<> mkExtraWits unsigned
Expand Down Expand Up @@ -276,7 +280,7 @@ newTransactionLayer proxy _protocolMagic epochLength = TransactionLayer
[ toStakePoolDlgCert accXPub poolId ]

let mkWits unsigned = SL.WitnessSet
(Set.singleton (mkWitness unsigned (getRawKey accXPrv, pwd')))
(Set.singleton (mkShelleyWitness unsigned (getRawKey accXPrv, pwd')))
mempty
mempty

Expand All @@ -299,7 +303,7 @@ newTransactionLayer proxy _protocolMagic epochLength = TransactionLayer
let accXPub = toXPub $ getRawKey accXPrv
let certs = [toStakeKeyDeregCert accXPub]
let mkWits unsigned = SL.WitnessSet
(Set.singleton (mkWitness unsigned (getRawKey accXPrv, pwd')))
(Set.singleton (mkShelleyWitness unsigned (getRawKey accXPrv, pwd')))
mempty
mempty

Expand Down Expand Up @@ -519,11 +523,11 @@ defaultTTL :: EpochLength -> SlotId -> SlotNo
defaultTTL epochLength slot =
(toSlotNo epochLength slot) + 7200

mkWitness
mkShelleyWitness
:: SL.TxBody TPraosStandardCrypto
-> (XPrv, Passphrase "encryption")
-> SL.WitVKey TPraosStandardCrypto 'SL.Witness
mkWitness body (prv, pwd) =
mkShelleyWitness body (prv, pwd) =
SL.WitVKey key sig
where
sig = SignedDSIGN
Expand Down
Expand Up @@ -51,8 +51,8 @@ import Cardano.Wallet.Primitive.Types
import Cardano.Wallet.Shelley.Compatibility
( Shelley, toSealed )
import Cardano.Wallet.Shelley.Transaction
( mkUnsignedTx
, mkWitness
( mkShelleyWitness
, mkUnsignedTx
, newTransactionLayer
, _decodeSignedTx
, _estimateMaxNumberOfInputs
Expand Down Expand Up @@ -173,7 +173,7 @@ prop_decodeSignedTxRoundtrip (DecodeSetup utxo outs slotNo pairs) = do
let inps = Map.toList $ getUTxO utxo
let cs = mempty { CS.inputs = inps, CS.outputs = outs }
let unsigned = mkUnsignedTx slotNo cs mempty []
let addrWits = Set.fromList $ map (mkWitness unsigned) pairs
let addrWits = Set.fromList $ map (mkShelleyWitness unsigned) pairs
let metadata = SL.SNothing
let wits = SL.WitnessSet addrWits mempty mempty
let ledgerTx = SL.Tx unsigned wits metadata
Expand Down

0 comments on commit 159f285

Please sign in to comment.