monerorequest-kotlin is an easy way to create/decode Monero Payment Requests.
monerorequest-kotlin
provides easy-to-use functions for creating and decoding Monero Payment Requests. While the package is not yet available on Maven Central, you can integrate it into your project by following these steps:
-
Download the Source Code:
- Clone this repository or download the source code as a ZIP file.
- Extract and locate the
monerorequest-kotlin
source files (usually found in thesrc
directory).
-
Include in Your Kotlin Project:
- Manually copy the source files into your project's
src
directory, ensuring they are placed within the appropriate package structure.
- Manually copy the source files into your project's
-
Usage:
- After including the library, you can use its primary functions in your project:
makeMoneroPaymentRequest()
: To create a Monero Payment Request.decodeMoneroPaymentRequest()
: To decode an existing Monero Payment Request.
- After including the library, you can use its primary functions in your project:
- To create a Monero Payment Request:
var moneroPaymentRequest = makeMoneroPaymentRequest(
customLabel = "Unlabeled Monero Payment Request",
sellersWallet = "4At3X5rvVypTofgmueN9s9QtrzdRe5BueFrskAZi17BoYbhzysozzoMFB6zWnTKdGC6AxEAbEE5czFR3hbEEJbsm4hCeX2S",
currency = "USD",
amount = "24.99",
paymentId = "0aff662b3151e624",
startDate = "2023-11-15T09:07:59.019Z",
daysPerBillingCycle = 30,
numberOfPayments = 1,
changeIndicatorUrl = "")
println(monero_payment_request
)
- To decode a Monero Payment Request:
var moneroPaymentRequestData = decodeMoneroPaymentRequest(moneroPaymentRequest = "monero-request:1:H4sIAAAAAAAC/y1QyU7DMBD9lcrntkriOFVyS0uKBCqCLlB6sex40kQkdvECJIh/xymc5i0z8zTzjVinnLQoQxGZpymaorJm8gy0kaIpmVWaOt16e3Sc1iDL3rPD7uYqGKs62jIOY8tBXhGIyUZJ0GryyPoOpJ1s4d2BsX5CsN7QC2jKm7Zt5JmWfdkCynAwRdJ13Duqope/OYMyL/8T2ggfEbCqSpKI45CEkESxX2mgbUEb+sl8HQ+Jc4uPRH8895e9qs6dg4fUpE9WD2ILZOlgrc1bfmrCxVK98nrojRoGtVkvk+FF7u/F7SrJv4qcFwUph/UW1x7dcdPF9QqO0W6MtExbKpiF8W9BhGdhMIuSfRBnhGR4MY9jfEI/vzFHmeFdAQAA")
-
A Monero Payment Request looks like this:
monero-request:1:H4sIAAAAAAAC/y1QXVPCMBD8K0yegWmbftC+FQRndHAUiiIvmTS50o5pgkmqto7/3RR9ut3b29u5+0a0VZ20KENBNE9TNEWspvIMpJG8YdQqTTotnDwqndYgWe/YYX9zbRirWiJoCePIQV4R8MlWSdBq8kj7FqSd7OC9A2Odg9PekAtoUjZCNPJMWM8EoAx7UyS7tnSKqsjlz2dQ5k/RPyENdxF+sAjjsEpwxfwkwcytNCAEaEM+qavjIWFu8THSH8/9pVDVue3gITXpk9UD30G07GCjzVt+avxkqV7LeuiNGga13Szj4UUW9/x2Fedf67xcryM2bHa4duiuNG1Yr+AY7MdIS7UlnFoY/+YFeOZ7syAuvCjDi8xP5zEOT+jnF8JbIrJdAQAA
-
When decoded, it is a MutableMap with this information:
{amount=24.99, change_indicator_url=, currency=USD, custom_label=Unlabeled Monero Payment Request, days_per_billing_cycle=0, number_of_payments=0, payment_id=0aff662b3151e624, sellers_wallet=4At3X5rvVypTofgmueN9s9QtrzdRe5BueFrskAZi17BoYbhzysozzoMFB6zWnTKdGC6AxEAbEE5czFR3hbEEJbsm4hCeX2S, start_date=2023-11-15T09:07:59.019Z}
- If
paymentId
is left blank, a random one will be generated. (If you do not want to use a paymentId, set payment_id to0000000000000000
.) - If
startDate
is left blank, the current time will be used. - If
customLabel
is left blank, it will be set toUnlabeled Monero Payment Request
- If
daysPerBillingCycle
is left blank, it will be set to30
- If
numberOfPayments
is left blank, it will be set to1
- If
version
is left blank, the latest version will be used.
- Generate a random payment_id:
makeRandomPaymentId()
- Create an RFC3339 timestamp for
startDate
from a ZonedDateTime object:convertToTruncatedRFC3339(zonedDateTime)
- Print the Monero logo to console:
printMoneroLogo()
- XMR:
4At3X5rvVypTofgmueN9s9QtrzdRe5BueFrskAZi17BoYbhzysozzoMFB6zWnTKdGC6AxEAbEE5czFR3hbEEJbsm4hCeX2S
- BTC:
1ACCQMwHYUkA1v449DvQ9t6dm3yv1enN87
- Cash App:
$LukeProfits
- Java Development Kit (JDK) 8 or above
- Kotlin 1.3 or above (if compiling from source)