{"id":15146783,"url":"https://github.com/woodser/monero-cpp","last_synced_at":"2025-04-09T15:52:01.454Z","repository":{"id":39703157,"uuid":"188735629","full_name":"woodser/monero-cpp","owner":"woodser","description":"C++ library for using Monero","archived":false,"fork":false,"pushed_at":"2024-09-21T11:55:21.000Z","size":4479,"stargazers_count":64,"open_issues_count":10,"forks_count":28,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T22:31:57.538Z","etag":null,"topics":["monero"],"latest_commit_sha":null,"homepage":"https://woodser.github.io/monero-cpp/doxygen/annotated.html","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/woodser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-26T21:58:51.000Z","updated_at":"2024-10-28T11:29:57.000Z","dependencies_parsed_at":"2024-01-21T11:22:07.677Z","dependency_job_id":"901fd777-3a78-4dcb-81fa-b413d465d01e","html_url":"https://github.com/woodser/monero-cpp","commit_stats":{"total_commits":962,"total_committers":6,"mean_commits":"160.33333333333334","dds":0.00519750519750517,"last_synced_commit":"bdc0ee7666fc4ba4550501b24b3d2d49f54365cd"},"previous_names":["woodser/monero-cpp"],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodser%2Fmonero-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodser%2Fmonero-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodser%2Fmonero-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodser%2Fmonero-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/woodser","download_url":"https://codeload.github.com/woodser/monero-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248064229,"owners_count":21041854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["monero"],"created_at":"2024-09-26T12:04:53.487Z","updated_at":"2025-04-09T15:52:01.429Z","avatar_url":"https://github.com/woodser.png","language":"C++","funding_links":[],"categories":["Libraries"],"sub_categories":["Other Wallets"],"readme":"# Monero C++ Library\n\nA C++ library for creating Monero applications using native bindings to [monero v0.18.3.4 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.3.4).\n\n* Supports fully client-side wallets by wrapping [wallet2.h](https://github.com/monero-project/monero/blob/master/src/wallet/wallet2.h).\n* Supports multisig, view-only, and offline wallets.\n* Uses a clearly defined [data model and API specification](https://woodser.github.io/monero-java/monero-spec.pdf) intended to be intuitive and robust.\n* Query wallet transactions, transfers, and outputs by their properties.\n* Receive notifications when wallets sync, send, or receive.\n* Tested by over 100 tests in [monero-java](https://github.com/woodser/monero-java) and [monero-ts](https://github.com/woodser/monero-ts) using JNI and WebAssembly bindings.\n\n## Sample code\n\n```c++\n// create a wallet from a seed phrase\nmonero_wallet_config wallet_config;\nwallet_config.m_seed = \"hefty value later extra artistic firm radar yodel talent future fungal nutshell because sanity awesome nail unjustly rage unafraid cedar delayed thumbs comb custom sanity\";\nwallet_config.m_path = \"MyWalletRestored\";\nwallet_config.m_password = \"supersecretpassword123\";\nwallet_config.m_network_type = monero_network_type::STAGENET;\nwallet_config.m_server = monero_rpc_connection(\"http://localhost:38081\", \"superuser\", \"abctesting123\");\nwallet_config.m_restore_height = 380104;\nwallet_config.m_seed_offset = \"\";\nmonero_wallet* wallet_restored = monero_wallet_full::create_wallet(wallet_config);\n\n// synchronize the wallet and receive progress notifications\nstruct : monero_wallet_listener {\n  void on_sync_progress(uint64_t height, uint64_t start_height, uint64_t end_height, double percent_done, const string\u0026 message) {\n    // feed a progress bar?\n  }\n} my_sync_listener;\nwallet_restored-\u003esync(my_sync_listener);\n\n// start syncing the wallet continuously in the background\nwallet_restored-\u003estart_syncing();\n\n// get balance, account, subaddresses\nstring restored_primary = wallet_restored-\u003eget_primary_address();\nuint64_t balance = wallet_restored-\u003eget_balance(); // can specify account and subaddress indices\nmonero_account account = wallet_restored-\u003eget_account(1, true); // get account with subaddresses\nuint64_t unlocked_account_balance = account.m_unlocked_balance.get(); // get boost::optional value\n\n// query a transaction by hash\nmonero_tx_query tx_query;\ntx_query.m_hash = \"314a0f1375db31cea4dac4e0a51514a6282b43792269b3660166d4d2b46437ca\";\nvector\u003cshared_ptr\u003cmonero_tx_wallet\u003e\u003e txs = wallet_restored-\u003eget_txs(tx_query);\nshared_ptr\u003cmonero_tx_wallet\u003e tx = txs[0];\nfor (const shared_ptr\u003cmonero_transfer\u003e transfer : tx-\u003eget_transfers()) {\n  bool is_incoming = transfer-\u003eis_incoming().get();\n  uint64_t in_amount = transfer-\u003em_amount.get();\n  int account_index = transfer-\u003em_account_index.get();\n}\nmonero_utils::free(txs);\n\n// query incoming transfers to account 1\nmonero_transfer_query transfer_query;\ntransfer_query.m_is_incoming = true;\ntransfer_query.m_account_index = 1;\nvector\u003cshared_ptr\u003cmonero_transfer\u003e\u003e transfers = wallet_restored-\u003eget_transfers(transfer_query);\nmonero_utils::free(transfers);\n\n// query unspent outputs\nmonero_output_query output_query;\noutput_query.m_is_spent = false;\nvector\u003cshared_ptr\u003cmonero_output_wallet\u003e\u003e outputs = wallet_restored-\u003eget_outputs(output_query);\nmonero_utils::free(outputs);\n\n// create and sync a new wallet with a random seed phrase\nwallet_config = monero_wallet_config();\nwallet_config.m_path = \"MyWalletRandom\";\nwallet_config.m_password = \"supersecretpassword123\";\nwallet_config.m_network_type = monero_network_type::STAGENET;\nwallet_config.m_server = monero_rpc_connection(\"http://localhost:38081\", \"superuser\", \"abctesting123\");\nwallet_config.m_language = \"English\";\nmonero_wallet* wallet_random = monero_wallet_full::create_wallet(wallet_config);\nwallet_random-\u003esync();\n\n// synchronize in the background every 5 seconds\nwallet_random-\u003estart_syncing(5000);\n\n// get wallet info\nstring random_seed = wallet_random-\u003eget_seed();\nstring random_primary = wallet_random-\u003eget_primary_address();\nuint64_t random_height = wallet_random-\u003eget_height();\nbool random_is_synced = wallet_random-\u003eis_synced();\n\n// receive notifications when funds are received, confirmed, and unlocked\nstruct : monero_wallet_listener {\n  void on_output_received(const monero_output_wallet\u0026 output) {\n    cout \u003c\u003c \"Wallet received funds!\" \u003c\u003c endl;\n    uint64_t amount = output.m_amount.get();\n    string tx_hash = output.m_tx-\u003em_hash.get();\n    bool is_confirmed = output.m_tx-\u003em_is_confirmed.get();\n    bool is_locked = dynamic_pointer_cast\u003cmonero_tx_wallet\u003e(output.m_tx)-\u003em_is_locked.get();\n    int account_index = output.m_account_index.get();\n    int subaddress_index = output.m_subaddress_index.get();\n    FUNDS_RECEIVED = true;\n  }\n} my_listener;\nwallet_random-\u003eadd_listener(my_listener);\n\n// send funds from the restored wallet to the random wallet\nmonero_tx_config tx_config;\ntx_config.m_account_index = 0;\ntx_config.m_address = wallet_random-\u003eget_address(1, 0);\ntx_config.m_amount = 50000;\ntx_config.m_relay = true;\nshared_ptr\u003cmonero_tx_wallet\u003e sent_tx = wallet_restored-\u003ecreate_tx(tx_config);\nbool in_pool = sent_tx-\u003em_in_tx_pool.get();  // true\nmonero_utils::free(sent_tx);\n\n// mine with 7 threads to push the network along\nint num_threads = 7;\nbool is_background = false;\nbool ignore_battery = false;\nwallet_restored-\u003estart_mining(num_threads, is_background, ignore_battery);\n\n// wait for the next block to be added to the chain\nuint64_t next_height = wallet_random-\u003ewait_for_next_block();\n\n// stop mining\nwallet_restored-\u003estop_mining();\n\n// create config to send funds to multiple destinations in the random wallet\ntx_config = monero_tx_config();\ntx_config.m_account_index = 1; // withdraw funds from this account\ntx_config.m_subaddress_indices = vector\u003cuint32_t\u003e();\ntx_config.m_subaddress_indices.push_back(0);\ntx_config.m_subaddress_indices.push_back(1); // withdraw funds from these subaddresses within the account\ntx_config.m_priority = monero_tx_priority::UNIMPORTANT; // no rush\ntx_config.m_relay = false; // create transaction and relay to the network if true\nvector\u003cshared_ptr\u003cmonero_destination\u003e\u003e destinations; // specify the recipients and their amounts\ndestinations.push_back(make_shared\u003cmonero_destination\u003e(wallet_random-\u003eget_address(1, 0), 50000));\ndestinations.push_back(make_shared\u003cmonero_destination\u003e(wallet_random-\u003eget_address(2, 0), 50000));\ntx_config.m_destinations = destinations;\n\n// create the transaction, confirm with the user, and relay to the network\nshared_ptr\u003cmonero_tx_wallet\u003e created_tx = wallet_restored-\u003ecreate_tx(tx_config);\nuint64_t fee = created_tx-\u003em_fee.get(); // \"Are you sure you want to send ...?\"\nwallet_restored-\u003erelay_tx(*created_tx); // recipient receives notification within 5 seconds\nmonero_utils::free(created_tx);\n\n// save and close the wallets\nwallet_restored-\u003eclose(true);\nwallet_random-\u003eclose(true);\ndelete wallet_restored;\ndelete wallet_random;\n```\n\n## Documentation\n\n* [API documentation](https://woodser.github.io/monero-cpp/doxygen/annotated.html)\n* [API and model overview with visual diagrams](https://woodser.github.io/monero-java/monero-spec.pdf)\n* [monero-ts documentation](https://github.com/woodser/monero-ts#documentation) provides additional documentation which translates to monero-cpp\n\n## Using monero-cpp in your project\n\nThis project may be compiled as part of another application or built as a shared or static library.\n\nFor example, [monero-java](https://github.com/woodser/monero-java) compiles this project to a shared library to support Java JNI bindings, while [monero-ts](https://github.com/woodser/monero-ts) compiles this project to WebAssembly binaries.\n\n### Linux\n\n1. Clone the project repository if applicable: `git clone --recurse-submodules https://github.com/woodser/monero-cpp.git`\n2. Update dependencies: `sudo apt update \u0026\u0026 sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz nettle-dev libevent-dev`\n3. Follow instructions to install [unbound](https://unbound.docs.nlnetlabs.nl/en/latest/getting-started/installation.html) for Linux to your home directory (e.g. `~/unbound-1.19.0`).\n\n    For example, install expat:\n    ```\n    cd ~\n    wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2\n    tar -xf expat-2.4.8.tar.bz2\n    sudo rm expat-2.4.8.tar.bz2\n    cd expat-2.4.8\n    ./configure --enable-static --disable-shared\n    make\n    sudo make install\n    cd ../\n    ```\n\n    For example, install unbound:\n    ```\n    cd ~\n    wget https://www.nlnetlabs.nl/downloads/unbound/unbound-1.22.0.tar.gz\n    tar xzf unbound-1.22.0.tar.gz\n    sudo apt update\n    sudo apt install -y build-essential\n    sudo apt install -y libssl-dev\n    sudo apt install -y libexpat1-dev\n    sudo apt-get install -y bison\n    sudo apt-get install -y flex\n    cd unbound-1.22.0\n    ./configure --with-libexpat=/usr --with-ssl=/usr --enable-static-exe\n    make\n    sudo make install\n    cd ../\n    ```\n4. Build monero-project, located as a submodule at ./external/monero-project. Install [dependencies](https://github.com/monero-project/monero#dependencies) as needed for your system, then build with: `make release-static -j8`\n5. Link to this library's source files in your application, or build monero-cpp to a shared library in ./build: `./bin/build_libmonero_cpp.sh`\n\n### macOS\n\n1. Clone the project repository if applicable: `git clone --recurse-submodules https://github.com/woodser/monero-cpp.git`\n2. Follow instructions to install [unbound](https://unbound.docs.nlnetlabs.nl/en/latest/getting-started/installation.html) for macOS to your home directory (e.g. `~/unbound-1.22.0`).\n\n    For example:\n    ```\n    cd ~\n    wget https://nlnetlabs.nl/downloads/unbound/unbound-1.22.0.tar.gz\n    tar xzf unbound-1.22.0.tar.gz\n    cd ~/unbound-1.22.0\n    ./configure --with-ssl=/opt/homebrew/Cellar/openssl@3/3.4.0/ --with-libexpat=/opt/homebrew/Cellar/expat/2.6.4\n    make\n    sudo make install\n    ```\n3. Build monero-project, located as a submodule at ./external/monero-project. Install [dependencies](https://github.com/monero-project/monero#dependencies) as needed for your system, then build with e.g.: `make release-static -j6`\n4. Link to this library's source files in your application, or build monero-cpp to a shared library in ./build: `./bin/build_libmonero_cpp.sh`\n\n### Windows\n\n1. Download and install [MSYS2](https://www.msys2.org/).\n2. Press the Windows button and launch `MSYS2 MINGW64` for 64 bit systems or `MSYS2 MINGW32` for 32 bit.\n3. Update packages: `pacman -Syu` and confirm at prompts.\n4. Relaunch MSYS2 (if necessary) and install dependencies:\n\n    For 64 bit:\n\n     ```\n     pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-unbound mingw-w64-x86_64-protobuf git mingw-w64-x86_64-libusb gettext base-devel\n     wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-icu-75.1-1-any.pkg.tar.zst\n     pacman -U mingw-w64-x86_64-icu-75.1-1-any.pkg.tar.zst\n     wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-boost-1.85.0-4-any.pkg.tar.zst\n     pacman -U mingw-w64-x86_64-boost-1.85.0-4-any.pkg.tar.zst\n     ```\n\n     For 32 bit:\n\n     ```\n     pacman -S  mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-zeromq mingw-w64-i686-libsodium mingw-w64-i686-hidapi mingw-w64-i686-unbound mingw-w64-i686-protobuf git mingw-w64-i686-libusb gettext base-devel mingw-w64-i686-icu\n     ```\n5. Clone repo if installing standalone (skip if building as part of another repo like monero-java or monero-ts): `git clone --recurse-submodules https://github.com/woodser/monero-cpp.git`\n6. Build monero-project, located as a submodule at ./external/monero-project. Install [dependencies](https://github.com/monero-project/monero#dependencies) as needed for your system, then build with:\n\n    For 64 bit: `make release-static-win64`\n    \n    For 32 bit: `make release-static-win32`\n7. Link to this library's source files in your application, or build monero-cpp to a shared library (libmonero-cpp.dll) in ./build: `./bin/build_libmonero_cpp.sh`\n\n## Running sample code and tests\n\n1. In CMakeLists.txt, set the flags to build:\n\n         set(BUILD_LIBRARY ON)\n         set(BUILD_SAMPLE ON)\n         set(BUILD_SCRATCHPAD ON)\n         set(BUILD_TESTS ON)\n2. `./bin/build_libmonero_cpp.sh`\n3. Run the app, for example: `./build/sample_code`\n\n## Related projects\n\n* [monero-java](https://github.com/woodser/monero-java)\n* [monero-ts](https://github.com/woodser/monero-ts)\n\n## License\n\nThis project is licensed under MIT.\n\n## Donations\n\nPlease consider donating to support the development of this project. 🙏\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"donate.png\" width=\"115\" height=\"115\"/\u003e\u003cbr\u003e\n\t\u003ccode\u003e46FR1GKVqFNQnDiFkH7AuzbUBrGQwz2VdaXTDD4jcjRE8YkkoTYTmZ2Vohsz9gLSqkj5EM6ai9Q7sBoX4FPPYJdGKQQXPVz\u003c/code\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoodser%2Fmonero-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwoodser%2Fmonero-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoodser%2Fmonero-cpp/lists"}