diff --git a/src/utils/keysend.ts b/src/utils/keysend.ts index ebde7b7..90b899b 100644 --- a/src/utils/keysend.ts +++ b/src/utils/keysend.ts @@ -5,31 +5,22 @@ const TAG_KEYSEND = "keysend"; export type KeySendRawData = { tag: string; status: string; - customData: { customKey: string; customValue: string }[]; + customData?: { customKey?: string; customValue?: string }[]; pubkey: string; }; export const parseKeysendResponse = (data: KeySendRawData): KeysendResponse => { if (data.tag !== TAG_KEYSEND) throw new Error("Invalid keysend params"); if (data.status !== "OK") throw new Error("Keysend status not OK"); - - if ( - !("customKey" in data.customData[0]) || - data.customData[0]["customKey"] != "696969" - ) - throw new Error("Unable to find customKey"); - - if ( - !("customValue" in data.customData[0]) || - !data.customData[0]["customValue"] - ) - throw new Error("Unable to find customValue"); - if (!data.pubkey) throw new Error("Pubkey does not exist"); const destination = data.pubkey; - const customKey = data.customData[0]["customKey"]; - const customValue = data.customData[0]["customValue"]; + let customKey, customValue; + + if (data.customData && data.customData[0]) { + customKey = data.customData[0].customKey; + customValue = data.customData[0].customValue; + } return { destination,