@cashu/cashu-ts
Version:
cashu library for communicating with a cashu mint
60 lines (45 loc) • 1.64 kB
Markdown
`wallet.ops.receive(...)` accepts an encoded token string, a decoded `Token`, or raw `Proof[]`.
```ts
const proofs = await wallet.ops.receive(token).run();
// Or use prepare() instead of run() to do a dry run preview first
const preview = await wallet.ops.receive(token).prepare();
const { keep } = await wallet.completeSwap(preview);
```
You can also receive an array of raw proofs directly:
```ts
const oldProofs: Proof[] = [proof1, proof2, proof3, ...];
const freshProofs = await wallet.ops.receive(oldProofs).run();
```
```ts
const proofs = await wallet.ops
.receive(token)
.asDeterministic() // counter=0 => auto-reserve
.requireDleq(true) // reject incoming proofs without DLEQ for the selected keyset
.keyset('0123456')
.onCountersReserved((c) => console.log('RX counters', c))
.run();
```
```ts
const proofs = await wallet.ops
.receive(token)
.asP2PK({ pubkey, locktime }) // NUT-11 options for new proofs
.privkey(['k1', 'k2', 'k3']) // sign incoming P2PK proofs
.proofsWeHave(myExistingProofs) // helps denomination selection
.run();
```
```ts
const proofsA = await wallet.ops
.receive(tokenA)
.asFactory(makeOutputData, [8, 4, 16]) // split must include these denoms
.run();
const proofsB = await wallet.ops
.receive(tokenB)
.asCustom(prebuiltRxOutputs) // amounts must sum to final received amount after fees
.run();
```