Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add bolt11 invoice string to sent stored payments #209

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backup-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backup-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backup-server",
"version": "0.0.129",
"version": "0.0.130",
"description": "",
"main": "index.js",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ PODS:
- React-jsinspector (0.72.4)
- React-logger (0.72.4):
- glog
- react-native-ldk (0.0.128):
- react-native-ldk (0.0.130):
- React
- react-native-randombytes (3.6.1):
- React-Core
Expand Down Expand Up @@ -723,7 +723,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: c7f826e40fa9cab5d37cab6130b1af237332b594
React-jsinspector: aaed4cf551c4a1c98092436518c2d267b13a673f
React-logger: da1ebe05ae06eb6db4b162202faeafac4b435e77
react-native-ldk: 7e754f4168e774326eaf2f0707843f5ce06f70bb
react-native-ldk: 70917f83fc99eab2fbd6df0edbd7ebd217bad7ea
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-tcp-socket: c1b7297619616b4c9caae6889bcb0aba78086989
React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f
Expand Down
3 changes: 2 additions & 1 deletion lib/android/src/main/java/com/reactnativeldk/LdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
UtilMethods.pay_invoice(invoice, Retry.timeout(timeoutSeconds.toLong()), channelManager)
if (res.is_ok) {
channelManagerPersister.persistPaymentSent(hashMapOf(
"bolt11_invoice" to paymentRequest,
"payment_id" to (res as Result_ThirtyTwoBytesPaymentErrorZ.Result_ThirtyTwoBytesPaymentErrorZ_OK).res.hexEncodedString(),
"payment_hash" to invoice.payment_hash().hexEncodedString(),
"amount_sat" to if (isZeroValueInvoice) amountSats.toLong() else ((invoice.amount_milli_satoshis() as Option_u64Z.Some).some.toInt() / 1000),
Expand Down Expand Up @@ -859,7 +860,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
description,
expiryDelta.toInt(),
Option_u16Z.none()
);
)

if (res.is_ok) {
return promise.resolve((res as Result_Bolt11InvoiceSignOrCreationErrorZ_OK).res.asJson)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
body.putHexString("payment_hash", (paymentPathSuccessful.payment_hash as Option_ThirtyTwoBytesZ.Some).some)

val pathHops = Arguments.createArray()
println(paymentPathSuccessful.path)
event.path._hops.forEach { pathHops.pushMap(it.asJson) }
body.putArray("path_hops", pathHops)

return LdkEventEmitter.send(EventTypes.channel_manager_payment_path_successful, body)
Expand Down
1 change: 1 addition & 0 deletions lib/ios/Ldk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ class Ldk: NSObject {

if res.isOk() {
channelManagerPersister.persistPaymentSent([
"bolt11_invoice": String(paymentRequest),
"payment_id": Data(res.getValue() ?? []).hexEncodedString(),
"payment_hash": Data(invoice.paymentHash() ?? []).hexEncodedString(),
"amount_sat": isZeroValueInvoice ? amountSats : (invoice.amountMilliSatoshis() ?? 0) / 1000,
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@synonymdev/react-native-ldk",
"title": "React Native LDK",
"version": "0.0.129",
"version": "0.0.130",
"description": "React Native wrapper for LDK",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions lib/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type TChannelManagerClaim = {
};

export type TChannelManagerPaymentSent = {
bolt11_invoice?: string;
payment_id: string;
payment_preimage?: string;
payment_hash: string;
Expand Down
Loading