-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #518 from Chia-Network/feature/assert-chia-network
feat: assert that chia network matches cw config file
- Loading branch information
Showing
13 changed files
with
89 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import request from 'request-promise'; | ||
import os from 'os'; | ||
import { getConfig } from '../utils/config-loader'; | ||
|
||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; | ||
|
||
const rpcUrl = getConfig().APP.WALLET_URL; | ||
|
||
const getBaseOptions = () => { | ||
const homeDir = os.homedir(); | ||
const certFile = path.resolve( | ||
`${homeDir}/.chia/mainnet/config/ssl/full_node/private_full_node.crt`, | ||
); | ||
const keyFile = path.resolve( | ||
`${homeDir}/.chia/mainnet/config/ssl/full_node/private_full_node.key`, | ||
); | ||
|
||
const baseOptions = { | ||
method: 'POST', | ||
cert: fs.readFileSync(certFile), | ||
key: fs.readFileSync(keyFile), | ||
}; | ||
|
||
return baseOptions; | ||
}; | ||
|
||
const getActiveNetwork = async () => { | ||
const options = { | ||
url: `${rpcUrl}/get_network_info`, | ||
body: JSON.stringify({}), | ||
}; | ||
|
||
const response = await request(Object.assign({}, getBaseOptions(), options)); | ||
|
||
const data = JSON.parse(response); | ||
|
||
if (data.success) { | ||
return data; | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
export default { | ||
getActiveNetwork, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import writeService from './writeService'; | ||
import syncService from './syncService'; | ||
import wallet from './wallet'; | ||
import fullNode from './fullNode'; | ||
|
||
export default { | ||
...writeService, | ||
...syncService, | ||
...wallet, | ||
...fullNode, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.