Completed
Pull Request — master (#127)
by thomas
19:50
created

WalletV1Sweeper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
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 string              $backupMnemonic
13
     * @param array               $blocktrailPublicKeys
14
     * @param UnspentOutputFinder $unspentOutputFinder
15
     * @param string              $network
16
     * @param bool                $testnet
17
     */
18 1
    public function __construct($primaryMnemonic, $primaryPassphrase, $backupMnemonic, array $blocktrailPublicKeys, UnspentOutputFinder $unspentOutputFinder, $network = 'btc', $testnet = false) {
19
        // cleanup copy paste errors from mnemonics
20 1
        $primaryMnemonic = str_replace("  ", " ", str_replace("\r\n", " ", str_replace("\n", " ", trim($primaryMnemonic))));
21 1
        $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 1
        $primarySeed = (new Bip39SeedGenerator())->getSeed($primaryMnemonic, $primaryPassphrase);
25 1
        $backupSeed = (new Bip39SeedGenerator())->getSeed($backupMnemonic, "");
26
27 1
        parent::__construct($primarySeed, $backupSeed, $blocktrailPublicKeys, $unspentOutputFinder, $network, $testnet);
28 1
    }
29
}
30