Skip to content

Commit

Permalink
Merge pull request cashubtc#121 from Kelbie/Allow-specifying-the-keys…
Browse files Browse the repository at this point in the history
…et-in-send-and-receive

Fixes bug with sending/receiving usd (other units)
  • Loading branch information
gandlafbtc authored May 20, 2024
2 parents 0d59735 + 78099d0 commit 39cbb8f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/CashuWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CashuWallet {
async receive(
token: string | Token,
options?: {
keysetId?: string;
preference?: Array<AmountPreference>;
counter?: number;
pubkey?: string;
Expand All @@ -127,6 +128,7 @@ class CashuWallet {
}
try {
const { proofs, proofsWithError } = await this.receiveTokenEntry(tokenEntry, {
keysetId: options?.keysetId,
preference: options?.preference,
counter: options?.counter,
pubkey: options?.pubkey,
Expand Down Expand Up @@ -160,6 +162,7 @@ class CashuWallet {
async receiveTokenEntry(
tokenEntry: TokenEntry,
options?: {
keysetId?: string;
preference?: Array<AmountPreference>;
counter?: number;
pubkey?: string;
Expand All @@ -174,7 +177,7 @@ class CashuWallet {
if (!preference) {
preference = getDefaultAmountPreference(amount);
}
const keys = await this.getKeys();
const keys = await this.getKeys(options?.keysetId);
const { payload, blindedMessages } = this.createSplitPayload(
amount,
tokenEntry.proofs,
Expand Down Expand Up @@ -218,6 +221,7 @@ class CashuWallet {
amount: number,
proofs: Array<Proof>,
options?: {
keysetId?: string;
preference?: Array<AmountPreference>;
counter?: number;
pubkey?: string;
Expand All @@ -227,7 +231,7 @@ class CashuWallet {
if (options?.preference) {
amount = options?.preference?.reduce((acc, curr) => acc + curr.amount * curr.count, 0);
}
const keyset = await this.getKeys();
const keyset = await this.getKeys(options?.keysetId);
let amountAvailable = 0;
const proofsToSend: Array<Proof> = [];
const proofsToKeep: Array<Proof> = [];
Expand Down

0 comments on commit 39cbb8f

Please sign in to comment.