Skip to content

Commit

Permalink
Merge branch 'bright_boson_2.2RC' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-strilets committed Jun 28, 2019
2 parents 0d0e2d0 + 1a746e6 commit f298212
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 89 deletions.
6 changes: 0 additions & 6 deletions utility/cli/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ namespace beam
const char* BTC_USER_NAME = "btc_user";
const char* LTC_PASS = "ltc_pass";
const char* LTC_USER_NAME = "ltc_user";
const char* QTUM_PASS = "qtum_pass";
const char* QTUM_USER_NAME = "qtum_user";
const char* AMOUNT = "amount";
const char* AMOUNT_FULL = "amount,a";
const char* RECEIVER_ADDR = "receiver_addr";
Expand All @@ -57,7 +55,6 @@ namespace beam
const char* NODE_ADDR_FULL = "node_addr,n";
const char* BTC_NODE_ADDR = "btc_node_addr";
const char* LTC_NODE_ADDR = "ltc_node_addr";
const char* QTUM_NODE_ADDR = "qtum_node_addr";
const char* COMMAND = "command";
const char* LISTEN = "listen";
const char* TREASURY = "treasury";
Expand Down Expand Up @@ -258,9 +255,6 @@ namespace beam
(cli::LTC_NODE_ADDR, po::value<string>(), "address of litecoin node")
(cli::LTC_USER_NAME, po::value<string>(), "user name for the litecoin node")
(cli::LTC_PASS, po::value<string>(), "password for the litecoin node")
(cli::QTUM_NODE_ADDR, po::value<string>(), "address of qtum node")
(cli::QTUM_USER_NAME, po::value<string>(), "user name for the qtum node")
(cli::QTUM_PASS, po::value<string>(), "password for the qtum node")
(cli::SWAP_COIN, po::value<string>(), "swap coin(btc, ltc, qtum)")
(cli::SWAP_AMOUNT, po::value<Positive<Amount>>(), "swap amount in the smallest unit of the coin")
(cli::SWAP_FEERATE, po::value<Positive<Amount>>(), "The specific feerate you are willing to pay(the smallest unit of the coin per KB)")
Expand Down
3 changes: 0 additions & 3 deletions utility/cli/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ namespace beam
extern const char* BTC_USER_NAME;
extern const char* LTC_PASS;
extern const char* LTC_USER_NAME;
extern const char* QTUM_PASS;
extern const char* QTUM_USER_NAME;
extern const char* AMOUNT;
extern const char* AMOUNT_FULL;
extern const char* RECEIVER_ADDR;
Expand All @@ -52,7 +50,6 @@ namespace beam
extern const char* NODE_ADDR_FULL;
extern const char* BTC_NODE_ADDR;
extern const char* LTC_NODE_ADDR;
extern const char* QTUM_NODE_ADDR;
extern const char* COMMAND;
extern const char* NODE;
extern const char* WALLET;
Expand Down
69 changes: 1 addition & 68 deletions wallet/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ namespace beam
return "BTC";
case AtomicSwapCoin::Litecoin:
return "LTC";
case AtomicSwapCoin::Qtum:
return "QTUM";
default:
assert(false && "Unknow SwapCoin");
}
Expand Down Expand Up @@ -1045,51 +1043,6 @@ namespace

return boost::optional<LitecoinOptions>{};
}

boost::optional<QtumOptions> ParseQtumOptions(const po::variables_map& vm)
{
if (vm.count(cli::QTUM_NODE_ADDR) > 0 || vm.count(cli::QTUM_USER_NAME) > 0 || vm.count(cli::QTUM_PASS) > 0)
{
QtumOptions qtumOptions;

string qtumNodeUri = vm[cli::QTUM_NODE_ADDR].as<string>();
if (!qtumOptions.m_address.resolve(qtumNodeUri.c_str()))
{
throw std::runtime_error("unable to resolve qtum node address: " + qtumNodeUri);
}

if (vm.count(cli::QTUM_USER_NAME) == 0)
{
throw std::runtime_error("user name of qtum node should be specified");
}

qtumOptions.m_userName = vm[cli::QTUM_USER_NAME].as<string>();

// TODO roman.strilets: use SecString instead of std::string
if (vm.count(cli::QTUM_PASS) == 0)
{
throw std::runtime_error("Please, provide password for the qtum node.");
}

qtumOptions.m_pass = vm[cli::QTUM_PASS].as<string>();

if (vm.count(cli::SWAP_FEERATE) == 0)
{
throw std::runtime_error("swap fee rate is missing");
}
qtumOptions.m_feeRate = vm[cli::SWAP_FEERATE].as<Positive<Amount>>().value;

auto swapSecondSideChainType = ParseSwapSecondSideChainType(vm);
if (swapSecondSideChainType != SwapSecondSideChainType::Unknown)
{
qtumOptions.m_chainType = swapSecondSideChainType;
}

return qtumOptions;
}

return boost::optional<QtumOptions>{};
}
}

io::Reactor::Ptr reactor;
Expand Down Expand Up @@ -1391,7 +1344,6 @@ int main_impl(int argc, char* argv[])

boost::optional<BitcoinOptions> btcOptions = ParseBitcoinOptions(vm);
boost::optional<LitecoinOptions> ltcOptions = ParseLitecoinOptions(vm);
boost::optional<QtumOptions> qtumOptions = ParseQtumOptions(vm);

/// HERE!!
io::Address receiverAddr;
Expand Down Expand Up @@ -1472,11 +1424,6 @@ int main_impl(int argc, char* argv[])
wallet.initLitecoin(io::Reactor::get_Current(), ltcOptions.get());
}

if (qtumOptions.is_initialized())
{
wallet.initQtum(io::Reactor::get_Current(), qtumOptions.get());
}

if (command == cli::SWAP_INIT || command == cli::SWAP_LISTEN)
{
if (vm.count(cli::SWAP_AMOUNT) == 0)
Expand Down Expand Up @@ -1530,21 +1477,7 @@ int main_impl(int argc, char* argv[])
}
secondSideChainType = ltcOptions->m_chainType;
}
else
{
if (!qtumOptions.is_initialized() || qtumOptions->m_userName.empty() || qtumOptions->m_pass.empty() || qtumOptions->m_address.empty())
{
LOG_ERROR() << "Qtum node credentials should be provided";
return -1;
}
if (!QtumSide::CheckAmount(swapAmount, qtumOptions->m_feeRate))
{
LOG_ERROR() << "The swap amount must be greater than the redemption fee.";
return -1;
}
secondSideChainType = qtumOptions->m_chainType;
}


bool isBeamSide = (vm.count(cli::SWAP_BEAM_SIDE) != 0);

if (command == cli::SWAP_INIT)
Expand Down
12 changes: 0 additions & 12 deletions wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,18 +598,6 @@ namespace beam::wallet
bool isBeamSide = it->second->GetMandatoryParameter<bool>(TxParameterID::AtomicSwapIsBeamSide);
return std::make_shared<LitecoinSide>(*it->second, m_litecoinBridge, isBeamSide);
}

if (swapCoin == AtomicSwapCoin::Qtum)
{
if (!m_qtumBridge)
{
LOG_ERROR() << "Qtum bridge is not initialized";
return nullptr;
}

bool isBeamSide = it->second->GetMandatoryParameter<bool>(TxParameterID::AtomicSwapIsBeamSide);
return std::make_shared<QtumSide>(*it->second, m_qtumBridge, isBeamSide);
}
}

LOG_ERROR() << "Transaction is absent in wallet.";
Expand Down

0 comments on commit f298212

Please sign in to comment.