summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Taaki <genjix@riseup.net>2014-05-08 17:56:40 (GMT)
committer Amir Taaki <genjix@riseup.net>2014-05-08 17:56:40 (GMT)
commit93419696c9901b4ea441f63b90b90c69e589b937 (patch)
tree4dbbb5e0d7a2802c218bdbe292a1387294c96e72
parentb8a044e79d71289a7a64e33d17d3be3a3fde15ed (diff)
allow configuring number of signatures in stealth-addr command.
-rw-r--r--src/stealth-addr.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/stealth-addr.cpp b/src/stealth-addr.cpp
index 6263022..604f0e4 100644
--- a/src/stealth-addr.cpp
+++ b/src/stealth-addr.cpp
@@ -1,3 +1,4 @@
+#include <boost/lexical_cast.hpp>
#include <bitcoin/bitcoin.hpp>
using namespace bc;
@@ -9,16 +10,30 @@ int main(int argc, char** argv)
args.push_back(argv[i]);
// Check for optional arguments.
bool reuse_address = false;
- for (auto it = args.begin(); it != args.end(); ++it)
+ uint8_t number_sigs = 0;
+ for (auto it = args.begin(); it != args.end(); )
+ {
if (*it == "--reuse-key" || *it == "-r")
{
- args.erase(it);
+ it = args.erase(it);
break;
}
+ if (*it == "--signatures" || *it == "-s")
+ {
+ it = args.erase(it);
+ if (it == args.end())
+ {
+ std::cerr << "sx: --signatures requires a number." << std::endl;
+ return -1;
+ }
+ number_sigs = static_cast<uint8_t>(boost::lexical_cast<int>(*it));
+ }
+ ++it;
+ }
// Read scan pubkey.
if (args.empty())
{
- std::cout << "sx: Scan pubkey must be provided." << std::endl;
+ std::cerr << "sx: Scan pubkey must be provided." << std::endl;
return -1;
}
const data_chunk scan_pubkey = decode_hex(args[0]);
@@ -44,9 +59,11 @@ int main(int argc, char** argv)
raw_addr.push_back(number_keys);
for (const auto& pubkey: spend_pubkeys)
extend_data(raw_addr, pubkey);
- // For now put number_sigs = number_keys
- // Allow configuring this later.
- uint8_t number_sigs = number_keys;
+ // If not configured then set it to the number_keys
+ if (!number_sigs)
+ number_sigs = number_keys;
+ if (reuse_address)
+ ++number_sigs;
raw_addr.push_back(number_sigs);
// Prefix filter currently unused.
// Allow configuring this later.