@@ -28,7 +28,7 @@ import Pos.Core (AddrStakeDistribution (..), StakeholderId,
28
28
addressHash , mkMultiKeyDistr , unsafeGetCoin )
29
29
import Pos.Core.Common (AddrAttributes (.. ), AddrSpendingData (.. ),
30
30
makeAddress )
31
- import Pos.Core.NetworkMagic (NetworkMagic ( .. ) )
31
+ import Pos.Core.NetworkMagic (makeNetworkMagic )
32
32
import Pos.Crypto (PublicKey , emptyPassphrase , encToPublic ,
33
33
fullPublicKeyF , hashHexF , noPassEncrypt , safeCreatePsk ,
34
34
unsafeCheatingHashCoerce , withSafeSigner )
@@ -105,6 +105,7 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
105
105
let name = " addr" in
106
106
needsCoreConfig name >>= \ genesisConfig ->
107
107
needsAuxxMode name >>= \ Dict ->
108
+ let nm = makeNetworkMagic (configProtocolMagic genesisConfig) in
108
109
return CommandProc
109
110
{ cpName = name
110
111
, cpArgumentPrepare = map
@@ -115,9 +116,9 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
115
116
, cpExec = \ (pk', mDistr) -> do
116
117
pk <- toLeft pk'
117
118
addr <- case mDistr of
118
- Nothing -> makePubKeyAddressAuxx fixedNM (configEpochSlots genesisConfig) pk
119
+ Nothing -> makePubKeyAddressAuxx nm (configEpochSlots genesisConfig) pk
119
120
Just distr -> return $
120
- makeAddress (PubKeyASD pk) (AddrAttributes Nothing distr fixedNM )
121
+ makeAddress (PubKeyASD pk) (AddrAttributes Nothing distr nm )
121
122
return $ ValueAddress addr
122
123
, cpHelp = " address for the specified public key. a stake distribution \
123
124
\ can be specified manually (by default it uses the current epoch \
@@ -136,7 +137,8 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
136
137
sk <- evaluateWHNF (sks !! i) -- WHNF is sufficient to force possible errors
137
138
-- from using (!!). I'd use NF but there's no
138
139
-- 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
140
142
return $ ValueAddress addrHD
141
143
, cpHelp = " address of the HD wallet for the specified public key"
142
144
},
@@ -195,13 +197,14 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
195
197
let name = " balance" in
196
198
needsCoreConfig name >>= \ genesisConfig ->
197
199
needsAuxxMode name >>= \ Dict ->
200
+ let nm = makeNetworkMagic (configProtocolMagic genesisConfig) in
198
201
return CommandProc
199
202
{ cpName = name
200
203
, cpArgumentPrepare = identity
201
204
, cpArgumentConsumer = getArg (tyAddress `tyEither` tyPublicKey `tyEither` tyInt) " addr"
202
205
, cpExec = \ addr' -> do
203
206
addr <-
204
- either return (makePubKeyAddressAuxx fixedNM $ configEpochSlots genesisConfig) <=<
207
+ either return (makePubKeyAddressAuxx nm $ configEpochSlots genesisConfig) <=<
205
208
traverse (either return getPublicKeyFromIndex) $ addr'
206
209
balance <- getBalance (configGenesisData genesisConfig) addr
207
210
return $ ValueNumber (fromIntegral . unsafeGetCoin $ balance)
@@ -489,6 +492,7 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
489
492
let name = " listaddr" in
490
493
needsCoreConfig name >>= \ genesisConfig ->
491
494
needsAuxxMode name >>= \ Dict ->
495
+ let nm = makeNetworkMagic (configProtocolMagic genesisConfig) in
492
496
return CommandProc
493
497
{ cpName = name
494
498
, cpArgumentPrepare = identity
@@ -499,8 +503,8 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
499
503
printAction " Available addresses:"
500
504
for_ (zip [0 :: Int .. ] sks ) $ \ (i, sk) -> do
501
505
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
504
508
printAction $
505
509
sformat (" #" % int% " : addr: " % build% " \n " %
506
510
" pk: " % fullPublicKeyF% " \n " %
@@ -509,7 +513,7 @@ createCommandProcs mCoreConfig mTxpConfig hasAuxxMode printAction mDiffusion = r
509
513
i addr pk (addressHash pk) addrHD
510
514
walletMB <- (^. usWallet) <$> (view userSecret >>= readTVarIO)
511
515
whenJust walletMB $ \ wallet -> do
512
- addrHD <- deriveHDAddressAuxx fixedNM epochSlots (_wusRootKey wallet)
516
+ addrHD <- deriveHDAddressAuxx nm epochSlots (_wusRootKey wallet)
513
517
printAction $
514
518
sformat (" Wallet address:\n " %
515
519
" HD addr: " % build)
@@ -566,7 +570,3 @@ getPublicKeyFromIndex i = do
566
570
let sk = sks !! i
567
571
pk = encToPublic sk
568
572
evaluateNF pk
569
-
570
-
571
- fixedNM :: NetworkMagic
572
- fixedNM = NetworkMainOrStage
0 commit comments