Add referral program with lightning/NWC payouts#55
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add referral program for automatic payouts with lightning address
Add referral program with lightning/NWC payouts
Feb 19, 2026
v0l
requested changes
Feb 19, 2026
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
v0l
reviewed
Feb 19, 2026
Contributor
|
@copilot |
v0l
requested changes
Feb 19, 2026
…dpoints Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
…y calculation Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
…invoice, BINARY(32) pre_image Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
…e single-currency summary Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
- Add API changelog entry for referral program endpoints - Fix unused imports (patch, post) in referral.rs - Reorganize imports per code style guidelines - Fix documentation comment: base32 -> base63 for referral codes
v0l
force-pushed
the
copilot/add-referral-program-feature
branch
from
February 20, 2026 16:37
26135af to
3d59ef1
Compare
Another migration (cpu_type) already uses timestamp 20260219000000.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a referral program allowing users to earn payouts when referred users make their first payment. Supports automatic payouts via lightning address or NWC wallet.
DB Layer
referral(user enrollment, unique code per user) andreferral_payouttables withinvoice VARCHAR(2048),pre_image BINARY(32),currency VARCHAR(5), andamount BIGINT UNSIGNEDcolumnsReferralandReferralPayoutadded tolnvps_db;ReferralPayoutincludesinvoice(BOLT11 lightning invoice) andpre_image(32-byte SHA256 hash revealed on payment)LNVpsDbBase:referralandreferral_payouttableslist_referral_usage(code)— returns the first paid VM payment per referred VM (same logic as the admin referral report), used to compute per-currency earnings in application codecount_failed_referrals(code)— counts referred VMs that never made a paid paymentAPI (
/api/v1/referral)POSTlightning_addressand/oruse_nwc; validates NWC is configured if requested; auto-generates 8-char base63 codeGETPATCHlightning_address, toggleuse_nwc)API Response Design
Since referrals can be paid in different currencies (EUR, BTC, etc.) that cannot be summed, and FIAT→BTC conversion happens at payout time with fluctuating rates, the
GETresponse avoids single-currency aggregates and instead returns:earned: [{currency, amount}]— per-currency breakdown of amounts earned from referrals (sum of first payments per referred VM, grouped by currency)payouts: [...]— full payout history line-by-line (includesinvoice,is_paid, etc.)referrals_success/referrals_failed— referral countsCode Generation
Referral codes are 8 random bytes each mapped to a 63-char alphabet (
A-Za-z0-9_).Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.