From 23fca5dd09be95d04e3048c8cd471b0d4f4bbaff Mon Sep 17 00:00:00 2001 From: woodser Date: Tue, 19 May 2020 14:56:12 -0400 Subject: [PATCH] sample code confirms fee with user --- README.md | 8 ++++++-- test/sample_code.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c55b067..650b211 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ config.m_subaddress_indices = vector(); config.m_subaddress_indices.push_back(0); config.m_subaddress_indices.push_back(1); // withdraw funds from these subaddresses within the account config.m_priority = monero_tx_priority::UNIMPORTANT; // no rush -config.m_relay = true; +config.m_relay = false; // create transaction and relay to the network if true vector> destinations; // specify the recipients and their amounts destinations.push_back(make_shared(wallet_random->get_address(1, 0), 50000)); destinations.push_back(make_shared(wallet_random->get_address(2, 0), 50000)); @@ -147,7 +147,11 @@ config.m_destinations = destinations; // create the transaction, confirm with the user, and relay to the network shared_ptr created_tx = wallet_restored->create_tx(config); uint64_t fee = created_tx->m_fee.get(); // "Are you sure you want to send ...?" -wallet_restored->relay_tx(*created_tx); // submit the transaction to the Monero network which will notify the recipient wallet +wallet_restored->relay_tx(*created_tx); // recipient receives notification within 10 seconds + +// save and close the wallets +wallet_restored->close(true); +wallet_random->close(true); ``` ## How to Run This Library diff --git a/test/sample_code.cpp b/test/sample_code.cpp index e60a18a..cce2b3b 100644 --- a/test/sample_code.cpp +++ b/test/sample_code.cpp @@ -133,7 +133,7 @@ int main(int argc, const char* argv[]) { config.m_subaddress_indices.push_back(0); config.m_subaddress_indices.push_back(1); // withdraw funds from these subaddresses within the account config.m_priority = monero_tx_priority::UNIMPORTANT; // no rush - config.m_relay = true; + config.m_relay = false; // create transaction and relay to the network if true vector> destinations; // specify the recipients and their amounts destinations.push_back(make_shared(wallet_random->get_address(1, 0), 50000)); destinations.push_back(make_shared(wallet_random->get_address(2, 0), 50000)); @@ -142,9 +142,13 @@ int main(int argc, const char* argv[]) { // create the transaction, confirm with the user, and relay to the network shared_ptr created_tx = wallet_restored->create_tx(config); uint64_t fee = created_tx->m_fee.get(); // "Are you sure you want to send ...?" - wallet_restored->relay_tx(*created_tx); // submit the transaction to the Monero network which will notify the recipient wallet + wallet_restored->relay_tx(*created_tx); // recipient receives notification within 10 seconds // the recipient wallet will be notified if (OUTPUT_RECEIVED) cout << "Sample code completed successfully" << endl; else throw runtime_error("Output should have been received"); + + // save and close the wallets + wallet_restored->close(true); + wallet_random->close(true); }