Skip to content

m-pays/magi-api-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magi API

This is a C++ wrapper library for Magi JSON-RPC. It allows developers to communicate with the Magi daemon without the need to pack and unpack JSON-RPC messages.

Building the library

Dependencies

Install CMake, Curl, libjson-cpp:

sudo apt-get install cmake libcurl4-openssl-dev libjsoncpp-dev

Install libjson-rpc-cpp:

sudo apt-get install libcurl4-openssl-dev libmicrohttpd-dev libjsoncpp-dev libargtable2-dev cmake
git clone git://github.com/cinemast/libjson-rpc-cpp.git
mkdir -p libjson-rpc-cpp/build
cd libjson-rpc-cpp/build
cmake .. && make
sudo make install
sudo ldconfig          #only required for linux

Build and install

Navigate to the root directory, and then:

mkdir build
cd build
cmake ..
make
sudo make install

Using the library

"example.cpp"

#include <magiapi/magiapi.h>

int main()
{
    std::string username = "rpcuser";
    std::string password = "rpcpass";
    std::string address = "127.0.0.1";
    int port = 8232;

    /* Constructor to connect to the magi daemon */
    MagiAPI xmg(username, password, address, port);

    /* Example method - getbalance */
    std::cout << "Wallet balance: " << xmg.getbalance() << std::endl;
}

Set library path

LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH

Compile

g++ example.cpp -lmagiapi

License

The magi-api-cpp library is released under the terms of MIT.

Acknowledgements

The original C++ wrapper for JSON-RPC communication was coded by bitcoinapi and bitcoin-api-cpp.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published