mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 23:31:32 +02:00
sample code confirms fee with user
This commit is contained in:
@@ -138,7 +138,7 @@ config.m_subaddress_indices = vector<uint32_t>();
|
||||
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<shared_ptr<monero_destination>> destinations; // specify the recipients and their amounts
|
||||
destinations.push_back(make_shared<monero_destination>(wallet_random->get_address(1, 0), 50000));
|
||||
destinations.push_back(make_shared<monero_destination>(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<monero_tx_wallet> 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
|
||||
|
||||
@@ -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<shared_ptr<monero_destination>> destinations; // specify the recipients and their amounts
|
||||
destinations.push_back(make_shared<monero_destination>(wallet_random->get_address(1, 0), 50000));
|
||||
destinations.push_back(make_shared<monero_destination>(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<monero_tx_wallet> 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user