Skip to content

Commit

Permalink
Merge pull request #104 from getlipa/feature/implement-registration-o…
Browse files Browse the repository at this point in the history
…f-lnurlp-invoices

Implement submission of LNURLp invoices
  • Loading branch information
danielgranhao authored May 16, 2024
2 parents 9bec325 + 6c4fd09 commit adf19cb
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ important analytics data about payments to the backend. This data is pseudonymiz

## Pigeon
Pigeons excel in orientation and have a remarkable ability to navigate addresses.
The library allows to register Lightning addresses.
The library allows to register Lightning addresses and processing incoming payments sent to a Lightning address.
4 changes: 4 additions & 0 deletions graphql/schemas/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,7 @@ mutation AssignLightningAddress {
assignedAt
}
}

mutation SubmitLnurlPayInvoice($id: String!, $invoice: String!) {
submit_lnurl_pay_invoice(id: $id, invoice: $invoice)
}
87 changes: 53 additions & 34 deletions graphql/schemas/schema_wallet_read.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Updated at 2024-02-23_11:14:36
# Hasura Role: WALLET_READ

schema {
query: query_root
mutation: mutation_root
Expand All @@ -16,6 +13,19 @@ directive @cached(
refresh: Boolean! = false
) on QUERY

input AcceptTermsConditionsV2Input {
fingerprint: String!
service: Service
version: Int!
}

type AcceptTermsConditionsV2Response {
acceptDate: DateTime
accepted: Boolean!
service: Service!
version: Int!
}

type AcceptTermsResponse {
acceptDate: DateTime
acceptedTerms: Boolean!
Expand Down Expand Up @@ -68,6 +78,17 @@ type GetTermsConditionsStatusResponse {
version: Int!
}

input GetTermsConditionsStatusV2Input {
service: Service
}

type GetTermsConditionsStatusV2Response {
acceptDate: DateTime
accepted: Boolean!
service: Service!
version: Int!
}

type LightningAddressResponse {
address: String!
assignedAt: DateTime!
Expand Down Expand Up @@ -157,6 +178,11 @@ input RequestSucceededInput {
paymentReceivedAt: DateTime!
}

enum Service {
LIPA_WALLET
POCKET_EXCHANGE
}

enum ServiceProviderEnum {
LIPA_WALLET
POCKET_EXCHANGE
Expand Down Expand Up @@ -238,6 +264,8 @@ type TokenContainer {
refreshToken: String
}

scalar Void

type WalletAcl {
accessExpiresAt: DateTime
displayName: String
Expand All @@ -254,16 +282,6 @@ type WalletConfiguration {
pubKeyId: String
}

type WalletEmail {
email: String
walletPubKeyId: String
}

type WalletNode {
nodePubKey: String
walletPubKeyId: String
}

input accept_terms_args {
pubkey_id: uuid
}
Expand All @@ -273,8 +291,8 @@ columns and relationships of "accepted_terms_conditions"
"""
type accepted_terms_conditions {
acceptDate: timestamptz
acceptedTerms: Boolean!
serviceProvider: service_provider_enum!
accepted: Boolean!
service: service_enum!
}

"""
Expand All @@ -285,16 +303,16 @@ input accepted_terms_conditions_bool_exp {
_not: accepted_terms_conditions_bool_exp
_or: [accepted_terms_conditions_bool_exp!]
acceptDate: timestamptz_comparison_exp
acceptedTerms: Boolean_comparison_exp
serviceProvider: service_provider_enum_comparison_exp
accepted: Boolean_comparison_exp
service: service_enum_comparison_exp
}

"""
unique or primary key constraints on table "accepted_terms_conditions"
"""
enum accepted_terms_conditions_constraint {
"""
unique or primary key constraint on columns "serviceProvider", "id"
unique or primary key constraint on columns "id", "service"
"""
accepted_terms_conditions_pkey
}
Expand All @@ -303,7 +321,7 @@ enum accepted_terms_conditions_constraint {
input type for inserting data into table "accepted_terms_conditions"
"""
input accepted_terms_conditions_insert_input {
serviceProvider: service_provider_enum
service: service_enum
}

"""
Expand All @@ -329,8 +347,8 @@ input accepted_terms_conditions_on_conflict {
"""Ordering options when selecting data from "accepted_terms_conditions"."""
input accepted_terms_conditions_order_by {
acceptDate: order_by
acceptedTerms: order_by
serviceProvider: order_by
accepted: order_by
service: order_by
}

"""
Expand All @@ -341,10 +359,10 @@ enum accepted_terms_conditions_select_column {
acceptDate

"""column name"""
acceptedTerms
accepted

"""column name"""
serviceProvider
service
}

"""
Expand All @@ -361,8 +379,8 @@ input accepted_terms_conditions_stream_cursor_input {
"""Initial value of the column from where the streaming should start"""
input accepted_terms_conditions_stream_cursor_value_input {
acceptDate: timestamptz
acceptedTerms: Boolean
serviceProvider: service_provider_enum
accepted: Boolean
service: service_enum
}

"""
Expand Down Expand Up @@ -672,6 +690,7 @@ type mutation_root {
where: accepted_terms_conditions_bool_exp
): accepted_terms_conditions
accept_terms_conditions(args: ServiceProviderInputInput): AcceptTermsResponse
accept_terms_conditions_v2(args: AcceptTermsConditionsV2Input): AcceptTermsConditionsV2Response
accept_wallet_acl_by_pk(pk_columns: AcceptWalletPkRequestInput!): WalletAcl
assign_lightning_address: LightningAddressResponse
create_backup(encryptedBackup: String!, schemaName: String!, schemaVersion: String!): CreateBackupResponse
Expand Down Expand Up @@ -702,15 +721,14 @@ type mutation_root {
recover_backup(schemaName: String!): RecoverBackupResponse
refresh_session(refreshToken: String!): TokenContainer
refresh_session_v2(refreshToken: String!): SessionPermit
register_email(email: String): WalletEmail
register_node(nodePubKey: String): WalletNode
register_notification_token(language: String!, notificationToken: String!): Token
register_topup(email: String, orderId: String!): RegisterTopupResponse
report_payment_telemetry(events: PaymentTelemetryEventsInput, telemetryId: String!): ReportPaymentTelemetryResponse
start_prepared_session(challenge: String!, challengeSignature: String!, challengeSignatureType: ChallengeSignatureType, preparedPermissionToken: String!): TokenContainer
start_prepared_session_v2(challenge: String!, challengeSignature: String!, challengeSignatureType: ChallengeSignatureType, preparedPermissionToken: String!): SessionPermit
start_session(authPubKey: String!, challenge: String!, challengeSignature: String!, challengeSignatureType: ChallengeSignatureType, signedAuthPubKey: String!, walletPubKey: String!): TokenContainer
start_session_v2(authPubKey: String!, challenge: String!, challengeSignature: String!, challengeSignatureType: ChallengeSignatureType, signedAuthPubKey: String!, walletPubKey: String!): SessionPermit
submit_lnurl_pay_invoice(id: String!, invoice: String!): Void
}

scalar numeric
Expand Down Expand Up @@ -824,6 +842,7 @@ type query_root {
currencyCode: String!
): currency
get_terms_conditions_status(args: GetTermsConditionsStatusInputInput): GetTermsConditionsStatusResponse
get_terms_conditions_status_v2(args: GetTermsConditionsStatusV2Input): GetTermsConditionsStatusV2Response

"""
fetch data from the table: "lightning_address"
Expand Down Expand Up @@ -921,20 +940,20 @@ type query_root {
wallet_acl_by_pk(id: uuid!): wallet_acl
}

enum service_provider_enum {
enum service_enum {
LIPA_WALLET
POCKET_EXCHANGE
}

"""
Boolean expression to compare columns of type "service_provider_enum". All fields are combined with logical 'AND'.
Boolean expression to compare columns of type "service_enum". All fields are combined with logical 'AND'.
"""
input service_provider_enum_comparison_exp {
_eq: service_provider_enum
_in: [service_provider_enum!]
input service_enum_comparison_exp {
_eq: service_enum
_in: [service_enum!]
_is_null: Boolean
_neq: service_provider_enum
_nin: [service_provider_enum!]
_neq: service_enum
_nin: [service_enum!]
}

type subscription_root {
Expand Down
9 changes: 9 additions & 0 deletions graphql/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type numeric = float8;
type timestamptz = String;
#[allow(non_camel_case_types)]
type uuid = String;
type Void = ();

#[derive(GraphQLQuery)]
#[graphql(
Expand Down Expand Up @@ -181,3 +182,11 @@ pub struct ReportPaymentTelemetry;
response_derives = "Debug"
)]
pub struct AssignLightningAddress;

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "schemas/schema_wallet_read.graphql",
query_path = "schemas/operations.graphql",
response_derives = "Debug"
)]
pub struct SubmitLnurlPayInvoice;
22 changes: 21 additions & 1 deletion pigeon/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use graphql::perro::OptionToError;
use graphql::schema::{assign_lightning_address, AssignLightningAddress};
use graphql::schema::{
assign_lightning_address, submit_lnurl_pay_invoice, AssignLightningAddress,
SubmitLnurlPayInvoice,
};
use graphql::{build_async_client, post};
use honeybadger::asynchronous::Auth;

Expand All @@ -18,3 +21,20 @@ pub async fn assign_lightning_address(backend_url: &str, auth: &Auth) -> graphql
.address;
Ok(address)
}

pub async fn submit_lnurl_pay_invoice(
backend_url: &str,
auth: &Auth,
id: String,
invoice: String,
) -> graphql::Result<()> {
let token = auth.query_token().await?;
let client = build_async_client(Some(&token))?;
let _data = post::<SubmitLnurlPayInvoice>(
&client,
backend_url,
submit_lnurl_pay_invoice::Variables { id, invoice },
)
.await?;
Ok(())
}

0 comments on commit adf19cb

Please sign in to comment.