Skip to content

Commit

Permalink
feat: getinfo and keysend methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanjoshi914 committed Dec 19, 2023
1 parent 687547f commit 7b1b03a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"dependencies": {
"@bitcoin-design/bitcoin-icons-react": "^0.1.10",
"@bitcoinerlab/secp256k1": "^1.0.5",
"@getalby/sdk": "^3.1.0",
"@getalby/sdk": "^3.2.0",
"@headlessui/react": "^1.7.16",
"@lightninglabs/lnc-web": "^0.2.4-alpha",
"@noble/curves": "^1.1.0",
Expand Down
21 changes: 17 additions & 4 deletions src/extension/background-script/connectors/nwc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class NWCConnector implements Connector {
"sendPaymentAsync",
"signMessage",
"getBalance",
"keysend",
];
}

Expand All @@ -53,9 +54,9 @@ class NWCConnector implements Connector {
}

async getInfo(): Promise<GetInfoResponse> {
// TODO: Load via NWC
const info = await this.nwc.getInfo();
return {
data: { alias: "NWC" },
data: { ...info, alias: "NWC" },
};
}

Expand Down Expand Up @@ -100,8 +101,20 @@ class NWCConnector implements Connector {
};
}

keysend(args: KeysendArgs): Promise<SendPaymentResponse> {
throw new Error("Method not implemented.");
async keysend(args: KeysendArgs): Promise<SendPaymentResponse> {
const data = await this.nwc.keysend({
destination: args.pubkey,
amount: args.amount,
customRecords: args.customRecords,
});

return {
data: {
preimage: data.payment_preimage,
paymentHash: data.payment_hash,
route: { total_amt: data.amount, total_fees: data.fee },
},
};
}

async checkPayment(args: CheckPaymentArgs): Promise<CheckPaymentResponse> {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,10 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.52.0.tgz#78fe5f117840f69dc4a353adf9b9cd926353378c"
integrity sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==

"@getalby/sdk@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@getalby/sdk/-/sdk-3.1.0.tgz#49a6d7b292f3c6ab1c37e72422aa0f0ec8f43226"
integrity sha512-1WwwMfrCRtlUv3BnT/rqYiE5giztH5ZxfT1fDwhaJGeC8EJXxGjFBbaUhE0Wq98Fcs/hKoGM4gSmp3UHFDuQxg==
"@getalby/sdk@^3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@getalby/sdk/-/sdk-3.2.0.tgz#fec967f741116d0f3ac06db8b27b9d225849fabe"
integrity sha512-gHWGeAcvaynSlV8sZ/DouakgJeNiiPDk3JeZvIYlkAN6A9XUE3n5QV6Flw1kmz8kKoVmv9Cqr0mHN/PFSV1YWw==
dependencies:
events "^3.3.0"
nostr-tools "^1.17.0"
Expand Down

0 comments on commit 7b1b03a

Please sign in to comment.