Skip to content

Commit

Permalink
Merge pull request #653 from evoskuil/master
Browse files Browse the repository at this point in the history
Update libbitcoin-system.props, rem dead code, comments, style.
  • Loading branch information
evoskuil authored Nov 1, 2019
2 parents 91a8729 + ee2426f commit 5a56c78
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 58 deletions.
2 changes: 1 addition & 1 deletion builds/msvc/vs2013/libbitcoin-system.import.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<!-- NOMINMAX enables use of std::min/max without conflict. -->
<!-- WIN32_LEAN_AND_MEAN avoids boost conflict: lists.boost.org/boost-users/2008/07/37824.php. -->
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;WITH_ICU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Linkage-libbitcoin-system)' == 'static' Or '$(Linkage-libbitcoin-system)' == 'ltcg'">BC_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
Expand Down
2 changes: 1 addition & 1 deletion builds/msvc/vs2015/libbitcoin-system.import.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<!-- NOMINMAX enables use of std::min/max without conflict. -->
<!-- WIN32_LEAN_AND_MEAN avoids boost conflict: lists.boost.org/boost-users/2008/07/37824.php. -->
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;WITH_ICU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Linkage-libbitcoin-system)' == 'static' Or '$(Linkage-libbitcoin-system)' == 'ltcg'">BC_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
Expand Down
2 changes: 1 addition & 1 deletion builds/msvc/vs2017/libbitcoin-system.import.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<!-- NOMINMAX enables use of std::min/max without conflict. -->
<!-- WIN32_LEAN_AND_MEAN avoids boost conflict: lists.boost.org/boost-users/2008/07/37824.php. -->
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;WITH_ICU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Linkage-libbitcoin-system)' == 'static' Or '$(Linkage-libbitcoin-system)' == 'ltcg'">BC_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
Expand Down
26 changes: 1 addition & 25 deletions include/bitcoin/explorer/commands/electrum-to-seed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ class BCX_API electrum_to_seed
value<boost::filesystem::path>(),
"The path to the configuration settings file."
)
(
"language,l",
value<explorer::config::language>(&option_.language),
"The language identifier of the dictionary of the mnemonic. Options are 'en', 'es', 'ja', 'pt', 'zh_Hans' and 'any', defaults to 'any'."
)
(
"passphrase,p",
value<std::string>(&option_.passphrase),
Expand Down Expand Up @@ -197,23 +192,6 @@ class BCX_API electrum_to_seed
argument_.words = value;
}

/**
* Get the value of the language option.
*/
virtual explorer::config::language& get_language_option()
{
return option_.language;
}

/**
* Set the value of the language option.
*/
virtual void set_language_option(
const explorer::config::language& value)
{
option_.language = value;
}

/**
* Get the value of the passphrase option.
*/
Expand Down Expand Up @@ -256,12 +234,10 @@ class BCX_API electrum_to_seed
struct option
{
option()
: language(),
passphrase()
: passphrase()
{
}

explorer::config::language language;
std::string passphrase;
} option_;
};
Expand Down
29 changes: 14 additions & 15 deletions model/generate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,6 @@
<define name="BX_EC_TO_WITNESS_PREFIX_NOT_SPECIFIED" value="The seed is less than 192 bits long." />
</command>

<command symbol="electrum-new" output="string" multipleX="true" category="WALLET" description="Create a mnemonic seed (Electrum) from entropy. WARNING: mnemonic should be created from properly generated entropy.">
<option name="prefix" type="electrum" description="The electrum seed type identifier to use. Options are 'standard', 'witness', and 'dual' (for two factor authentication), defaults to 'standard'." />
<option name="language" type="language" description="The language identifier of the mnemonic dictionary to use. Options are 'en', 'es', 'pt', 'ja', 'zh_Hans' and 'any', defaults to 'en'." />
<argument name="SEED" stdin="true" type="base16" description="The Base16 entropy from which the mnemonic is created. If not specified the entropy is read from STDIN." />
<define name="BX_ELECTRUM_NEW_INVALID_SEED" value="The seed size is not supported." />
<define name="BX_ELECTRUM_REQUIRES_ICU" value="The command requires an ICU build." />
</command>

<command symbol="electrum-to-seed" output="base16" category="WALLET" description="Convert a mnemonic seed (Electrum) to its numeric representation.">
<option name="language" type="language" description="The language identifier of the dictionary of the mnemonic. Options are 'en', 'es', 'ja', 'pt', 'zh_Hans' and 'any', defaults to 'any'." />
<option name="passphrase" type="string" description="An optional passphrase for converting the mnemonic to a seed." />
<argument name="WORD" stdin="true" limit="-1" type="string" description="The set of words that that make up the mnemonic. If not specified the words are read from STDIN." />
<define name="BX_ELECTRUM_TO_SEED_REQUIRES_ICU" value="The passphrase option requires an ICU build." />
</command>

<command symbol="ek-address" output="payment_address" category="KEY_ENCRYPTION" description="Create a payment address derived from an intermediate passphrase token (BIP38).">
<option name="uncompressed" description="Use the uncompressed public key format, as used to create the corresponding encrypted private key." />
<option name="version" type="byte" configuration="wallet.pay_to_public_key_hash_version" description="The desired payment address version used to create the corresponding encrypted private key." />
Expand Down Expand Up @@ -289,6 +274,20 @@
<define name="BX_EK_TO_EC_REQUIRES_ICU" value="The command requires an ICU build." />
</command>

<command symbol="electrum-new" output="string" multipleX="true" category="WALLET" description="Create a mnemonic seed (Electrum) from entropy. WARNING: mnemonic should be created from properly generated entropy.">
<option name="prefix" type="electrum" description="The electrum seed type identifier to use. Options are 'standard', 'witness', and 'dual' (for two factor authentication), defaults to 'standard'." />
<option name="language" type="language" description="The language identifier of the mnemonic dictionary to use. Options are 'en', 'es', 'pt', 'ja', 'zh_Hans' and 'any', defaults to 'en'." />
<argument name="SEED" stdin="true" type="base16" description="The Base16 entropy from which the mnemonic is created. If not specified the entropy is read from STDIN." />
<define name="BX_ELECTRUM_NEW_INVALID_SEED" value="The seed size is not supported." />
<define name="BX_ELECTRUM_REQUIRES_ICU" value="The command requires an ICU build." />
</command>

<command symbol="electrum-to-seed" output="base16" category="WALLET" description="Convert a mnemonic seed (Electrum) to its numeric representation.">
<option name="passphrase" type="string" description="An optional passphrase for converting the mnemonic to a seed." />
<argument name="WORD" stdin="true" limit="-1" type="string" description="The set of words that that make up the mnemonic. If not specified the words are read from STDIN." />
<define name="BX_ELECTRUM_TO_SEED_REQUIRES_ICU" value="The passphrase option requires an ICU build." />
</command>

<command symbol="fetch-balance" output="balance_row" category="ONLINE" network="true" description="Get the balance in satoshi of a payment address. Requires a Libbitcoin server connection.">
<option name="format" type="encoding" description="The output format. Options are 'info', 'json' and 'xml', defaults to 'info'." />
<argument name="hash" stdin="true" type="hash256" description="The Base16 payments search key. If not specified the key is read from STDIN."/>
Expand Down
7 changes: 3 additions & 4 deletions src/commands/electrum-to-seed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ using namespace bc::system::wallet;
console_result electrum_to_seed::invoke(std::ostream& output,
std::ostream& error)
{
// Bound parameters.
const dictionary_list& language = get_language_option();

#ifdef WITH_ICU
const auto& passphrase = get_passphrase_option();
const auto& words = get_words_argument();

// Decoding requires ICU normalization.
if (passphrase.empty())
output << base16(electrum::decode_mnemonic(words)) << std::endl;
else
output << base16(electrum::decode_mnemonic(words, passphrase)) << std::endl;
output << base16(electrum::decode_mnemonic(words, passphrase))
<< std::endl;

return console_result::okay;
#else
Expand Down
2 changes: 1 addition & 1 deletion src/commands/mnemonic-to-seed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ console_result mnemonic_to_seed::invoke(std::ostream& output,
return console_result::failure;
}

// The passphrase requires ICU normalization.
// Decoding with passphrase requires ICU normalization.
const auto seed = decode_mnemonic(words);
#endif

Expand Down
2 changes: 1 addition & 1 deletion test/commands/ec-to-ek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ BOOST_AUTO_TEST_SUITE(ec_to_ek__invoke)

#ifdef WITH_ICU

// BI-38 Vectors
// BIP-38 Vectors

BOOST_AUTO_TEST_CASE(ec_to_ek__invoke__vector_0_uncompressed__okay)
{
Expand Down
6 changes: 0 additions & 6 deletions test/commands/electrum-new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ BOOST_AUTO_TEST_CASE(electrum_new__invoke__en_dictionary_prefix__okay_output)

BOOST_AUTO_TEST_CASE(electrum_new__invoke__es_dictionary_prefix__okay_output)
{
// Required for proper initialization of a non-ascii dictionary in vc++.
set_utf8_stdout();

// Verify the UTF8 initialization.
BOOST_REQUIRE(system::wallet::language::es[0] == std::string("ábaco"));

BX_DECLARE_COMMAND(electrum_new);
command.set_seed_argument({ "05e669b4270f4e25bce6fc3736170d423c" });
command.set_language_option({ "es" });
Expand Down
3 changes: 0 additions & 3 deletions test/commands/electrum-to-seed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ BOOST_AUTO_TEST_CASE(electrum_to_seed__invoke__okay_output)
BOOST_AUTO_TEST_CASE(electrum_to_seed__invoke__language_en__okay_output)
{
BX_DECLARE_COMMAND(electrum_to_seed);
command.set_language_option({ "en" });
command.set_words_argument({ "foobar" });
#ifdef WITH_ICU
BX_REQUIRE_OKAY(command.invoke(output, error));
Expand All @@ -54,7 +53,6 @@ BOOST_AUTO_TEST_CASE(electrum_to_seed__invoke__language_en__okay_output)
BOOST_AUTO_TEST_CASE(electrum_to_seed__invoke__12_words__okay_output)
{
BX_DECLARE_COMMAND(electrum_to_seed);
command.set_language_option({ "en" });
command.set_words_argument({ "giggle", "crush", "argue", "inflict", "wear", "defy", "combine", "evolve", "tiger", "spatial", "crumble", "fury" });
#ifdef WITH_ICU
BX_REQUIRE_OKAY(command.invoke(output, error));
Expand All @@ -69,7 +67,6 @@ BOOST_AUTO_TEST_CASE(electrum_to_seed__invoke__12_words__okay_output)
BOOST_AUTO_TEST_CASE(electrum_to_seed__invoke__12_words_with_passphrase_electrum_test__okay_output)
{
BX_DECLARE_COMMAND(electrum_to_seed);
command.set_language_option({ "es" });
command.set_passphrase_option({ "araña difícil solución término cárcel" });
command.set_words_argument({ "almíbar", "tibio", "superar", "vencer", "hacha", "peatón", "príncipe", "matar", "consejo", "polen", "vehículo", "odisea" });
#ifdef WITH_ICU
Expand Down

0 comments on commit 5a56c78

Please sign in to comment.