Code Duplication    Length = 19-19 lines in 2 locations

src/WalletV2.php 1 location

@@ 134-152 (lines=19) @@
131
     * @return array backupInfo
132
     * @throws BlocktrailSDKException
133
     */
134
    public function passwordChange($newPassword) {
135
        if ($this->locked) {
136
            throw new BlocktrailSDKException("Wallet needs to be unlocked to change password");
137
        }
138
139
        if (!$this->secret) {
140
            throw new BlocktrailSDKException("No secret");
141
        }
142
143
        $encryptedSecret = CryptoJSAES::encrypt($this->secret, $newPassword);
144
145
        $this->sdk->updateWallet($this->identifier, ['encrypted_secret' => $encryptedSecret]);
146
147
        $this->encryptedSecret = $encryptedSecret;
148
149
        return [
150
            'encrypted_secret' => MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($this->encryptedSecret))),
151
        ];
152
    }
153
}
154

src/WalletV3.php 1 location

@@ 145-163 (lines=19) @@
142
     * @return array backupInfo
143
     * @throws BlocktrailSDKException
144
     */
145
    public function passwordChange($newPassword) {
146
        if ($this->locked) {
147
            throw new BlocktrailSDKException("Wallet needs to be unlocked to change password");
148
        }
149
150
        if (!$this->secret) {
151
            throw new BlocktrailSDKException("No secret");
152
        }
153
154
        $encryptedSecret = Encryption::encrypt($this->secret, new Buffer($newPassword));
155
156
        $this->sdk->updateWallet($this->identifier, ['encrypted_secret' => base64_encode($encryptedSecret->getBinary())]);
157
158
        $this->encryptedSecret = $encryptedSecret;
159
160
        return [
161
            'encrypted_secret' => Mnemonic::encode($encryptedSecret),
162
        ];
163
    }
164
}
165