Skip to content

Commit adf19cb

Browse files
Merge pull request #104 from getlipa/feature/implement-registration-of-lnurlp-invoices
Implement submission of LNURLp invoices
2 parents 9bec325 + 6c4fd09 commit adf19cb

File tree

5 files changed

+88
-36
lines changed

5 files changed

+88
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ important analytics data about payments to the backend. This data is pseudonymiz
2525

2626
## Pigeon
2727
Pigeons excel in orientation and have a remarkable ability to navigate addresses.
28-
The library allows to register Lightning addresses.
28+
The library allows to register Lightning addresses and processing incoming payments sent to a Lightning address.

graphql/schemas/operations.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,7 @@ mutation AssignLightningAddress {
164164
assignedAt
165165
}
166166
}
167+
168+
mutation SubmitLnurlPayInvoice($id: String!, $invoice: String!) {
169+
submit_lnurl_pay_invoice(id: $id, invoice: $invoice)
170+
}

graphql/schemas/schema_wallet_read.graphql

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Updated at 2024-02-23_11:14:36
2-
# Hasura Role: WALLET_READ
3-
41
schema {
52
query: query_root
63
mutation: mutation_root
@@ -16,6 +13,19 @@ directive @cached(
1613
refresh: Boolean! = false
1714
) on QUERY
1815

16+
input AcceptTermsConditionsV2Input {
17+
fingerprint: String!
18+
service: Service
19+
version: Int!
20+
}
21+
22+
type AcceptTermsConditionsV2Response {
23+
acceptDate: DateTime
24+
accepted: Boolean!
25+
service: Service!
26+
version: Int!
27+
}
28+
1929
type AcceptTermsResponse {
2030
acceptDate: DateTime
2131
acceptedTerms: Boolean!
@@ -68,6 +78,17 @@ type GetTermsConditionsStatusResponse {
6878
version: Int!
6979
}
7080

81+
input GetTermsConditionsStatusV2Input {
82+
service: Service
83+
}
84+
85+
type GetTermsConditionsStatusV2Response {
86+
acceptDate: DateTime
87+
accepted: Boolean!
88+
service: Service!
89+
version: Int!
90+
}
91+
7192
type LightningAddressResponse {
7293
address: String!
7394
assignedAt: DateTime!
@@ -157,6 +178,11 @@ input RequestSucceededInput {
157178
paymentReceivedAt: DateTime!
158179
}
159180

181+
enum Service {
182+
LIPA_WALLET
183+
POCKET_EXCHANGE
184+
}
185+
160186
enum ServiceProviderEnum {
161187
LIPA_WALLET
162188
POCKET_EXCHANGE
@@ -238,6 +264,8 @@ type TokenContainer {
238264
refreshToken: String
239265
}
240266

267+
scalar Void
268+
241269
type WalletAcl {
242270
accessExpiresAt: DateTime
243271
displayName: String
@@ -254,16 +282,6 @@ type WalletConfiguration {
254282
pubKeyId: String
255283
}
256284

257-
type WalletEmail {
258-
email: String
259-
walletPubKeyId: String
260-
}
261-
262-
type WalletNode {
263-
nodePubKey: String
264-
walletPubKeyId: String
265-
}
266-
267285
input accept_terms_args {
268286
pubkey_id: uuid
269287
}
@@ -273,8 +291,8 @@ columns and relationships of "accepted_terms_conditions"
273291
"""
274292
type accepted_terms_conditions {
275293
acceptDate: timestamptz
276-
acceptedTerms: Boolean!
277-
serviceProvider: service_provider_enum!
294+
accepted: Boolean!
295+
service: service_enum!
278296
}
279297

280298
"""
@@ -285,16 +303,16 @@ input accepted_terms_conditions_bool_exp {
285303
_not: accepted_terms_conditions_bool_exp
286304
_or: [accepted_terms_conditions_bool_exp!]
287305
acceptDate: timestamptz_comparison_exp
288-
acceptedTerms: Boolean_comparison_exp
289-
serviceProvider: service_provider_enum_comparison_exp
306+
accepted: Boolean_comparison_exp
307+
service: service_enum_comparison_exp
290308
}
291309

292310
"""
293311
unique or primary key constraints on table "accepted_terms_conditions"
294312
"""
295313
enum accepted_terms_conditions_constraint {
296314
"""
297-
unique or primary key constraint on columns "serviceProvider", "id"
315+
unique or primary key constraint on columns "id", "service"
298316
"""
299317
accepted_terms_conditions_pkey
300318
}
@@ -303,7 +321,7 @@ enum accepted_terms_conditions_constraint {
303321
input type for inserting data into table "accepted_terms_conditions"
304322
"""
305323
input accepted_terms_conditions_insert_input {
306-
serviceProvider: service_provider_enum
324+
service: service_enum
307325
}
308326

309327
"""
@@ -329,8 +347,8 @@ input accepted_terms_conditions_on_conflict {
329347
"""Ordering options when selecting data from "accepted_terms_conditions"."""
330348
input accepted_terms_conditions_order_by {
331349
acceptDate: order_by
332-
acceptedTerms: order_by
333-
serviceProvider: order_by
350+
accepted: order_by
351+
service: order_by
334352
}
335353

336354
"""
@@ -341,10 +359,10 @@ enum accepted_terms_conditions_select_column {
341359
acceptDate
342360

343361
"""column name"""
344-
acceptedTerms
362+
accepted
345363

346364
"""column name"""
347-
serviceProvider
365+
service
348366
}
349367

350368
"""
@@ -361,8 +379,8 @@ input accepted_terms_conditions_stream_cursor_input {
361379
"""Initial value of the column from where the streaming should start"""
362380
input accepted_terms_conditions_stream_cursor_value_input {
363381
acceptDate: timestamptz
364-
acceptedTerms: Boolean
365-
serviceProvider: service_provider_enum
382+
accepted: Boolean
383+
service: service_enum
366384
}
367385

368386
"""
@@ -672,6 +690,7 @@ type mutation_root {
672690
where: accepted_terms_conditions_bool_exp
673691
): accepted_terms_conditions
674692
accept_terms_conditions(args: ServiceProviderInputInput): AcceptTermsResponse
693+
accept_terms_conditions_v2(args: AcceptTermsConditionsV2Input): AcceptTermsConditionsV2Response
675694
accept_wallet_acl_by_pk(pk_columns: AcceptWalletPkRequestInput!): WalletAcl
676695
assign_lightning_address: LightningAddressResponse
677696
create_backup(encryptedBackup: String!, schemaName: String!, schemaVersion: String!): CreateBackupResponse
@@ -702,15 +721,14 @@ type mutation_root {
702721
recover_backup(schemaName: String!): RecoverBackupResponse
703722
refresh_session(refreshToken: String!): TokenContainer
704723
refresh_session_v2(refreshToken: String!): SessionPermit
705-
register_email(email: String): WalletEmail
706-
register_node(nodePubKey: String): WalletNode
707724
register_notification_token(language: String!, notificationToken: String!): Token
708725
register_topup(email: String, orderId: String!): RegisterTopupResponse
709726
report_payment_telemetry(events: PaymentTelemetryEventsInput, telemetryId: String!): ReportPaymentTelemetryResponse
710727
start_prepared_session(challenge: String!, challengeSignature: String!, challengeSignatureType: ChallengeSignatureType, preparedPermissionToken: String!): TokenContainer
711728
start_prepared_session_v2(challenge: String!, challengeSignature: String!, challengeSignatureType: ChallengeSignatureType, preparedPermissionToken: String!): SessionPermit
712729
start_session(authPubKey: String!, challenge: String!, challengeSignature: String!, challengeSignatureType: ChallengeSignatureType, signedAuthPubKey: String!, walletPubKey: String!): TokenContainer
713730
start_session_v2(authPubKey: String!, challenge: String!, challengeSignature: String!, challengeSignatureType: ChallengeSignatureType, signedAuthPubKey: String!, walletPubKey: String!): SessionPermit
731+
submit_lnurl_pay_invoice(id: String!, invoice: String!): Void
714732
}
715733

716734
scalar numeric
@@ -824,6 +842,7 @@ type query_root {
824842
currencyCode: String!
825843
): currency
826844
get_terms_conditions_status(args: GetTermsConditionsStatusInputInput): GetTermsConditionsStatusResponse
845+
get_terms_conditions_status_v2(args: GetTermsConditionsStatusV2Input): GetTermsConditionsStatusV2Response
827846

828847
"""
829848
fetch data from the table: "lightning_address"
@@ -921,20 +940,20 @@ type query_root {
921940
wallet_acl_by_pk(id: uuid!): wallet_acl
922941
}
923942

924-
enum service_provider_enum {
943+
enum service_enum {
925944
LIPA_WALLET
926945
POCKET_EXCHANGE
927946
}
928947

929948
"""
930-
Boolean expression to compare columns of type "service_provider_enum". All fields are combined with logical 'AND'.
949+
Boolean expression to compare columns of type "service_enum". All fields are combined with logical 'AND'.
931950
"""
932-
input service_provider_enum_comparison_exp {
933-
_eq: service_provider_enum
934-
_in: [service_provider_enum!]
951+
input service_enum_comparison_exp {
952+
_eq: service_enum
953+
_in: [service_enum!]
935954
_is_null: Boolean
936-
_neq: service_provider_enum
937-
_nin: [service_provider_enum!]
955+
_neq: service_enum
956+
_nin: [service_enum!]
938957
}
939958

940959
type subscription_root {

graphql/src/schema.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type numeric = float8;
77
type timestamptz = String;
88
#[allow(non_camel_case_types)]
99
type uuid = String;
10+
type Void = ();
1011

1112
#[derive(GraphQLQuery)]
1213
#[graphql(
@@ -181,3 +182,11 @@ pub struct ReportPaymentTelemetry;
181182
response_derives = "Debug"
182183
)]
183184
pub struct AssignLightningAddress;
185+
186+
#[derive(GraphQLQuery)]
187+
#[graphql(
188+
schema_path = "schemas/schema_wallet_read.graphql",
189+
query_path = "schemas/operations.graphql",
190+
response_derives = "Debug"
191+
)]
192+
pub struct SubmitLnurlPayInvoice;

pigeon/src/lib.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use graphql::perro::OptionToError;
2-
use graphql::schema::{assign_lightning_address, AssignLightningAddress};
2+
use graphql::schema::{
3+
assign_lightning_address, submit_lnurl_pay_invoice, AssignLightningAddress,
4+
SubmitLnurlPayInvoice,
5+
};
36
use graphql::{build_async_client, post};
47
use honeybadger::asynchronous::Auth;
58

@@ -18,3 +21,20 @@ pub async fn assign_lightning_address(backend_url: &str, auth: &Auth) -> graphql
1821
.address;
1922
Ok(address)
2023
}
24+
25+
pub async fn submit_lnurl_pay_invoice(
26+
backend_url: &str,
27+
auth: &Auth,
28+
id: String,
29+
invoice: String,
30+
) -> graphql::Result<()> {
31+
let token = auth.query_token().await?;
32+
let client = build_async_client(Some(&token))?;
33+
let _data = post::<SubmitLnurlPayInvoice>(
34+
&client,
35+
backend_url,
36+
submit_lnurl_pay_invoice::Variables { id, invoice },
37+
)
38+
.await?;
39+
Ok(())
40+
}

0 commit comments

Comments
 (0)