fix(docker): Removing memory limit

This commit is contained in:
Chris Troutner
2024-04-03 09:55:48 -07:00
6 changed files with 26 additions and 24 deletions
+2
View File
@@ -72,3 +72,5 @@ data/
run-dev.sh run-dev.sh
!README.md !README.md
wallet.json
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "ipfs-bch-wallet-service", "name": "ipfs-bch-wallet-service",
"version": "3.0.0", "version": "3.1.0",
"description": "IPFS and REST service providing blockchain access needed by a wallet. ", "description": "IPFS and REST service providing blockchain access needed by a wallet. ",
"main": "index.js", "main": "index.js",
"type": "module", "type": "module",
+1 -1
View File
@@ -22,7 +22,7 @@ services:
options: options:
max-size: '10m' max-size: '10m'
max-file: '10' max-file: '10'
mem_limit: 1000mb #mem_limit: 1500mb
links: links:
- mongo-bch-service - mongo-bch-service
ports: ports:
+15 -5
View File
@@ -49,7 +49,7 @@ class Wallet {
advancedConfig.restURL = this.config.apiServer advancedConfig.restURL = this.config.apiServer
} }
console.log('advancedConfig setting when creating wallet: ', advancedConfig) // console.log('advancedConfig setting when creating wallet: ', advancedConfig)
// Instantiate minimal-slp-wallet. // Instantiate minimal-slp-wallet.
if (walletData.mnemonic) { if (walletData.mnemonic) {
@@ -96,8 +96,8 @@ class Wallet {
// Try to open the wallet.json file. // Try to open the wallet.json file.
try { try {
// console.log('this.config.walletFile: ', this.config.walletFile)
walletData = await this.jsonFiles.readJSON(this.config.walletFile) walletData = await this.jsonFiles.readJSON(this.config.walletFile)
walletData = walletData.wallet
} catch (err) { } catch (err) {
// Create a new wallet file if one does not already exist. // Create a new wallet file if one does not already exist.
console.log('Wallet file not found. Creating new wallet.json file.') console.log('Wallet file not found. Creating new wallet.json file.')
@@ -112,7 +112,7 @@ class Wallet {
walletData.nextAddress = 1 walletData.nextAddress = 1
// Write the wallet data to the JSON file. // Write the wallet data to the JSON file.
await this.jsonFiles.writeJSON(walletData, this.config.walletFile) await this.jsonFiles.writeJSON({ wallet: walletData }, this.config.walletFile)
} }
// console.log('walletData: ', walletData) // console.log('walletData: ', walletData)
@@ -149,13 +149,18 @@ class Wallet {
async incrementNextAddress () { async incrementNextAddress () {
try { try {
const walletData = await this.openWallet() const walletData = await this.openWallet()
// console.log('original walletdata: ', walletData)
await this.instanceWalletWithoutInitialization(walletData)
walletData.nextAddress++ walletData.nextAddress++
// console.log('walletData finish: ', walletData) // console.log('walletData finish: ', walletData)
await this.jsonFiles.writeJSON(walletData, this.WALLET_FILE)
await this.jsonFiles.writeJSON({ wallet: walletData }, this.config.walletFile)
// Update the working instance of the wallet. // Update the working instance of the wallet.
this.bchWallet.walletInfo.nextAddress++ this.bchWallet.walletInfo.nextAddress++
// console.log('this.bchWallet.walletInfo: ', this.bchWallet.walletInfo) // console.log('this.bchWallet.walletInfo: ', this.bchWallet.walletInfo)
return walletData.nextAddress return walletData.nextAddress
} catch (err) { } catch (err) {
console.error('Error in incrementNextAddress()') console.error('Error in incrementNextAddress()')
@@ -173,16 +178,21 @@ class Wallet {
// Increment the HD index and generate a new key pair. // Increment the HD index and generate a new key pair.
hdIndex = await this.incrementNextAddress() hdIndex = await this.incrementNextAddress()
} }
const mnemonic = this.bchWallet.walletInfo.mnemonic const mnemonic = this.bchWallet.walletInfo.mnemonic
// root seed buffer // root seed buffer
const rootSeed = await this.bchWallet.bchjs.Mnemonic.toSeed(mnemonic) const rootSeed = await this.bchWallet.bchjs.Mnemonic.toSeed(mnemonic)
const masterHDNode = this.bchWallet.bchjs.HDNode.fromSeed(rootSeed) const masterHDNode = this.bchWallet.bchjs.HDNode.fromSeed(rootSeed)
// HDNode of BIP44 account // HDNode of BIP44 account
// const account = this.bchWallet.bchjs.HDNode.derivePath(masterHDNode, "m/44'/245'/0'") // const account = this.bchWallet.bchjs.HDNode.derivePath(masterHDNode, "m/44'/245'/0'")
const childNode = masterHDNode.derivePath(`m/44'/245'/0'/0/${hdIndex}`) const childNode = masterHDNode.derivePath(`m/44'/245'/0'/0/${hdIndex}`)
const cashAddress = this.bchWallet.bchjs.HDNode.toCashAddress(childNode) const cashAddress = this.bchWallet.bchjs.HDNode.toCashAddress(childNode)
console.log('Generating a new key pair for cashAddress: ', cashAddress) console.log('Generating a new key pair for cashAddress: ', cashAddress)
const wif = this.bchWallet.bchjs.HDNode.toWIF(childNode) const wif = this.bchWallet.bchjs.HDNode.toWIF(childNode)
const outObj = { const outObj = {
cashAddress, cashAddress,
wif, wif,
+7 -6
View File
@@ -18,7 +18,7 @@ import * as url from 'url'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
// Global constants // Global constants
const testWalletFile = `${__dirname.toString()}/test-wallet.json` const testWalletFile = `${__dirname.toString()}test-wallet.json`
describe('#wallet', () => { describe('#wallet', () => {
let uut let uut
@@ -59,7 +59,7 @@ describe('#wallet', () => {
// Mock dependencies // Mock dependencies
uut.BchWallet = MockBchWallet uut.BchWallet = MockBchWallet
// Ensure we open the test file, not the production wallet file. // Ensure we open the test file, not the production wallet file.
uut.walletFile = testWalletFile uut.config.walletFile = testWalletFile
const result = await uut.openWallet() const result = await uut.openWallet()
// console.log('result: ', result) // console.log('result: ', result)
assert.property(result, 'mnemonic') assert.property(result, 'mnemonic')
@@ -75,7 +75,7 @@ describe('#wallet', () => {
it('should open existing wallet file', async () => { it('should open existing wallet file', async () => {
// This test case uses the file created in the previous test case. // This test case uses the file created in the previous test case.
// Ensure we open the test file, not the production wallet file. // Ensure we open the test file, not the production wallet file.
uut.walletFile = testWalletFile uut.config.walletFile = testWalletFile
const result = await uut.openWallet() const result = await uut.openWallet()
// console.log('result: ', result) // console.log('result: ', result)
assert.property(result, 'mnemonic') assert.property(result, 'mnemonic')
@@ -274,11 +274,12 @@ describe('#wallet', () => {
describe('#getKeyPair', () => { describe('#getKeyPair', () => {
it('should return an object with a key pair', async () => { it('should return an object with a key pair', async () => {
// Ensure we open the test file, not the production wallet file. // Ensure we open the test file, not the production wallet file.
uut.WALLET_FILE = testWalletFile // uut.WALLET_FILE = testWalletFile
// mock instance of minimal-slp-wallet uut.config.walletFile = testWalletFile
uut.bchWallet = new MockBchWallet()
const result = await uut.getKeyPair() const result = await uut.getKeyPair()
// console.log('result: ', result) // console.log('result: ', result)
assert.property(result, 'cashAddress') assert.property(result, 'cashAddress')
assert.property(result, 'wif') assert.property(result, 'wif')
assert.property(result, 'hdIndex') assert.property(result, 'hdIndex')
-11
View File
@@ -1,11 +0,0 @@
{
"mnemonic": "course abstract aerobic deer try switch turtle diet fence affair butter top",
"privateKey": "L5D2UAam8tvo3uii5kpgaGyjvVMimdrXu8nWGQSQjuuAix6ji1YQ",
"publicKey": "0379433ffc401483ade310469953c1cba77c71af904f07c15bde330d7198b4d6dc",
"cashAddress": "bitcoincash:qzl0d3gcqeypv4cy7gh8rgdszxa9vvm2acv7fqtd00",
"address": "bitcoincash:qzl0d3gcqeypv4cy7gh8rgdszxa9vvm2acv7fqtd00",
"slpAddress": "simpleledger:qzl0d3gcqeypv4cy7gh8rgdszxa9vvm2acq9zm7d33",
"legacyAddress": "1JQj1KcQL7GPKzc1D2PvdUSgw3MbDtrHzi",
"hdPath": "m/44'/245'/0'/0/0",
"nextAddress": 1
}