Skip to content

Commit

Permalink
Merge pull request #146 from getAlby/task-custom-keysend
Browse files Browse the repository at this point in the history
fix: remove custom key value
  • Loading branch information
im-adithya authored Mar 28, 2024
2 parents 37eb0be + a0de979 commit a18ac93
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/utils/keysend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a18ac93

Please sign in to comment.