Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Aseman-Land/QNostr
Nostr module for Qt
https://github.com/Aseman-Land/QNostr
Last synced: 24 days ago
JSON representation
Nostr module for Qt
- Host: GitHub
- URL: https://github.com/Aseman-Land/QNostr
- Owner: Aseman-Land
- License: lgpl-2.1
- Created: 2023-07-20T10:45:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-24T13:48:25.000Z (over 1 year ago)
- Last Synced: 2024-08-04T11:01:15.485Z (4 months ago)
- Language: C++
- Size: 33.2 KB
- Stars: 10
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nostr - QNostr - Land/QNostr.svg?style=social) - A Nostr protocol implementation for clients as a Qt Module in C++ (Relays / Implementations)
README
# QNostr-Module
Standard Nostr module for Qt written using C++ and QtWebSockets.## How to Build
To build it for Qt5 run below commands:
```bash
git clone "https://github.com/Aseman-Land/qnostr.git"
cd qnostr
mkdir build && cd build
qmake -r ..
make -j4
sudo make install
```And for Qt6:
```bash
git clone "https://github.com/Aseman-Land/qnostr.git"
cd qnostr
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install
```## How to add it to Projects
It's easy. Just add below line to your qmake's `.pro` file:
```qmake
QT += nostr
```Or for cmake
```cmake
find_package(Qt6 6.0.0 CONFIG REQUIRED COMPONENTS Nostr)
```## How to use it
```C++
#include#include
const auto secret = QNostr::generateNewSecret();
QNostr relay(secret);
relay.addRelay(QUrl("wss://RELAY_ADDRESS"));connect(&relay, &QNostr::connected, [](const QUrl &relay){
qDebug() << relay << "Connected";
});
connect(&relay, &QNostr::newEvent, [](const QString &subscribeId, const QNostrRelay::Event &event, bool storedEvent, const QUrl &relay){
qDebug() << relay << subscribeId << event.content << storedEvent;
});
connect(&relay, &QNostr::disconnected, [](const QUrl &relay){
qDebug() << relay << "Disconnected";
});QNostrRelay::Request req;
req.authors << "AUTHOR_PKEY";
req.kinds << 1;
req.limit = 10;qDebug() << relay.sendRequest(req);
```