@@ -28,7 +28,7 @@ import Pos.Core (AddrStakeDistribution (..), StakeholderId,
2828 addressHash , mkMultiKeyDistr , unsafeGetCoin )
2929import Pos.Core.Common (AddrAttributes (.. ), AddrSpendingData (.. ),
3030 makeAddress )
31- import Pos.Core.NetworkMagic (NetworkMagic ( .. ) )
31+ import Pos.Core.NetworkMagic (makeNetworkMagic )
3232import Pos.Crypto (PublicKey , emptyPassphrase , encToPublic ,
3333 fullPublicKeyF , hashHexF , noPassEncrypt , safeCreatePsk ,
3434 unsafeCheatingHashCoerce , withSafeSigner )
@@ -105,6 +105,7 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
105105 let name = " addr" in
106106 needsCoreConfig name >>= \ genesisConfig ->
107107 needsAuxxMode name >>= \ Dict ->
108+ let nm = makeNetworkMagic (configProtocolMagic genesisConfig) in
108109 return CommandProc
109110 { cpName = name
110111 , cpArgumentPrepare = map
@@ -115,9 +116,9 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
115116 , cpExec = \ (pk', mDistr) -> do
116117 pk <- toLeft pk'
117118 addr <- case mDistr of
118- Nothing -> makePubKeyAddressAuxx fixedNM (configEpochSlots genesisConfig) pk
119+ Nothing -> makePubKeyAddressAuxx nm (configEpochSlots genesisConfig) pk
119120 Just distr -> return $
120- makeAddress (PubKeyASD pk) (AddrAttributes Nothing distr fixedNM )
121+ makeAddress (PubKeyASD pk) (AddrAttributes Nothing distr nm )
121122 return $ ValueAddress addr
122123 , cpHelp = " address for the specified public key. a stake distribution \
123124 \ can be specified manually (by default it uses the current epoch \
@@ -136,7 +137,8 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
136137 sk <- evaluateWHNF (sks !! i) -- WHNF is sufficient to force possible errors
137138 -- from using (!!). I'd use NF but there's no
138139 -- NFData instance for secret keys.
139- addrHD <- deriveHDAddressAuxx fixedNM (configEpochSlots genesisConfig) sk
140+ let nm = makeNetworkMagic (configProtocolMagic genesisConfig)
141+ addrHD <- deriveHDAddressAuxx nm (configEpochSlots genesisConfig) sk
140142 return $ ValueAddress addrHD
141143 , cpHelp = " address of the HD wallet for the specified public key"
142144 },
@@ -195,13 +197,14 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
195197 let name = " balance" in
196198 needsCoreConfig name >>= \ genesisConfig ->
197199 needsAuxxMode name >>= \ Dict ->
200+ let nm = makeNetworkMagic (configProtocolMagic genesisConfig) in
198201 return CommandProc
199202 { cpName = name
200203 , cpArgumentPrepare = identity
201204 , cpArgumentConsumer = getArg (tyAddress `tyEither` tyPublicKey `tyEither` tyInt) " addr"
202205 , cpExec = \ addr' -> do
203206 addr <-
204- either return (makePubKeyAddressAuxx fixedNM $ configEpochSlots genesisConfig) <=<
207+ either return (makePubKeyAddressAuxx nm $ configEpochSlots genesisConfig) <=<
205208 traverse (either return getPublicKeyFromIndex) $ addr'
206209 balance <- getBalance (configGenesisData genesisConfig) addr
207210 return $ ValueNumber (fromIntegral . unsafeGetCoin $ balance)
@@ -489,6 +492,7 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
489492 let name = " listaddr" in
490493 needsCoreConfig name >>= \ genesisConfig ->
491494 needsAuxxMode name >>= \ Dict ->
495+ let nm = makeNetworkMagic (configProtocolMagic genesisConfig) in
492496 return CommandProc
493497 { cpName = name
494498 , cpArgumentPrepare = identity
@@ -499,8 +503,8 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
499503 printAction " Available addresses:"
500504 for_ (zip [0 :: Int .. ] sks ) $ \ (i, sk) -> do
501505 let pk = encToPublic sk
502- addr <- makePubKeyAddressAuxx fixedNM epochSlots pk
503- addrHD <- deriveHDAddressAuxx fixedNM epochSlots sk
506+ addr <- makePubKeyAddressAuxx nm epochSlots pk
507+ addrHD <- deriveHDAddressAuxx nm epochSlots sk
504508 printAction $
505509 sformat (" #" % int% " : addr: " % build% " \n " %
506510 " pk: " % fullPublicKeyF% " \n " %
@@ -509,7 +513,7 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
509513 i addr pk (addressHash pk) addrHD
510514 walletMB <- (^. usWallet) <$> (view userSecret >>= readTVarIO)
511515 whenJust walletMB $ \ wallet -> do
512- addrHD <- deriveHDAddressAuxx fixedNM epochSlots (_wusRootKey wallet)
516+ addrHD <- deriveHDAddressAuxx nm epochSlots (_wusRootKey wallet)
513517 printAction $
514518 sformat (" Wallet address:\n " %
515519 " HD addr: " % build)
@@ -566,7 +570,3 @@ getPublicKeyFromIndex i = do
566570 let sk = sks !! i
567571 pk = encToPublic sk
568572 evaluateNF pk
569-
570-
571- fixedNM :: NetworkMagic
572- fixedNM = NetworkMainOrStage
0 commit comments