Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CashuWallet.send() with OutputAmounts doesn't seem to work #220

Open
thebullishbitcoiner opened this issue Dec 8, 2024 · 4 comments
Open
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@thebullishbitcoiner
Copy link

thebullishbitcoiner commented Dec 8, 2024

Can someone please help me identify this as an issue on my end or the library?

I was able to get wallet.send to work in the scenario where the amount, proofs, and sendAmounts all match (i.e. they're all 4).

image

But when the amount isn't equal to the value of the proof(s), I keep getting an error about the keepAmounts not matching. I've tried hard-coding keepAmounts as [] and various other combinations without any luck.

image

I assume that if I want to send a 1-sat token to 5 people with an 8-sat proof, sendAmounts should be [1,1,1,1,1] and keepAmounts would be either [3] or [1,2]. Not sure if I'm using this correctly.

@cashubtc cashubtc deleted a comment Dec 8, 2024
@callebtc callebtc added help wanted Extra attention is needed question Further information is requested labels Dec 8, 2024
@Egge21M
Copy link
Collaborator

Egge21M commented Dec 8, 2024

If you opt into sendAmounts you need to provide a set of keepAmounts and sendAmounts that match the input. I agree that this is not too ergonomic and we are currently working on a more intuitive and convenient flow.

The first argument to CashuWallet.send() should be the amount you want to send, not including change. Like:

const proofs = await wallet.mintProofs(8, req.quote);

const { keep, send } = await wallet.send(5, proofs, {
    outputAmounts: { sendAmounts: Array(5).fill(1), keepAmounts: [1, 2] }
});

@thebullishbitcoiner
Copy link
Author

I tried hard-coding an 8 and the keepAmounts array to match the proof but still get the error.

Screenshot 2024-12-08 at 9 23 59 AM Screenshot 2024-12-08 at 9 25 04 AM

@Egge21M
Copy link
Collaborator

Egge21M commented Dec 8, 2024

I tried hard-coding an 8 and the keepAmounts array to match the proof but still get the error.

Does the selected mint require fees? If so make sure to adjust keep amounts accordingly.

@thebullishbitcoiner
Copy link
Author

thebullishbitcoiner commented Dec 8, 2024

How can I tell? I'm using Minibits here.

Also, it worked once when I had a 2sat proof. The amount was 2, sendAmounts was [1,1] and keepAmounts was [].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants