mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-22 01:02:00 -07:00
33 lines
980 B
JavaScript
33 lines
980 B
JavaScript
/*
|
|
Generate a wallet.json file for use with the DEX.
|
|
*/
|
|
|
|
// Public NPM libraries
|
|
const BchWallet = require('minimal-slp-wallet/index')
|
|
const fs = require('fs').promises
|
|
|
|
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.
|
|
this.bchWallet = new BchWallet(undefined, advancedConfig)
|
|
await this.bchWallet.walletInfoPromise
|
|
const walletData = this.bchWallet.walletInfo
|
|
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()
|