2022-03-27 11:00:29 -07:00
|
|
|
/*
|
|
|
|
|
Generate a wallet.json file for use with the DEX.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Public NPM libraries
|
2022-10-09 06:37:12 -07:00
|
|
|
import BchWallet from 'minimal-slp-wallet'
|
2022-10-01 15:58:36 -07:00
|
|
|
|
|
|
|
|
import { promises as fs } from 'fs'
|
2022-03-27 11:00:29 -07:00
|
|
|
|
|
|
|
|
async function createWallet () {
|
|
|
|
|
try {
|
|
|
|
|
// Configure the minimal-slp-wallet library to use the JSON RPC over IPFS.
|
|
|
|
|
const advancedConfig = {
|
|
|
|
|
interface: 'consumer-api',
|
|
|
|
|
noUpdate: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wait for the wallet to be created.
|
2022-10-09 06:39:42 -07:00
|
|
|
const bchWallet = new BchWallet(undefined, advancedConfig)
|
|
|
|
|
await bchWallet.walletInfoPromise
|
|
|
|
|
const walletData = bchWallet.walletInfo
|
2022-03-27 11:00:29 -07:00
|
|
|
walletData.nextAddress = 1
|
|
|
|
|
|
|
|
|
|
// Save the wallet file to disk.
|
|
|
|
|
await fs.writeFile('wallet.json', JSON.stringify(walletData, null, 2))
|
|
|
|
|
|
|
|
|
|
console.log('Generated wallet.json. Copy this file to the docker/bch-dex folder to be used inside the Docker container.')
|
|
|
|
|
console.log(`${JSON.stringify(walletData, null, 2)}`)
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('Error: ', err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
createWallet()
|