Skip to content

Commit

Permalink
Don't store the initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
peachbits committed Oct 4, 2024
1 parent 9982000 commit 6aa135c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- fixed: (Zcash/Piratechain) Don't save sensitive initializer object to engine

## 4.26.0 (2024-10-03)

- changed: Add redundancy to Cardano queries
Expand Down
23 changes: 11 additions & 12 deletions src/piratechain/PiratechainEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class PiratechainEngine extends CurrencyEngine<
synchronizerStatus!: StatusEvent['name']
availableZatoshi!: string
initialNumBlocksToDownload!: number
initializer!: InitializerConfig
birthdayHeight: number
progressRatio!: number
queryMutex: boolean
makeSynchronizer: (
Expand All @@ -67,6 +67,7 @@ export class PiratechainEngine extends CurrencyEngine<
const { networkInfo } = env
this.pluginId = this.currencyInfo.pluginId
this.networkInfo = networkInfo
this.birthdayHeight = 0
this.makeSynchronizer = makeSynchronizer
this.queryMutex = false

Expand All @@ -79,13 +80,11 @@ export class PiratechainEngine extends CurrencyEngine<
}

initData(): void {
const { birthdayHeight } = this.initializer

// walletLocalData
if (this.otherData.blockRange.first === 0) {
this.otherData.blockRange = {
first: birthdayHeight,
last: birthdayHeight
first: this.birthdayHeight,
last: this.birthdayHeight
}
}

Expand Down Expand Up @@ -293,15 +292,15 @@ export class PiratechainEngine extends CurrencyEngine<
)(opts?.privateKeys)

const { rpcNode } = this.networkInfo
this.initializer = {
mnemonicSeed: piratechainPrivateKeys.mnemonic,
birthdayHeight: piratechainPrivateKeys.birthdayHeight,
alias: base16.stringify(base64.parse(this.walletId)),
...rpcNode
}
this.birthdayHeight = piratechainPrivateKeys.birthdayHeight

try {
this.synchronizer = await this.makeSynchronizer(this.initializer)
this.synchronizer = await this.makeSynchronizer({
mnemonicSeed: piratechainPrivateKeys.mnemonic,
birthdayHeight: piratechainPrivateKeys.birthdayHeight,
alias: base16.stringify(base64.parse(this.walletId)),
...rpcNode
})
} catch (e) {
// The synchronizer cannot start if it isn't present.
if (
Expand Down
8 changes: 3 additions & 5 deletions src/zcash/ZcashEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class ZcashEngine extends CurrencyEngine<
synchronizerStatus!: StatusEvent['name']
availableZatoshi!: string
balances: ZcashBalances
initializer!: InitializerConfig
progressRatio!: {
seenFirstUpdate: boolean
percent: number
Expand Down Expand Up @@ -340,15 +339,14 @@ export class ZcashEngine extends CurrencyEngine<

if (this.synchronizer == null) {
const { rpcNode } = this.networkInfo
this.initializer = {

this.synchronizer = await this.makeSynchronizer({
mnemonicSeed: zcashPrivateKeys.mnemonic,
birthdayHeight: zcashPrivateKeys.birthdayHeight,
alias: base16.stringify(base64.parse(this.walletId)),
newWallet: !this.otherData.isSdkInitializedOnDisk,
...rpcNode
}

this.synchronizer = await this.makeSynchronizer(this.initializer)
})
this.initData()
this.initSubscriptions()
}
Expand Down

0 comments on commit 6aa135c

Please sign in to comment.