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

chore: removing description hash #3647

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
11 changes: 0 additions & 11 deletions apps/pay/app/lnurlp/[username]/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ gql`
mutation lnInvoiceCreateOnBehalfOfRecipient(
$walletId: WalletId!
$amount: SatAmount!
$descriptionHash: Hex32Bytes!
) {
mutationData: lnInvoiceCreateOnBehalfOfRecipient(
input: {
recipientWalletId: $walletId
amount: $amount
descriptionHash: $descriptionHash
}
) {
errors {
Expand Down Expand Up @@ -136,20 +134,11 @@ export async function GET(
})
}

let descriptionHash: string

if (nostrEnabled && nostr) {
descriptionHash = crypto.createHash("sha256").update(nostr).digest("hex")
} else {
descriptionHash = crypto.createHash("sha256").update(metadata).digest("hex")
}

const result = await client.mutate<LnInvoiceCreateOnBehalfOfRecipientMutation>({
mutation: LnInvoiceCreateOnBehalfOfRecipientDocument,
variables: {
walletId,
amount: amountSats,
descriptionHash,
},
})

Expand Down
6 changes: 1 addition & 5 deletions core/api/src/app/wallets/add-invoice-for-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ const addInvoiceForRecipient = async ({
recipientWalletId,
walletAmount,
memo = "",
descriptionHash,
expiresIn,
}: AddInvoiceForRecipientArgs): Promise<WalletInvoice | ApplicationError> =>
addInvoice({
Expand All @@ -127,7 +126,7 @@ const addInvoiceForRecipient = async ({
recipientWalletDescriptor,
}: BuildWIBWithAmountFnArgs) =>
walletInvoiceBuilder
.withDescription({ description: memo, descriptionHash })
.withDescription({ description: memo })
.generatedForRecipient()
.withRecipientWallet(recipientWalletDescriptor)
.withExpiration(expiresIn)
Expand All @@ -153,7 +152,6 @@ export const addInvoiceForRecipientForBtcWallet = async (
recipientWalletId,
walletAmount,
expiresIn,
descriptionHash: args.descriptionHash,
memo: args.memo,
})
}
Expand All @@ -177,7 +175,6 @@ export const addInvoiceForRecipientForUsdWallet = async (
recipientWalletId,
walletAmount,
expiresIn,
descriptionHash: args.descriptionHash,
memo: args.memo,
})
}
Expand All @@ -201,7 +198,6 @@ export const addInvoiceForRecipientForUsdWalletAndBtcAmount = async (
recipientWalletId,
walletAmount,
expiresIn,
descriptionHash: args.descriptionHash,
memo: args.memo,
})
}
Expand Down
2 changes: 0 additions & 2 deletions core/api/src/app/wallets/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ type AddInvoiceForRecipientArgs = {
recipientWalletId: WalletId
walletAmount: PaymentAmount<WalletCurrency>
memo?: string
descriptionHash?: string
expiresIn: Minutes
}

type AddInvoiceForRecipientForBtcWalletArgs = {
recipientWalletId: string
amount: number
memo?: string
descriptionHash?: string
expiresIn?: number
}

Expand Down
3 changes: 0 additions & 3 deletions core/api/src/domain/bitcoin/lightning/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,20 @@ type LnInvoice = {
type RegisterInvoiceArgs = {
paymentHash: PaymentHash
description: string
descriptionHash?: string
sats: Satoshis
expiresAt: InvoiceExpiration
}

type NewRegisterInvoiceArgs = {
paymentHash: PaymentHash
description: string
descriptionHash?: string
btcPaymentAmount: BtcPaymentAmount
expiresAt: InvoiceExpiration
}

type RegisteredInvoice = {
invoice: LnInvoice
pubkey: Pubkey
descriptionHash?: string // TODO: proper type
}

type PayInvoiceResult = {
Expand Down
9 changes: 1 addition & 8 deletions core/api/src/domain/wallet-invoices/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,11 @@ type WalletInvoiceBuilderConfig = {
}

type WalletInvoiceBuilder = {
withDescription: ({
description,
descriptionHash,
}: {
description: string
descriptionHash?: string
}) => WIBWithDescription
withDescription: ({ description }: { description: string }) => WIBWithDescription
}

type WIBWithDescriptionState = WalletInvoiceBuilderConfig & {
description: string
descriptionHash?: string
}

type WIBWithDescription = {
Expand Down
10 changes: 1 addition & 9 deletions core/api/src/domain/wallet-invoices/wallet-invoice-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ import { toSeconds } from "@/domain/primitives"
export const WalletInvoiceBuilder = (
config: WalletInvoiceBuilderConfig,
): WalletInvoiceBuilder => {
const withDescription = ({
description,
descriptionHash,
}: {
description: string
descriptionHash?: string
}) => {
const withDescription = ({ description }: { description: string }) => {
return WIBWithDescription({
...config,
description,
descriptionHash,
})
}

Expand Down Expand Up @@ -134,7 +127,6 @@ export const WIBWithAmount = (state: WIBWithAmountState): WIBWithAmount => {
const registeredInvoice = await state.lnRegisterInvoice({
paymentHash,
description: state.description,
descriptionHash: state.descriptionHash,
btcPaymentAmount: state.btcAmount,
expiresAt: state.invoiceExpiration,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const LnInvoiceCreateOnBehalfOfRecipientInput = GT.Input({
},
amount: { type: GT.NonNull(SatAmount), description: "Amount in satoshis." },
memo: { type: Memo, description: "Optional memo for the lightning invoice." },
descriptionHash: { type: Hex32Bytes },
expiresIn: {
type: Minutes,
description: "Optional invoice expiration time in minutes.",
Expand All @@ -40,8 +39,8 @@ const LnInvoiceCreateOnBehalfOfRecipientMutation = GT.Field({
input: { type: GT.NonNull(LnInvoiceCreateOnBehalfOfRecipientInput) },
},
resolve: async (_, args) => {
const { recipientWalletId, amount, memo, descriptionHash, expiresIn } = args.input
for (const input of [recipientWalletId, amount, memo, descriptionHash, expiresIn]) {
const { recipientWalletId, amount, memo, expiresIn } = args.input
for (const input of [recipientWalletId, amount, memo, expiresIn]) {
if (input instanceof Error) {
return { errors: [{ message: input.message }] }
}
Expand All @@ -51,7 +50,7 @@ const LnInvoiceCreateOnBehalfOfRecipientMutation = GT.Field({
recipientWalletId,
amount,
memo,
descriptionHash,

expiresIn,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const LnUsdInvoiceBtcDenominatedCreateOnBehalfOfRecipientInput = GT.Input({
description:
"Optional memo for the lightning invoice. Acts as a note to the recipient.",
},
descriptionHash: { type: Hex32Bytes },
expiresIn: {
type: Minutes,
description: "Optional invoice expiration time in minutes.",
Expand All @@ -47,8 +46,8 @@ const LnUsdInvoiceBtcDenominatedCreateOnBehalfOfRecipientMutation = GT.Field({
},
},
resolve: async (_, args) => {
const { recipientWalletId, amount, memo, descriptionHash, expiresIn } = args.input
for (const input of [recipientWalletId, amount, memo, descriptionHash, expiresIn]) {
const { recipientWalletId, amount, memo, expiresIn } = args.input
for (const input of [recipientWalletId, amount, memo, expiresIn]) {
if (input instanceof Error) {
return { errors: [{ message: input.message }] }
}
Expand All @@ -58,7 +57,6 @@ const LnUsdInvoiceBtcDenominatedCreateOnBehalfOfRecipientMutation = GT.Field({
recipientWalletId,
amount,
memo,
descriptionHash,
expiresIn,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const LnUsdInvoiceCreateOnBehalfOfRecipientInput = GT.Input({
description:
"Optional memo for the lightning invoice. Acts as a note to the recipient.",
},
descriptionHash: { type: Hex32Bytes },
expiresIn: {
type: Minutes,
description: "Optional invoice expiration time in minutes.",
Expand All @@ -45,8 +44,8 @@ const LnUsdInvoiceCreateOnBehalfOfRecipientMutation = GT.Field({
input: { type: GT.NonNull(LnUsdInvoiceCreateOnBehalfOfRecipientInput) },
},
resolve: async (_, args) => {
const { recipientWalletId, amount, memo, descriptionHash, expiresIn } = args.input
for (const input of [recipientWalletId, amount, memo, descriptionHash, expiresIn]) {
const { recipientWalletId, amount, memo, expiresIn } = args.input
for (const input of [recipientWalletId, amount, memo, expiresIn]) {
if (input instanceof Error) {
return { errors: [{ message: input.message }] }
}
Expand All @@ -56,7 +55,7 @@ const LnUsdInvoiceCreateOnBehalfOfRecipientMutation = GT.Field({
recipientWalletId,
amount,
memo,
descriptionHash,

expiresIn,
})

Expand Down
6 changes: 0 additions & 6 deletions core/api/src/graphql/public/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,6 @@ type GraphQLApplicationError implements Error {
path: [String]
}

"""Hex-encoded string of 32 bytes"""
scalar Hex32Bytes

union InitiationVia = InitiationViaIntraLedger | InitiationViaLn | InitiationViaOnChain

type InitiationViaIntraLedger {
Expand Down Expand Up @@ -544,7 +541,6 @@ input LnInvoiceCreateInput {
input LnInvoiceCreateOnBehalfOfRecipientInput {
"""Amount in satoshis."""
amount: SatAmount!
descriptionHash: Hex32Bytes

"""Optional invoice expiration time in minutes."""
expiresIn: Minutes
Expand Down Expand Up @@ -688,7 +684,6 @@ type LnUpdate {
input LnUsdInvoiceBtcDenominatedCreateOnBehalfOfRecipientInput {
"""Amount in satoshis."""
amount: SatAmount!
descriptionHash: Hex32Bytes

"""Optional invoice expiration time in minutes."""
expiresIn: Minutes
Expand Down Expand Up @@ -719,7 +714,6 @@ input LnUsdInvoiceCreateInput {
input LnUsdInvoiceCreateOnBehalfOfRecipientInput {
"""Amount in USD cents."""
amount: CentAmount!
descriptionHash: Hex32Bytes

"""Optional invoice expiration time in minutes."""
expiresIn: Minutes
Expand Down
4 changes: 0 additions & 4 deletions core/api/src/services/lnd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ export const LndService = (): ILightningService | LightningServiceError => {
paymentHash,
sats,
description,
descriptionHash,
expiresAt,
}: RegisterInvoiceArgs & { lnd: AuthenticatedLnd }): Promise<
RegisteredInvoice | LightningServiceError
Expand All @@ -500,7 +499,6 @@ export const LndService = (): ILightningService | LightningServiceError => {
lnd,
id: paymentHash,
description,
description_hash: descriptionHash,
tokens: sats as number,
expires_at: expiresAt.toISOString(),
}
Expand All @@ -526,7 +524,6 @@ export const LndService = (): ILightningService | LightningServiceError => {
paymentHash,
sats,
description,
descriptionHash,
expiresAt,
}: RegisterInvoiceArgs): Promise<RegisteredInvoice | LightningServiceError> => {
const lnds = listActiveLnd()
Expand All @@ -536,7 +533,6 @@ export const LndService = (): ILightningService | LightningServiceError => {
paymentHash,
sats,
description,
descriptionHash,
expiresAt,
})
if (isConnectionError(result)) continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe("WalletInvoiceBuilder", () => {
const invoice: RegisteredInvoice = {
invoice: lnInvoice,
pubkey: "pubkey" as Pubkey,
descriptionHash: args.descriptionHash,
}

return invoice
Expand Down
Loading