Skip to content

Commit

Permalink
Merge pull request #36 from yfgeek/master
Browse files Browse the repository at this point in the history
Fixed testnet WIF format bug
  • Loading branch information
rgex authored Aug 9, 2017
2 parents 7356fdd + 9eb7142 commit b885965
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ public function getNetworkPrefix()
return $this->networkPrefix;
}

/**
* Returns the current network prefix for WIF, '80' = main network, 'ef' = test network.
*
* @return string (hexa)
*/
public function getPrivatePrefix(){
if($this->networkPrefix =='6f')
return 'ef';
else
return '80';
}

/***
* Permutation table used for Base58 encoding and decoding.
*
Expand Down Expand Up @@ -825,7 +837,7 @@ public function getWif($compressed = true)
while(strlen($k) < 64)
$k = '0' . $k;

$secretKey = '80' . $k;
$secretKey = $this->getPrivatePrefix() . $k;

if($compressed) {
$secretKey .= '01';
Expand Down

0 comments on commit b885965

Please sign in to comment.