@antseed/buyer-core 0.1.36 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/buyer-payment-manager.d.ts +29 -1
- package/dist/buyer-payment-manager.d.ts.map +1 -1
- package/dist/buyer-payment-manager.js +116 -40
- package/dist/buyer-payment-manager.js.map +1 -1
- package/dist/buyer-payment-negotiator.d.ts +35 -8
- package/dist/buyer-payment-negotiator.d.ts.map +1 -1
- package/dist/buyer-payment-negotiator.js +189 -51
- package/dist/buyer-payment-negotiator.js.map +1 -1
- package/dist/channel-reconcile.d.ts +52 -0
- package/dist/channel-reconcile.d.ts.map +1 -0
- package/dist/channel-reconcile.js +151 -0
- package/dist/channel-reconcile.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pricing.d.ts +7 -0
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js +21 -0
- package/dist/pricing.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,3 +22,15 @@ The environment plugs in through small structural interfaces
|
|
|
22
22
|
— identity, peer knowledge, and optional verification persistence.
|
|
23
23
|
|
|
24
24
|
Implementations don't import this package; compatibility is structural.
|
|
25
|
+
|
|
26
|
+
**Keeping stored channels honest.** The store can lag the chain: a seller may
|
|
27
|
+
close a channel this buyer stopped using. `reconcileStoredChannels({ store,
|
|
28
|
+
channels, buyerEvmAddr })` reads every active row of one buyer on-chain and
|
|
29
|
+
retires the ones that can never move money again. A closed channel becomes
|
|
30
|
+
`settled` and a withdrawn one `timeout`, each with the contract's settled
|
|
31
|
+
amount, and a reserve that never landed and whose every ReserveAuth has
|
|
32
|
+
expired becomes `ghost`. Unreadable rows and unknown statuses stay active, as
|
|
33
|
+
do rows whose reserve can still land. It never leaves a seller with a different
|
|
34
|
+
active channel than it had. A process with live buyer sessions calls
|
|
35
|
+
`negotiator.reconcileChannelsWithChain()` instead, which also leaves alone a
|
|
36
|
+
seller with payment work in flight and drops retired sessions from memory.
|
|
@@ -106,6 +106,8 @@ export declare class BuyerPaymentManager {
|
|
|
106
106
|
private readonly _sellerAddressResolver?;
|
|
107
107
|
/** sellerPeerId -> cumulative USDC amount in the latest SpendingAuth */
|
|
108
108
|
private readonly _cumulativeAmount;
|
|
109
|
+
/** sellerPeerId -> the highest cumulative the seller reported accepting on the active channel */
|
|
110
|
+
private readonly _sellerAccepted;
|
|
109
111
|
/** sellerPeerId -> cumulative metadata for SpendingAuth */
|
|
110
112
|
private readonly _metadata;
|
|
111
113
|
/** sellerPeerId -> buyer-verified cumulative cost from bytes/4 */
|
|
@@ -190,6 +192,17 @@ export declare class BuyerPaymentManager {
|
|
|
190
192
|
/** Clean up all in-memory state for a seller when the session ends. */
|
|
191
193
|
cleanupSession(sellerPeerId: string): void;
|
|
192
194
|
getActiveSession(sellerPeerId: string): StoredChannel | null;
|
|
195
|
+
/**
|
|
196
|
+
* Whether `channel` is still where its writer started: the seller's active
|
|
197
|
+
* session, or a one-off channel not yet retired. Payment work reads the
|
|
198
|
+
* channel, awaits, then writes per-seller state; once the session is retired
|
|
199
|
+
* and replaced during that await, those writes would land on the new channel.
|
|
200
|
+
*/
|
|
201
|
+
private _isLive;
|
|
202
|
+
/** Commit a SpendingAuth to a live channel, unless a higher one was committed while it was signed. */
|
|
203
|
+
private _commitLive;
|
|
204
|
+
/** The highest cumulative signed on a live channel: in memory, or committed to the store. */
|
|
205
|
+
getHighestSignedAmount(channel: StoredChannel): bigint;
|
|
193
206
|
retireSession(sellerPeerId: string, status: typeof CHANNEL_STATUS.SETTLED | typeof CHANNEL_STATUS.TIMEOUT | typeof CHANNEL_STATUS.GHOST, settledAmount?: bigint): void;
|
|
194
207
|
canReplayReserveAuth(sellerPeerId: string): boolean;
|
|
195
208
|
hasPendingReserveAuth(sellerPeerId: string): boolean;
|
|
@@ -242,10 +255,15 @@ export declare class BuyerPaymentManager {
|
|
|
242
255
|
/**
|
|
243
256
|
* Durably persist a pending ReserveAuth, then transmit it and adopt the new
|
|
244
257
|
* ceiling in memory. Shared by reserve replay, pending-reserve replay, and
|
|
245
|
-
* reserve top-ups.
|
|
258
|
+
* reserve top-ups. The reserve fields go over the stored row, not `session`:
|
|
259
|
+
* a SpendingAuth committed while the ReserveAuth was signed keeps its higher
|
|
260
|
+
* cumulative, which is also the one sent. False, with nothing sent or
|
|
261
|
+
* adopted, once the session is no longer live.
|
|
246
262
|
*/
|
|
247
263
|
private _commitAndSendReserveAuth;
|
|
264
|
+
/** A dropped commit leaves the per-seller cumulative as it was; see `_commitLive`. */
|
|
248
265
|
private _commitUpdatedSpendingAuth;
|
|
266
|
+
/** See `_commitLive` for a dropped commit. */
|
|
249
267
|
private _signAndCommitSpendingAuth;
|
|
250
268
|
private _topUpAfterSpendAuthBestEffort;
|
|
251
269
|
/**
|
|
@@ -302,6 +320,11 @@ export declare class BuyerPaymentManager {
|
|
|
302
320
|
/** Check whether the channel has reached its absolute remaining-headroom threshold. */
|
|
303
321
|
private _needsTopUp;
|
|
304
322
|
setChannelDepositReader(reader: (channelId: string) => Promise<bigint>): void;
|
|
323
|
+
/**
|
|
324
|
+
* Whether this seller has a paid request running or a reserve top-up queued
|
|
325
|
+
* or running. The channel reconcile pass leaves such a seller's session alone.
|
|
326
|
+
*/
|
|
327
|
+
hasPaymentInFlight(sellerPeerId: string): boolean;
|
|
305
328
|
/** Count a paid request to this seller as in flight until endPaidRequest. */
|
|
306
329
|
beginPaidRequest(sellerPeerId: string): void;
|
|
307
330
|
endPaidRequest(sellerPeerId: string): void;
|
|
@@ -392,6 +415,8 @@ export declare class BuyerPaymentManager {
|
|
|
392
415
|
* still open on-chain, the buyer can still requestClose() it.
|
|
393
416
|
*/
|
|
394
417
|
retireOneOffChannel(channelId: string, status?: typeof CHANNEL_STATUS[keyof typeof CHANNEL_STATUS]): void;
|
|
418
|
+
/** Drop a one-off channel's in-memory state, failing anyone still waiting for its AuthAck. The store is not touched. */
|
|
419
|
+
forgetOneOffChannel(channelId: string): void;
|
|
395
420
|
/**
|
|
396
421
|
* Record that a tracked video job ended without a video (the seller
|
|
397
422
|
* answered FAILED). The seller
|
|
@@ -414,6 +439,9 @@ export declare class BuyerPaymentManager {
|
|
|
414
439
|
getReserveCeiling(sellerPeerId: string): bigint;
|
|
415
440
|
/** Current cumulative signed amount for a seller. */
|
|
416
441
|
getCumulativeAmount(sellerPeerId: string): bigint;
|
|
442
|
+
/** The highest cumulative the seller has reported accepting on the active channel (0 if none yet). */
|
|
443
|
+
getSellerAcceptedCumulative(sellerPeerId: string): bigint;
|
|
444
|
+
private _recordSellerAccepted;
|
|
417
445
|
/** Live cumulative token counts for a seller (in-memory, always up-to-date). */
|
|
418
446
|
getCumulativeTokens(sellerPeerId: string): {
|
|
419
447
|
inputTokens: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buyer-payment-manager.d.ts","sourceRoot":"","sources":["../src/buyer-payment-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,0BAA0B,EAC1B,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgBtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAA8B,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAO7H,OAAO,EAGL,KAAK,cAAc,E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G,OAAO;IAI7C,wDAAwD;IACxD,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAKxC,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,EAAE;IAWlD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMxC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKzC,UAAU,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAOrE"}
|
|
@@ -89,6 +89,8 @@ export class BuyerPaymentManager {
|
|
|
89
89
|
_sellerAddressResolver;
|
|
90
90
|
/** sellerPeerId -> cumulative USDC amount in the latest SpendingAuth */
|
|
91
91
|
_cumulativeAmount = new Map();
|
|
92
|
+
/** sellerPeerId -> the highest cumulative the seller reported accepting on the active channel */
|
|
93
|
+
_sellerAccepted = new Map();
|
|
92
94
|
/** sellerPeerId -> cumulative metadata for SpendingAuth */
|
|
93
95
|
_metadata = new Map();
|
|
94
96
|
/** sellerPeerId -> buyer-verified cumulative cost from bytes/4 */
|
|
@@ -310,6 +312,7 @@ export class BuyerPaymentManager {
|
|
|
310
312
|
/** Clean up all in-memory state for a seller when the session ends. */
|
|
311
313
|
cleanupSession(sellerPeerId) {
|
|
312
314
|
this._cumulativeAmount.delete(sellerPeerId);
|
|
315
|
+
this._sellerAccepted.delete(sellerPeerId);
|
|
313
316
|
this._metadata.delete(sellerPeerId);
|
|
314
317
|
this._verifiedCost.delete(sellerPeerId);
|
|
315
318
|
this._sessionPricing.delete(sellerPeerId);
|
|
@@ -325,6 +328,34 @@ export class BuyerPaymentManager {
|
|
|
325
328
|
getActiveSession(sellerPeerId) {
|
|
326
329
|
return this._channelStore.getActiveChannelByPeerAndBuyer(sellerPeerId, CHANNEL_ROLE.BUYER, this._identity.wallet.address);
|
|
327
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Whether `channel` is still where its writer started: the seller's active
|
|
333
|
+
* session, or a one-off channel not yet retired. Payment work reads the
|
|
334
|
+
* channel, awaits, then writes per-seller state; once the session is retired
|
|
335
|
+
* and replaced during that await, those writes would land on the new channel.
|
|
336
|
+
*/
|
|
337
|
+
_isLive(channel) {
|
|
338
|
+
return channel.channelKind === CHANNEL_KIND.ONE_OFF
|
|
339
|
+
? this._oneOffChannels.has(channel.sessionId)
|
|
340
|
+
: this.getActiveSession(channel.peerId)?.sessionId === channel.sessionId;
|
|
341
|
+
}
|
|
342
|
+
/** Commit a SpendingAuth to a live channel, unless a higher one was committed while it was signed. */
|
|
343
|
+
async _commitLive(channel, metadata) {
|
|
344
|
+
if (!this._isLive(channel))
|
|
345
|
+
return 'retired';
|
|
346
|
+
if (BigInt(channel.authMax) < this.getHighestSignedAmount(channel))
|
|
347
|
+
return 'superseded';
|
|
348
|
+
await this._commitAuthorization(channel, metadata);
|
|
349
|
+
return this._isLive(channel) ? 'committed' : 'retired';
|
|
350
|
+
}
|
|
351
|
+
/** The highest cumulative signed on a live channel: in memory, or committed to the store. */
|
|
352
|
+
getHighestSignedAmount(channel) {
|
|
353
|
+
const committed = BigInt(this._channelStore.getChannel(channel.sessionId)?.authMax ?? '0');
|
|
354
|
+
const inMemory = (channel.channelKind === CHANNEL_KIND.ONE_OFF
|
|
355
|
+
? this._oneOffChannels.get(channel.sessionId)?.cumulative
|
|
356
|
+
: this._cumulativeAmount.get(channel.peerId)) ?? 0n;
|
|
357
|
+
return committed > inMemory ? committed : inMemory;
|
|
358
|
+
}
|
|
328
359
|
retireSession(sellerPeerId, status, settledAmount) {
|
|
329
360
|
const session = this.getActiveSession(sellerPeerId);
|
|
330
361
|
if (session) {
|
|
@@ -352,28 +383,13 @@ export class BuyerPaymentManager {
|
|
|
352
383
|
}
|
|
353
384
|
const cumulativeAmount = this._cumulativeAmount.get(sellerPeerId) ?? BigInt(session.authMax);
|
|
354
385
|
const currentMeta = this._sanitizeMetadata(this._metadata.get(sellerPeerId));
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
const spendingAuthSig = await signSpendingAuth(this._signer, this._channelsDomain, metadataMsg);
|
|
363
|
-
await this._commitAuthorization({
|
|
364
|
-
...session,
|
|
365
|
-
latestBuyerSig: spendingAuthSig,
|
|
366
|
-
latestSpendingAuthSig: spendingAuthSig,
|
|
367
|
-
latestMetadata: encodedMetadata,
|
|
368
|
-
updatedAt: Date.now(),
|
|
369
|
-
}, currentMeta);
|
|
370
|
-
paymentMux.sendSpendingAuth({
|
|
371
|
-
channelId: session.sessionId,
|
|
372
|
-
cumulativeAmount: cumulativeAmount.toString(),
|
|
373
|
-
metadataHash: metadataHashHex,
|
|
374
|
-
metadata: encodedMetadata,
|
|
375
|
-
spendingAuthSig,
|
|
376
|
-
});
|
|
386
|
+
const spendingAuth = await this._signAndCommitSpendingAuth(session, cumulativeAmount, currentMeta);
|
|
387
|
+
if (spendingAuth === 'retired')
|
|
388
|
+
throw writeDropped(sellerPeerId);
|
|
389
|
+
// The higher authorization committed meanwhile was sent by its own writer.
|
|
390
|
+
if (spendingAuth === 'superseded')
|
|
391
|
+
return session.sessionId;
|
|
392
|
+
paymentMux.sendSpendingAuth(spendingAuth);
|
|
377
393
|
return session.sessionId;
|
|
378
394
|
}
|
|
379
395
|
async extendCurrentSpendingAuth(sellerPeerId, minBudgetPerRequest, paymentMux, targetCumulative, requestId, inFlightRequests = 1) {
|
|
@@ -419,6 +435,11 @@ export class BuyerPaymentManager {
|
|
|
419
435
|
}
|
|
420
436
|
const currentMeta = this._sanitizeMetadata(this._metadata.get(sellerPeerId));
|
|
421
437
|
const spendingAuth = await this._commitUpdatedSpendingAuth(session, sellerPeerId, nextCumulative, currentMeta);
|
|
438
|
+
if (spendingAuth === 'retired')
|
|
439
|
+
throw writeDropped(sellerPeerId);
|
|
440
|
+
// A SpendingAuth committed while this one was signed already signed past the target.
|
|
441
|
+
if (spendingAuth === 'superseded')
|
|
442
|
+
return { sessionId: session.sessionId, topUp: extendNeedsTopUp };
|
|
422
443
|
this._verifiedCost.set(sellerPeerId, reopened.verifiedCost);
|
|
423
444
|
this._reportSpend({
|
|
424
445
|
sellerPeerId,
|
|
@@ -465,17 +486,20 @@ export class BuyerPaymentManager {
|
|
|
465
486
|
};
|
|
466
487
|
const spendingAuthSig = await signSpendingAuth(this._signer, this._channelsDomain, metadataMsg);
|
|
467
488
|
const encodedMetadata = encodeMetadata(currentMeta);
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
489
|
+
// A capped close authorization is below the signed high-water mark; keep
|
|
490
|
+
// the persisted latest authorization consistent with authMax.
|
|
491
|
+
const live = capped
|
|
492
|
+
? this._isLive(session)
|
|
493
|
+
: await this._commitLive({
|
|
472
494
|
...session,
|
|
495
|
+
authMax: cumulativeAmount.toString(),
|
|
473
496
|
latestBuyerSig: spendingAuthSig,
|
|
474
497
|
latestSpendingAuthSig: spendingAuthSig,
|
|
475
498
|
latestMetadata: encodedMetadata,
|
|
476
499
|
updatedAt: Date.now(),
|
|
477
|
-
}, currentMeta);
|
|
478
|
-
|
|
500
|
+
}, currentMeta) === 'committed';
|
|
501
|
+
if (!live)
|
|
502
|
+
throw writeDropped(sellerPeerId);
|
|
479
503
|
return {
|
|
480
504
|
version: 1,
|
|
481
505
|
channelId: session.sessionId,
|
|
@@ -508,9 +532,11 @@ export class BuyerPaymentManager {
|
|
|
508
532
|
deadline,
|
|
509
533
|
confirmedAmount: 0n,
|
|
510
534
|
};
|
|
511
|
-
await this._commitAndSendReserveAuth(session, sellerPeerId, pending, paymentMux, {
|
|
535
|
+
const live = await this._commitAndSendReserveAuth(session, sellerPeerId, pending, paymentMux, {
|
|
512
536
|
initialReserveAmount: maxAmount.toString(),
|
|
513
537
|
});
|
|
538
|
+
if (!live)
|
|
539
|
+
throw writeDropped(sellerPeerId);
|
|
514
540
|
return session.sessionId;
|
|
515
541
|
}
|
|
516
542
|
/** Replay the latest unacknowledged initial reserve or top-up authorization. */
|
|
@@ -533,7 +559,8 @@ export class BuyerPaymentManager {
|
|
|
533
559
|
const signature = await this._signReserveAuth(session.sessionId, pending.maxAmount, deadline);
|
|
534
560
|
pending = { ...pending, signature, deadline };
|
|
535
561
|
}
|
|
536
|
-
await this._commitAndSendReserveAuth(session, sellerPeerId, pending, paymentMux)
|
|
562
|
+
if (!await this._commitAndSendReserveAuth(session, sellerPeerId, pending, paymentMux))
|
|
563
|
+
throw writeDropped(sellerPeerId);
|
|
537
564
|
return session.sessionId;
|
|
538
565
|
}
|
|
539
566
|
/** Reconcile the locally usable ceiling with an authoritative on-chain read. */
|
|
@@ -670,13 +697,19 @@ export class BuyerPaymentManager {
|
|
|
670
697
|
/**
|
|
671
698
|
* Durably persist a pending ReserveAuth, then transmit it and adopt the new
|
|
672
699
|
* ceiling in memory. Shared by reserve replay, pending-reserve replay, and
|
|
673
|
-
* reserve top-ups.
|
|
700
|
+
* reserve top-ups. The reserve fields go over the stored row, not `session`:
|
|
701
|
+
* a SpendingAuth committed while the ReserveAuth was signed keeps its higher
|
|
702
|
+
* cumulative, which is also the one sent. False, with nothing sent or
|
|
703
|
+
* adopted, once the session is no longer live.
|
|
674
704
|
*/
|
|
675
705
|
async _commitAndSendReserveAuth(session, sellerPeerId, pending, paymentMux, options = {}) {
|
|
706
|
+
const current = this._isLive(session) ? this._channelStore.getChannel(session.sessionId) : null;
|
|
707
|
+
if (!current)
|
|
708
|
+
return false;
|
|
676
709
|
const metadata = this._sanitizeMetadata(this._metadata.get(sellerPeerId));
|
|
677
710
|
const encodedMetadata = encodeMetadata(metadata);
|
|
678
711
|
await this._commitAuthorization({
|
|
679
|
-
...
|
|
712
|
+
...current,
|
|
680
713
|
deadline: pending.deadline,
|
|
681
714
|
latestBuyerSig: pending.signature,
|
|
682
715
|
latestMetadata: encodedMetadata,
|
|
@@ -691,10 +724,12 @@ export class BuyerPaymentManager {
|
|
|
691
724
|
confirmedReserveAmount: pending.confirmedAmount.toString(),
|
|
692
725
|
updatedAt: Date.now(),
|
|
693
726
|
}, metadata);
|
|
727
|
+
if (!this._isLive(session))
|
|
728
|
+
return false;
|
|
694
729
|
this._pendingReserveAuth.set(sellerPeerId, pending);
|
|
695
730
|
paymentMux.sendSpendingAuth({
|
|
696
731
|
channelId: session.sessionId,
|
|
697
|
-
cumulativeAmount:
|
|
732
|
+
cumulativeAmount: current.authMax,
|
|
698
733
|
metadataHash: computeMetadataHash(metadata),
|
|
699
734
|
metadata: encodedMetadata,
|
|
700
735
|
spendingAuthSig: pending.signature,
|
|
@@ -703,13 +738,18 @@ export class BuyerPaymentManager {
|
|
|
703
738
|
reserveDeadline: pending.deadline,
|
|
704
739
|
});
|
|
705
740
|
this._currentReserveCeiling.set(sellerPeerId, pending.maxAmount);
|
|
741
|
+
return true;
|
|
706
742
|
}
|
|
743
|
+
/** A dropped commit leaves the per-seller cumulative as it was; see `_commitLive`. */
|
|
707
744
|
async _commitUpdatedSpendingAuth(session, sellerPeerId, cumulativeAmount, metadata) {
|
|
708
745
|
const sanitizedMetadata = this._sanitizeMetadata(metadata);
|
|
709
746
|
const spendingAuth = await this._signAndCommitSpendingAuth(session, cumulativeAmount, sanitizedMetadata);
|
|
747
|
+
if (typeof spendingAuth === 'string')
|
|
748
|
+
return spendingAuth;
|
|
710
749
|
this._cumulativeAmount.set(sellerPeerId, cumulativeAmount);
|
|
711
750
|
return spendingAuth;
|
|
712
751
|
}
|
|
752
|
+
/** See `_commitLive` for a dropped commit. */
|
|
713
753
|
async _signAndCommitSpendingAuth(channel, cumulativeAmount, metadata) {
|
|
714
754
|
const sanitizedMetadata = this._sanitizeMetadata(metadata);
|
|
715
755
|
const metadataHash = computeMetadataHash(sanitizedMetadata);
|
|
@@ -719,7 +759,7 @@ export class BuyerPaymentManager {
|
|
|
719
759
|
cumulativeAmount,
|
|
720
760
|
metadataHash,
|
|
721
761
|
});
|
|
722
|
-
await this.
|
|
762
|
+
const outcome = await this._commitLive({
|
|
723
763
|
...channel,
|
|
724
764
|
authMax: cumulativeAmount.toString(),
|
|
725
765
|
latestBuyerSig: spendingAuthSig,
|
|
@@ -727,6 +767,8 @@ export class BuyerPaymentManager {
|
|
|
727
767
|
latestMetadata: encodedMetadata,
|
|
728
768
|
updatedAt: Date.now(),
|
|
729
769
|
}, sanitizedMetadata);
|
|
770
|
+
if (outcome !== 'committed')
|
|
771
|
+
return outcome;
|
|
730
772
|
return {
|
|
731
773
|
channelId: channel.sessionId,
|
|
732
774
|
cumulativeAmount: cumulativeAmount.toString(),
|
|
@@ -1009,6 +1051,13 @@ export class BuyerPaymentManager {
|
|
|
1009
1051
|
setChannelDepositReader(reader) {
|
|
1010
1052
|
this._readChannelDeposit = reader;
|
|
1011
1053
|
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Whether this seller has a paid request running or a reserve top-up queued
|
|
1056
|
+
* or running. The channel reconcile pass leaves such a seller's session alone.
|
|
1057
|
+
*/
|
|
1058
|
+
hasPaymentInFlight(sellerPeerId) {
|
|
1059
|
+
return (this._inFlightPaidRequests.get(sellerPeerId) ?? 0) > 0 || (this._topUpsQueued.get(sellerPeerId) ?? 0) > 0;
|
|
1060
|
+
}
|
|
1012
1061
|
/** Count a paid request to this seller as in flight until endPaidRequest. */
|
|
1013
1062
|
beginPaidRequest(sellerPeerId) {
|
|
1014
1063
|
this._inFlightPaidRequests.set(sellerPeerId, (this._inFlightPaidRequests.get(sellerPeerId) ?? 0) + 1);
|
|
@@ -1264,7 +1313,7 @@ export class BuyerPaymentManager {
|
|
|
1264
1313
|
};
|
|
1265
1314
|
const spendingAuthSig = await signSpendingAuth(this._signer, channelsDomain, metadataMsg);
|
|
1266
1315
|
// Persist updated cumulative values to BuyerChannelStore
|
|
1267
|
-
await this.
|
|
1316
|
+
const outcome = await this._commitLive({
|
|
1268
1317
|
...session,
|
|
1269
1318
|
authMax: newAmount.toString(),
|
|
1270
1319
|
requestCount: Number(newMeta.cumulativeRequestCount),
|
|
@@ -1273,6 +1322,8 @@ export class BuyerPaymentManager {
|
|
|
1273
1322
|
latestMetadata: encodedMetadata,
|
|
1274
1323
|
updatedAt: Date.now(),
|
|
1275
1324
|
}, newMeta);
|
|
1325
|
+
if (outcome !== 'committed')
|
|
1326
|
+
throw writeDropped(sellerPeerId);
|
|
1276
1327
|
this._cumulativeAmount.set(sellerPeerId, newAmount);
|
|
1277
1328
|
this._verifiedCost.set(sellerPeerId, nextVerifiedCost);
|
|
1278
1329
|
this._metadata.set(sellerPeerId, newMeta);
|
|
@@ -1345,6 +1396,8 @@ export class BuyerPaymentManager {
|
|
|
1345
1396
|
debugWarn(`[BuyerPayment] NeedAuth for unknown channel ${payload.channelId.slice(0, 18)}... — ignoring`);
|
|
1346
1397
|
return false;
|
|
1347
1398
|
}
|
|
1399
|
+
if (payload.currentAcceptedCumulative != null)
|
|
1400
|
+
this._recordSellerAccepted(sellerPeerId, session.sessionId, BigInt(payload.currentAcceptedCumulative));
|
|
1348
1401
|
if (this.isRequestCovered(sellerPeerId, payload.requestId)) {
|
|
1349
1402
|
debugWarn(`[BuyerPayment] Refusing NeedAuth from ${sellerPeerId.slice(0, 12)}... for request ${payload.requestId} it served from a free allowance`);
|
|
1350
1403
|
return false;
|
|
@@ -1546,6 +1599,8 @@ export class BuyerPaymentManager {
|
|
|
1546
1599
|
// owner. In particular, swallowing an IndexedDB failure leaves the browser
|
|
1547
1600
|
// connected with advanced in-memory counters but no durable signature.
|
|
1548
1601
|
const spendingAuth = await this._commitUpdatedSpendingAuth(session, sellerPeerId, effectiveAmount, newMeta);
|
|
1602
|
+
if (typeof spendingAuth === 'string')
|
|
1603
|
+
return false;
|
|
1549
1604
|
this._verifiedCost.set(sellerPeerId, nextVerifiedCost);
|
|
1550
1605
|
this._metadata.set(sellerPeerId, newMeta);
|
|
1551
1606
|
if (deliveredResponse && !alreadyCounted) {
|
|
@@ -1666,7 +1721,6 @@ export class BuyerPaymentManager {
|
|
|
1666
1721
|
const newCeiling = prevCeiling + additionalReserve;
|
|
1667
1722
|
debugLog(`[BuyerPayment] topUpReserve: channel=${session.sessionId.slice(0, 18)}... ceiling ${prevCeiling} → ${newCeiling}`);
|
|
1668
1723
|
const reserveAuthSig = await this._signReserveAuth(session.sessionId, newCeiling, deadline);
|
|
1669
|
-
const currentCumulative = this._cumulativeAmount.get(sellerPeerId) ?? 0n;
|
|
1670
1724
|
const salt = this._reserveSalt.get(sellerPeerId) ?? '0x' + '00'.repeat(32);
|
|
1671
1725
|
const pending = {
|
|
1672
1726
|
signature: reserveAuthSig,
|
|
@@ -1678,11 +1732,11 @@ export class BuyerPaymentManager {
|
|
|
1678
1732
|
};
|
|
1679
1733
|
// Send ReserveAuth sig with reserve fields (same pattern as initial authorizeSpending).
|
|
1680
1734
|
// The seller uses this to call topUp() on-chain with the new maxAmount.
|
|
1681
|
-
await this._commitAndSendReserveAuth(session, sellerPeerId, pending, paymentMux, {
|
|
1682
|
-
cumulativeAmount: currentCumulative.toString(),
|
|
1735
|
+
const sent = await this._commitAndSendReserveAuth(session, sellerPeerId, pending, paymentMux, {
|
|
1683
1736
|
initialReserveAmount: session.initialReserveAmount ?? prevCeiling.toString(),
|
|
1684
1737
|
});
|
|
1685
|
-
|
|
1738
|
+
if (sent)
|
|
1739
|
+
debugLog(`[BuyerPayment] topUpReserve sent: newCeiling=${newCeiling}`);
|
|
1686
1740
|
}
|
|
1687
1741
|
// ── Queries ───────────────────────────────────────────────────
|
|
1688
1742
|
/** Max USDC overdraft (unverified exposure) from buyer config. */
|
|
@@ -1805,13 +1859,19 @@ export class BuyerPaymentManager {
|
|
|
1805
1859
|
* still open on-chain, the buyer can still requestClose() it.
|
|
1806
1860
|
*/
|
|
1807
1861
|
retireOneOffChannel(channelId, status = CHANNEL_STATUS.SETTLED) {
|
|
1862
|
+
if (!this._oneOffChannels.has(channelId))
|
|
1863
|
+
return;
|
|
1864
|
+
this.forgetOneOffChannel(channelId);
|
|
1865
|
+
this._channelStore.updateChannelStatus(channelId, status);
|
|
1866
|
+
}
|
|
1867
|
+
/** Drop a one-off channel's in-memory state, failing anyone still waiting for its AuthAck. The store is not touched. */
|
|
1868
|
+
forgetOneOffChannel(channelId) {
|
|
1808
1869
|
const state = this._oneOffChannels.get(channelId);
|
|
1809
1870
|
if (!state)
|
|
1810
1871
|
return;
|
|
1811
1872
|
this._oneOffChannels.delete(channelId);
|
|
1812
1873
|
for (const waiter of state.ackWaiters.splice(0))
|
|
1813
1874
|
waiter(false);
|
|
1814
|
-
this._channelStore.updateChannelStatus(channelId, status);
|
|
1815
1875
|
}
|
|
1816
1876
|
/**
|
|
1817
1877
|
* Record that a tracked video job ended without a video (the seller
|
|
@@ -1903,6 +1963,8 @@ export class BuyerPaymentManager {
|
|
|
1903
1963
|
inputCharacters: countUnits(usage, 'input_characters'),
|
|
1904
1964
|
});
|
|
1905
1965
|
const spendingAuth = await this._signAndCommitSpendingAuth(channel, state.price, metadata);
|
|
1966
|
+
if (typeof spendingAuth === 'string')
|
|
1967
|
+
return;
|
|
1906
1968
|
this._reportUnitSpend(sellerPeerId, requestId, state.price - state.cumulative);
|
|
1907
1969
|
state.cumulative = state.price;
|
|
1908
1970
|
paymentMux.sendSpendingAuth(spendingAuth);
|
|
@@ -1921,6 +1983,17 @@ export class BuyerPaymentManager {
|
|
|
1921
1983
|
getCumulativeAmount(sellerPeerId) {
|
|
1922
1984
|
return this._cumulativeAmount.get(sellerPeerId) ?? 0n;
|
|
1923
1985
|
}
|
|
1986
|
+
/** The highest cumulative the seller has reported accepting on the active channel (0 if none yet). */
|
|
1987
|
+
getSellerAcceptedCumulative(sellerPeerId) {
|
|
1988
|
+
const accepted = this._sellerAccepted.get(sellerPeerId);
|
|
1989
|
+
return accepted && accepted.channelId === this.getActiveSession(sellerPeerId)?.sessionId ? accepted.amount : 0n;
|
|
1990
|
+
}
|
|
1991
|
+
_recordSellerAccepted(sellerPeerId, channelId, amount) {
|
|
1992
|
+
const known = this._sellerAccepted.get(sellerPeerId);
|
|
1993
|
+
if (known?.channelId === channelId && known.amount >= amount)
|
|
1994
|
+
return;
|
|
1995
|
+
this._sellerAccepted.set(sellerPeerId, { channelId, amount });
|
|
1996
|
+
}
|
|
1924
1997
|
/** Live cumulative token counts for a seller (in-memory, always up-to-date). */
|
|
1925
1998
|
getCumulativeTokens(sellerPeerId) {
|
|
1926
1999
|
const meta = this._sanitizeMetadata(this._metadata.get(sellerPeerId));
|
|
@@ -2255,6 +2328,9 @@ export class BuyerPaymentManager {
|
|
|
2255
2328
|
return { available: info.available, reserved: info.reserved };
|
|
2256
2329
|
}
|
|
2257
2330
|
}
|
|
2331
|
+
function writeDropped(sellerPeerId) {
|
|
2332
|
+
return buyerFault(`[BuyerPayment] Authorization for seller ${sellerPeerId.slice(0, 12)}... was dropped: its session was retired, or signed higher, while it was being signed`, 'buyer-session-state');
|
|
2333
|
+
}
|
|
2258
2334
|
function videoJobKey(sellerPeerId, protocol, jobId) {
|
|
2259
2335
|
return `${sellerPeerId.toLowerCase()}\n${protocol}\n${jobId}`;
|
|
2260
2336
|
}
|