Skip to content

Commit

Permalink
qr code as json compatible with GUI wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
mbg033 committed Apr 14, 2020
1 parent 81a8e4a commit a553960
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/apps/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace graft::rta::apps {

GRAFT_DEFINE_IO_STRUCT_INITED(WalletDataQrCode,
(graft::supernode::request::NodeAddress, posAddress, graft::supernode::request::NodeAddress()), //
(uint64_t, blockNumber, 0),
(uint64_t, blockHeight, 0),
(std::string, blockHash, std::string()),
(std::string, paymentId, std::string()),
(std::string, key, std::string()) // key so wallet can decrypt the Payment Data
Expand Down
52 changes: 29 additions & 23 deletions src/apps/rta-pos-cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class PoS
{
WalletDataQrCode qrCode;
qrCode.blockHash = m_presale_resp.BlockHash;
qrCode.blockNumber = m_presale_resp.BlockNumber;
qrCode.blockHeight = m_presale_resp.BlockNumber;
qrCode.key = epee::string_tools::pod_to_hex(m_wallet_secret_key);
qrCode.posAddress.Id = epee::string_tools::pod_to_hex(m_pub_key);
qrCode.posAddress.WalletAddress = m_wallet_address;
Expand Down Expand Up @@ -384,7 +384,6 @@ class PoS
return false;
}
return true;

}

bool validateTx(uint64_t sale_amount)
Expand Down Expand Up @@ -514,6 +513,9 @@ int main(int argc, char* argv[])
const command_line::arg_descriptor<std::string> arg_supernode_address = { "supernode-address", "Supernode address", "localhost:28690", false };
const command_line::arg_descriptor<std::string> arg_pos_wallet_address = { "wallet-address", "POS Wallet address", "", false };
const command_line::arg_descriptor<bool> arg_check_payment_data = { "check-payment-data", "Check payment data", false, false };
const command_line::arg_descriptor<bool> arg_dont_approve = { "dont-approve-payment", "Don't approve payment", false, false };
const command_line::arg_descriptor<bool> arg_force_reject = { "force-payment-rejected", "Force payment rejected", false, false };



command_line::add_arg(desc_cmd, arg_input_file);
Expand All @@ -526,6 +528,8 @@ int main(int argc, char* argv[])
command_line::add_arg(desc_cmd, arg_pos_wallet_address);
command_line::add_arg(desc_cmd, command_line::arg_help);
command_line::add_arg(desc_cmd, arg_check_payment_data);
command_line::add_arg(desc_cmd, arg_dont_approve);
command_line::add_arg(desc_cmd, arg_force_reject);

po::options_description desc_options("Allowed options");
desc_options.add(desc_cmd);
Expand Down Expand Up @@ -567,6 +571,9 @@ int main(int argc, char* argv[])
std::cout << "sale-itimeout: " << command_line::get_arg(vm, arg_sale_timeout) << std::endl;
std::cout << "supernode-address: " << command_line::get_arg(vm, arg_supernode_address) << std::endl;
std::cout << "pos-wallet-address: " << command_line::get_arg(vm, arg_pos_wallet_address) << std::endl;

bool no_approve = command_line::get_arg(vm, arg_dont_approve);
bool force_reject = command_line::get_arg(vm, arg_force_reject);


uint64_t amount = 0;
Expand Down Expand Up @@ -627,30 +634,29 @@ int main(int argc, char* argv[])

MINFO("Sale tx validated for payment: " << pos.paymentId());
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
#if 1
if (!pos.approvePayment()) {
return EXIT_FAILURE;
}

// wait for status = Success;
if (!pos.waitForStatus(int(graft::RTAStatus::Success), actualStatus, std::chrono::seconds(20))) {
MERROR("Expected Success status, got: " << actualStatus);
return EXIT_FAILURE;
}

#endif

#if 0
if (!pos.rejectPayment()) {
return EXIT_FAILURE;
if (!no_approve && !force_reject) {
if (!pos.approvePayment()) {
return EXIT_FAILURE;
}

// wait for status = Success;
if (!pos.waitForStatus(int(graft::RTAStatus::Success), actualStatus, std::chrono::seconds(20))) {
MERROR("Expected Success status, got: " << actualStatus);
return EXIT_FAILURE;
}
}

// wait for status = Success;
if (!pos.waitForStatus(int(graft::RTAStatus::FailRejectedByPOS), actualStatus, std::chrono::seconds(20))) {
MERROR("Expected RejectedByPOS status, got: " << actualStatus);
return EXIT_FAILURE;
if (force_reject) {
if (!pos.rejectPayment()) {
return EXIT_FAILURE;
}

// wait for status = Success;
if (!pos.waitForStatus(int(graft::RTAStatus::FailRejectedByPOS), actualStatus, std::chrono::seconds(20))) {
MERROR("Expected RejectedByPOS status, got: " << actualStatus);
return EXIT_FAILURE;
}
}
#endif

MWARNING("Payment: " << pos.paymentId() << " processed, status: " << actualStatus);

Expand Down
4 changes: 2 additions & 2 deletions src/apps/rta-wallet-cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Wallet
{
PaymentDataRequest req;
req.PaymentID = m_paymentDetails.paymentId;
req.BlockHeight = m_paymentDetails.blockNumber;
req.BlockHeight = m_paymentDetails.blockHeight;
req.BlockHash = m_paymentDetails.blockHash;

std::string raw_resp;
Expand Down Expand Up @@ -271,7 +271,7 @@ class Wallet
// 2. create tx;
cryptonote::rta_header rta_hdr;
rta_hdr.payment_id = m_paymentDetails.paymentId;
rta_hdr.auth_sample_height = m_paymentDetails.blockNumber;
rta_hdr.auth_sample_height = m_paymentDetails.blockHeight;

MWARNING("Building transaction...");

Expand Down

0 comments on commit a553960

Please sign in to comment.