cashubtc / cashu-feni

A Cashu mint and wallet implementation in Golang
MIT License
36 stars 13 forks source link

outputs constructed when doing split can tell mint the intended payment amount vs change #54

Open elnosh opened 1 year ago

elnosh commented 1 year ago

When sending from wallet, the way outputs are constructed in the request for /split they could be telling the mint which is the intended payment amount vs which is the change.

Code in wallet constructing output

    total := SumProofs(proofs)
    frstAmt := total - amount
    scndAmt := amount
    frstOutputs := mint.AmountSplit(frstAmt)
    scndOutputs := mint.AmountSplit(scndAmt)
    amounts := append(frstOutputs, scndOutputs...)

So if user has a balance of 100 and tries a send 20 the output amounts when requesting a split to the mint could look like [16, 64, 4, 16]

Describe the solution you'd like Maybe sort the outputs slice before sending request to mint.