Skip to content

Commit

Permalink
chore: add memo to lnurl and lnaddress send mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Aug 28, 2024
1 parent 0d98340 commit 0fac444
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 4 deletions.
4 changes: 4 additions & 0 deletions apps/consent/app/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ export type LnAddressPaymentSendInput = {
readonly amount: Scalars['SatAmount']['input'];
/** Lightning address to send to. */
readonly lnAddress: Scalars['String']['input'];
/** Optional memo to associate with the lightning invoice. */
readonly memo?: InputMaybe<Scalars['Memo']['input']>;
/** Wallet ID to send bitcoin from. */
readonly walletId: Scalars['WalletId']['input'];
};
Expand Down Expand Up @@ -835,6 +837,8 @@ export type LnurlPaymentSendInput = {
readonly amount: Scalars['SatAmount']['input'];
/** Lnurl string to send to. */
readonly lnurl: Scalars['String']['input'];
/** Optional memo to associate with the lightning invoice. */
readonly memo?: InputMaybe<Scalars['Memo']['input']>;
/** Wallet ID to send bitcoin from. */
readonly walletId: Scalars['WalletId']['input'];
};
Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/services/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ export type LnAddressPaymentSendInput = {
readonly amount: Scalars['SatAmount']['input'];
/** Lightning address to send to. */
readonly lnAddress: Scalars['String']['input'];
/** Optional memo to associate with the lightning invoice. */
readonly memo?: InputMaybe<Scalars['Memo']['input']>;
/** Wallet ID to send bitcoin from. */
readonly walletId: Scalars['WalletId']['input'];
};
Expand Down Expand Up @@ -930,6 +932,8 @@ export type LnurlPaymentSendInput = {
readonly amount: Scalars['SatAmount']['input'];
/** Lnurl string to send to. */
readonly lnurl: Scalars['String']['input'];
/** Optional memo to associate with the lightning invoice. */
readonly memo?: InputMaybe<Scalars['Memo']['input']>;
/** Wallet ID to send bitcoin from. */
readonly walletId: Scalars['WalletId']['input'];
};
Expand Down
4 changes: 4 additions & 0 deletions apps/map/services/galoy/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ export type LnAddressPaymentSendInput = {
readonly amount: Scalars['SatAmount']['input'];
/** Lightning address to send to. */
readonly lnAddress: Scalars['String']['input'];
/** Optional memo to associate with the lightning invoice. */
readonly memo?: InputMaybe<Scalars['Memo']['input']>;
/** Wallet ID to send bitcoin from. */
readonly walletId: Scalars['WalletId']['input'];
};
Expand Down Expand Up @@ -835,6 +837,8 @@ export type LnurlPaymentSendInput = {
readonly amount: Scalars['SatAmount']['input'];
/** Lnurl string to send to. */
readonly lnurl: Scalars['String']['input'];
/** Optional memo to associate with the lightning invoice. */
readonly memo?: InputMaybe<Scalars['Memo']['input']>;
/** Wallet ID to send bitcoin from. */
readonly walletId: Scalars['WalletId']['input'];
};
Expand Down
4 changes: 4 additions & 0 deletions apps/pay/lib/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ export type LnAddressPaymentSendInput = {
readonly amount: Scalars['SatAmount'];
/** Lightning address to send to. */
readonly lnAddress: Scalars['String'];
/** Optional memo to associate with the lightning invoice. */
readonly memo?: InputMaybe<Scalars['Memo']>;
/** Wallet ID to send bitcoin from. */
readonly walletId: Scalars['WalletId'];
};
Expand Down Expand Up @@ -834,6 +836,8 @@ export type LnurlPaymentSendInput = {
readonly amount: Scalars['SatAmount'];
/** Lnurl string to send to. */
readonly lnurl: Scalars['String'];
/** Optional memo to associate with the lightning invoice. */
readonly memo?: InputMaybe<Scalars['Memo']>;
/** Wallet ID to send bitcoin from. */
readonly walletId: Scalars['WalletId'];
};
Expand Down
6 changes: 4 additions & 2 deletions core/api/src/app/payments/send-lnurl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const lnAddressPaymentSend = async ({
senderWalletId,
senderAccount,
amount: uncheckedAmount,
memo,
lnAddress,
}: LnAddressPaymentSendArgs): Promise<PaymentSendResult | ApplicationError> => {
const amount = checkedToBtcPaymentAmount(uncheckedAmount)
Expand All @@ -26,7 +27,7 @@ export const lnAddressPaymentSend = async ({

return payInvoiceByWalletId({
uncheckedPaymentRequest: invoice,
memo: null,
memo,
senderWalletId,
senderAccount,
})
Expand All @@ -36,6 +37,7 @@ export const lnurlPaymentSend = async ({
senderWalletId,
senderAccount,
amount: uncheckedAmount,
memo,
lnurl,
}: LnurlPaymentSendArgs): Promise<PaymentSendResult | ApplicationError> => {
const amount = checkedToBtcPaymentAmount(uncheckedAmount)
Expand All @@ -55,7 +57,7 @@ export const lnurlPaymentSend = async ({

return payInvoiceByWalletId({
uncheckedPaymentRequest: invoice,
memo: null,
memo,
senderWalletId,
senderAccount,
})
Expand Down
2 changes: 2 additions & 0 deletions core/api/src/app/wallets/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ type LnAddressPaymentSendArgs = {
senderAccount: Account
lnAddress: string
amount: number
memo: string | null
}

type LnurlPaymentSendArgs = {
senderWalletId: WalletId
senderAccount: Account
lnurl: string
amount: number
memo: string | null
}

type ProcessedReason =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Payments } from "@/app"
import { GT } from "@/graphql/index"
import WalletId from "@/graphql/shared/types/scalar/wallet-id"
import SatAmount from "@/graphql/shared/types/scalar/sat-amount"
import Memo from "@/graphql/shared/types/scalar/memo"
import { mapAndParseErrorForGqlResponse } from "@/graphql/error-map"

const LnAddressPaymentSendInput = GT.Input({
Expand All @@ -21,6 +22,10 @@ const LnAddressPaymentSendInput = GT.Input({
type: GT.NonNull(GT.String),
description: "Lightning address to send to.",
},
memo: {
type: Memo,
description: "Optional memo to associate with the lightning invoice.",
},
}),
})

Expand All @@ -32,6 +37,7 @@ const LnAddressPaymentSendMutation = GT.Field<
walletId: WalletId | InputValidationError
amount: Satoshis | InputValidationError
lnAddress: string | InputValidationError
memo?: string | InputValidationError
}
}
>({
Expand All @@ -44,7 +50,7 @@ const LnAddressPaymentSendMutation = GT.Field<
input: { type: GT.NonNull(LnAddressPaymentSendInput) },
},
resolve: async (_, args, { domainAccount }) => {
const { walletId, amount, lnAddress } = args.input
const { walletId, amount, lnAddress, memo } = args.input
if (lnAddress instanceof Error) {
return { errors: [{ message: lnAddress.message }] }
}
Expand All @@ -57,11 +63,16 @@ const LnAddressPaymentSendMutation = GT.Field<
return { errors: [{ message: walletId.message }] }
}

if (memo instanceof Error) {
return { errors: [{ message: memo.message }] }
}

const result = await Payments.lnAddressPaymentSend({
lnAddress,
amount,
senderWalletId: walletId,
senderAccount: domainAccount,
memo: memo ?? null,
})

if (result instanceof Error) {
Expand Down
13 changes: 12 additions & 1 deletion core/api/src/graphql/public/root/mutation/lnurl-payment-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Payments } from "@/app"
import { GT } from "@/graphql/index"
import WalletId from "@/graphql/shared/types/scalar/wallet-id"
import SatAmount from "@/graphql/shared/types/scalar/sat-amount"
import Memo from "@/graphql/shared/types/scalar/memo"
import { mapAndParseErrorForGqlResponse } from "@/graphql/error-map"

const LnurlPaymentSendInput = GT.Input({
Expand All @@ -21,6 +22,10 @@ const LnurlPaymentSendInput = GT.Input({
type: GT.NonNull(GT.String),
description: "Lnurl string to send to.",
},
memo: {
type: Memo,
description: "Optional memo to associate with the lightning invoice.",
},
}),
})

Expand All @@ -32,6 +37,7 @@ const LnurlPaymentSendMutation = GT.Field<
walletId: WalletId | InputValidationError
amount: Satoshis | InputValidationError
lnurl: string | InputValidationError
memo?: string | InputValidationError
}
}
>({
Expand All @@ -44,7 +50,7 @@ const LnurlPaymentSendMutation = GT.Field<
input: { type: GT.NonNull(LnurlPaymentSendInput) },
},
resolve: async (_, args, { domainAccount }) => {
const { walletId, amount, lnurl } = args.input
const { walletId, amount, lnurl, memo } = args.input
if (lnurl instanceof Error) {
return { errors: [{ message: lnurl.message }] }
}
Expand All @@ -57,11 +63,16 @@ const LnurlPaymentSendMutation = GT.Field<
return { errors: [{ message: walletId.message }] }
}

if (memo instanceof Error) {
return { errors: [{ message: memo.message }] }
}

const result = await Payments.lnurlPaymentSend({
lnurl,
amount,
senderWalletId: walletId,
senderAccount: domainAccount,
memo: memo ?? null,
})

if (result instanceof Error) {
Expand Down
6 changes: 6 additions & 0 deletions core/api/src/graphql/public/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ input LnAddressPaymentSendInput {
"""Lightning address to send to."""
lnAddress: String!

"""Optional memo to associate with the lightning invoice."""
memo: Memo

"""Wallet ID to send bitcoin from."""
walletId: WalletId!
}
Expand Down Expand Up @@ -817,6 +820,9 @@ input LnurlPaymentSendInput {
"""Lnurl string to send to."""
lnurl: String!

"""Optional memo to associate with the lightning invoice."""
memo: Memo

"""Wallet ID to send bitcoin from."""
walletId: WalletId!
}
Expand Down
6 changes: 6 additions & 0 deletions dev/config/apollo-federation/supergraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,9 @@ input LnAddressPaymentSendInput
"""Lightning address to send to."""
lnAddress: String!

"""Optional memo to associate with the lightning invoice."""
memo: Memo

"""Wallet ID to send bitcoin from."""
walletId: WalletId!
}
Expand Down Expand Up @@ -1074,6 +1077,9 @@ input LnurlPaymentSendInput
"""Lnurl string to send to."""
lnurl: String!

"""Optional memo to associate with the lightning invoice."""
memo: Memo

"""Wallet ID to send bitcoin from."""
walletId: WalletId!
}
Expand Down

0 comments on commit 0fac444

Please sign in to comment.