Skip to content

Commit

Permalink
Merge pull request #552 from evoskuil/master
Browse files Browse the repository at this point in the history
Add testnet3 wallet constants.
  • Loading branch information
evoskuil committed Oct 19, 2016
2 parents 15ff0ec + ade41c3 commit e35ceb5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
9 changes: 7 additions & 2 deletions include/bitcoin/bitcoin/wallet/ec_private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@ typedef byte_array<wif_compressed_size> wif_compressed;
class BC_API ec_private
{
public:
static const uint8_t compressed_sentinel;

// WIF carries a compression flag for payment address generation but
// assumes a mapping to payment address version. This is insufficient
// as a parameterized mapping is required, so we use the same technique as
// with hd keys, merging the two necessary values into one version.
static const uint8_t wif;
static const uint8_t mainnet_wif;
static const uint8_t mainnet_p2kh;
static const uint16_t mainnet;
static const uint8_t compressed_sentinel;

static const uint8_t testnet_wif;
static const uint8_t testnet_p2kh;
static const uint16_t testnet;

static inline uint8_t to_address_prefix(uint16_t version)
{
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/bitcoin/wallet/hd_private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BC_API hd_private
{
public:
static const uint64_t mainnet;
static const uint64_t testnet;

static inline uint32_t to_prefix(uint64_t prefixes)
{
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/bitcoin/wallet/hd_public.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class BC_API hd_public
{
public:
static const uint32_t mainnet;
static const uint32_t testnet;

static inline uint32_t to_prefix(uint64_t prefixes)
{
Expand Down
11 changes: 8 additions & 3 deletions src/wallet/ec_private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@
namespace libbitcoin {
namespace wallet {

const uint8_t ec_private::wif = 0x80;
const uint8_t ec_private::mainnet_p2kh = 0x00;
const uint16_t ec_private::mainnet = uint8_t(wif) << 8 | mainnet_p2kh;
const uint8_t ec_private::compressed_sentinel = 0x01;

const uint8_t ec_private::mainnet_wif = 0x80;
const uint8_t ec_private::mainnet_p2kh = 0x00;
const uint16_t ec_private::mainnet = to_version(mainnet_p2kh, mainnet_wif);

const uint8_t ec_private::testnet_wif = 0xef;
const uint8_t ec_private::testnet_p2kh = 0x6f;
const uint16_t ec_private::testnet = to_version(testnet_p2kh, testnet_wif);

ec_private::ec_private()
: valid_(false), compress_(true), version_(0), secret_(null_hash)
{
Expand Down
5 changes: 4 additions & 1 deletion src/wallet/hd_private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@

namespace libbitcoin {
namespace wallet {

const uint64_t hd_private::mainnet = to_prefixes(76066276,
hd_public::mainnet);

const uint64_t hd_private::testnet = to_prefixes(70615956,
hd_public::testnet);

hd_private::hd_private()
: hd_public(), secret_(null_hash)
{
Expand Down
1 change: 1 addition & 0 deletions src/wallet/hd_public.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace libbitcoin {
namespace wallet {

const uint32_t hd_public::mainnet = 76067358;
const uint32_t hd_public::testnet = 70617039;

// hd_public
// ----------------------------------------------------------------------------
Expand Down

0 comments on commit e35ceb5

Please sign in to comment.