Skip to content

Commit

Permalink
fix: tests for p2pk and claim
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Mar 23, 2024
1 parent 5bfecf8 commit 5b8b5a9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 28 deletions.
26 changes: 0 additions & 26 deletions wrappers/fedimint-ts/FedimintClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,32 +355,6 @@ class FedimintClient {
federationId
);
},

/**
* Creates a lightning invoice where the gateway contract locks the ecash to a specific pubkey
* Useful for creating invoices that pay to another user besides yourself
*/
createInvoicePubkey: async (
pubkey: string,
amountMsat: number,
description: string,
expiryTime?: number,
federationId?: string
): FedimintResponse<LnInvoiceResponse> => {
const request: LnInvoiceExternalPubkeyRequest = {
externalPubkey: pubkey,
amountMsat,
description,
expiryTime,
};

return await this.postWithId<LnInvoiceExternalPubkeyResponse>(
"/ln/invoice-external-pubkey",
request,
federationId
);
},

/**
* Waits for a lightning invoice to be paid
*/
Expand Down
48 changes: 46 additions & 2 deletions wrappers/fedimint-ts/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ async function main() {
const keyPair = newKeyPair();
console.log("Generated key pair: ", keyPair);

return;

// ADMIN METHODS
// `/v2/admin/config`
logMethod("/v2/admin/config");
Expand Down Expand Up @@ -107,6 +105,52 @@ async function main() {
logMethod("/v2/ln/await-invoice");
data = await fedimintClient.ln.awaitInvoice(operationId);
logInputAndOutput({ operationId }, data);
// `/v1/ln/invoice-external-pubkey`
logMethod("/v1/ln/invoice-external-pubkey");
data = await fedimintClient.ln.createInvoiceForPubkey(
keyPair.publicKey,
1000,
"test"
);
logInputAndOutput(
{
externalPubkey: keyPair.publicKey,
amountMsat: 10000,
description: "test",
},
data
);
// pay the invoice
payResponse = await fedimintClient.ln.pay(data.invoice);
// `/v1/ln/claim-external-pubkey`
logMethod("/v1/ln/claim-external-pubkey");
data = await fedimintClient.ln.claimPubkeyReceive(keyPair.privateKey);
logInputAndOutput({ privateKey: keyPair.privateKey }, data);
// `/v1/ln/invoice-external-pubkey-tweaked`
logMethod("/v1/ln/invoice-external-pubkey-tweaked");
data = await fedimintClient.ln.createInvoiceForPubkeyTweak(
keyPair.publicKey,
1,
1000,
"test"
);
logInputAndOutput(
{
externalPubkey: keyPair.publicKey,
tweak: 1,
amountMsat: 10000,
description: "test",
},
data
);
// pay the invoice
payResponse = await fedimintClient.ln.pay(data.invoice);
// `/v1/ln/claim-external-pubkey-tweaked`
logMethod("/v1/ln/claim-external-pubkey-tweaked");
data = await fedimintClient.ln.claimPubkeyReceiveTweaked(keyPair.privateKey, [
1,
]);
logInputAndOutput({ privateKey: keyPair.privateKey, tweaks: [1] }, data);

// MINT METHODS
// `/v2/mint/spend`
Expand Down

0 comments on commit 5b8b5a9

Please sign in to comment.