Completed
Branch master (56c2f5)
by
unknown
07:05
created

WalletV1Sweeper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 7
1
<?php
2
3
namespace Blocktrail\SDK;
4
5
use BitWasp\Bitcoin\Mnemonic\Bip39\Bip39SeedGenerator;
6
7
class WalletV1Sweeper extends WalletSweeper {
8
9
    /**
10
     * @param string              $primaryMnemonic
11
     * @param string              $primaryPassphrase
12
     * @param array               $backupMnemonic
13
     * @param array               $blocktrailPublicKeys
14
     * @param UnspentOutputFinder $unspentOutputFinder
15
     * @param string              $network
16
     * @param bool                $testnet
17
     */
18
    public function __construct($primaryMnemonic, $primaryPassphrase, $backupMnemonic, array $blocktrailPublicKeys, UnspentOutputFinder $unspentOutputFinder, $network = 'btc', $testnet = false) {
19
        // cleanup copy paste errors from mnemonics
20
        $primaryMnemonic = str_replace("  ", " ", str_replace("\r\n", " ", str_replace("\n", " ", trim($primaryMnemonic))));
21
        $backupMnemonic = str_replace("  ", " ", str_replace("\r\n", " ", str_replace("\n", " ", trim($backupMnemonic))));
22
23
        // convert the primary and backup mnemonics to seeds (using BIP39), then create private keys (using BIP32)
24
        $primarySeed = (new Bip39SeedGenerator())->getSeed($primaryMnemonic, $primaryPassphrase);
25
        $backupSeed = (new Bip39SeedGenerator())->getSeed($backupMnemonic, "");
26
27
        parent::__construct($primarySeed, $backupSeed, $blocktrailPublicKeys, $unspentOutputFinder, $network, $testnet);
0 ignored issues
show
Compatibility introduced by
$primarySeed of type object<BitWasp\Buffertools\BufferInterface> is not a sub-type of object<BitWasp\Buffertools\Buffer>. It seems like you assume a concrete implementation of the interface BitWasp\Buffertools\BufferInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
Compatibility introduced by
$backupSeed of type object<BitWasp\Buffertools\BufferInterface> is not a sub-type of object<BitWasp\Buffertools\Buffer>. It seems like you assume a concrete implementation of the interface BitWasp\Buffertools\BufferInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
28
    }
29
}
30