diff --git a/src/apps/common/common.h b/src/apps/common/common.h index ed85261a..9423319d 100644 --- a/src/apps/common/common.h +++ b/src/apps/common/common.h @@ -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 diff --git a/src/apps/rta-pos-cli/main.cpp b/src/apps/rta-pos-cli/main.cpp index 1a6fc065..b7410add 100644 --- a/src/apps/rta-pos-cli/main.cpp +++ b/src/apps/rta-pos-cli/main.cpp @@ -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; @@ -384,7 +384,6 @@ class PoS return false; } return true; - } bool validateTx(uint64_t sale_amount) @@ -514,6 +513,9 @@ int main(int argc, char* argv[]) const command_line::arg_descriptor arg_supernode_address = { "supernode-address", "Supernode address", "localhost:28690", false }; const command_line::arg_descriptor arg_pos_wallet_address = { "wallet-address", "POS Wallet address", "", false }; const command_line::arg_descriptor arg_check_payment_data = { "check-payment-data", "Check payment data", false, false }; + const command_line::arg_descriptor arg_dont_approve = { "dont-approve-payment", "Don't approve payment", false, false }; + const command_line::arg_descriptor arg_force_reject = { "force-payment-rejected", "Force payment rejected", false, false }; + command_line::add_arg(desc_cmd, arg_input_file); @@ -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); @@ -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; @@ -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); diff --git a/src/apps/rta-wallet-cli/main.cpp b/src/apps/rta-wallet-cli/main.cpp index 67e29ad3..c15fde94 100644 --- a/src/apps/rta-wallet-cli/main.cpp +++ b/src/apps/rta-wallet-cli/main.cpp @@ -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; @@ -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...");