@1sat/wallet-server 0.0.1 → 0.0.3
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/dist/accounts/index.d.ts +4 -7
- package/dist/accounts/index.d.ts.map +1 -1
- package/dist/accounts/index.js +3 -6
- package/dist/accounts/index.js.map +1 -1
- package/dist/accounts/middleware.d.ts +29 -30
- package/dist/accounts/middleware.d.ts.map +1 -1
- package/dist/accounts/middleware.js +303 -121
- package/dist/accounts/middleware.js.map +1 -1
- package/dist/accounts/pricing.d.ts +38 -11
- package/dist/accounts/pricing.d.ts.map +1 -1
- package/dist/accounts/pricing.js +40 -11
- package/dist/accounts/pricing.js.map +1 -1
- package/dist/accounts/queries.d.ts +42 -0
- package/dist/accounts/queries.d.ts.map +1 -0
- package/dist/accounts/queries.js +91 -0
- package/dist/accounts/queries.js.map +1 -0
- package/dist/accounts/types.d.ts +46 -29
- package/dist/accounts/types.d.ts.map +1 -1
- package/dist/client.d.ts +20 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +34 -0
- package/dist/client.js.map +1 -0
- package/dist/createWalletServer.d.ts +12 -3
- package/dist/createWalletServer.d.ts.map +1 -1
- package/dist/createWalletServer.js +84 -46
- package/dist/createWalletServer.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/topUp.d.ts +28 -0
- package/dist/topUp.d.ts.map +1 -0
- package/dist/topUp.js +67 -0
- package/dist/topUp.js.map +1 -0
- package/package.json +57 -46
- package/dist/accounts/metering.d.ts +0 -15
- package/dist/accounts/metering.d.ts.map +0 -1
- package/dist/accounts/metering.js +0 -32
- package/dist/accounts/metering.js.map +0 -1
- package/dist/accounts/migrations.d.ts +0 -18
- package/dist/accounts/migrations.d.ts.map +0 -1
- package/dist/accounts/migrations.js +0 -46
- package/dist/accounts/migrations.js.map +0 -1
- package/dist/accounts/paymentValidation.d.ts +0 -59
- package/dist/accounts/paymentValidation.d.ts.map +0 -1
- package/dist/accounts/paymentValidation.js +0 -112
- package/dist/accounts/paymentValidation.js.map +0 -1
- package/dist/accounts/repo.d.ts +0 -17
- package/dist/accounts/repo.d.ts.map +0 -1
- package/dist/accounts/repo.js +0 -94
- package/dist/accounts/repo.js.map +0 -1
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { AccountsConfig } from './types';
|
|
2
|
+
/** Minimal payment view needed for pricing math. */
|
|
3
|
+
export interface PaymentForPricing {
|
|
4
|
+
bytesCovered: number;
|
|
5
|
+
paidThroughBlock: number;
|
|
6
|
+
}
|
|
2
7
|
declare const BYTES_PER_GB = 1073741824;
|
|
3
8
|
export interface CapacityInput {
|
|
4
9
|
baselineBytes: number;
|
|
@@ -13,18 +18,40 @@ export interface CapacityResult {
|
|
|
13
18
|
deficitBytes: number;
|
|
14
19
|
}
|
|
15
20
|
export declare function computeCapacity(input: CapacityInput): CapacityResult;
|
|
21
|
+
export interface RefundedQuoteInput {
|
|
22
|
+
usedBytes: number;
|
|
23
|
+
currentPayment: PaymentForPricing | undefined;
|
|
24
|
+
currentBlock: number;
|
|
25
|
+
config: Pick<AccountsConfig, 'baselineBytes' | 'purchaseUnitBytes' | 'satsPerUnit' | 'durationBlocks'>;
|
|
26
|
+
}
|
|
27
|
+
export interface RefundedQuote {
|
|
28
|
+
/** Total paid capacity (in bytes, rounded up to a whole purchase unit) to be purchased. */
|
|
29
|
+
bytesCovered: number;
|
|
30
|
+
unitsCharged: number;
|
|
31
|
+
/** Price at full rate for `unitsCharged` over `durationBlocks`. */
|
|
32
|
+
fullSats: number;
|
|
33
|
+
/** Credit for unused time remaining on the caller's current payment. */
|
|
34
|
+
refundSats: number;
|
|
35
|
+
/** Sats owed after applying refund (never negative). */
|
|
36
|
+
chargeSats: number;
|
|
37
|
+
/** Block height at which the new payment will expire. */
|
|
38
|
+
paidThroughBlock: number;
|
|
39
|
+
}
|
|
16
40
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
41
|
+
* Computes a single quote under the "full charge minus refund credit" model.
|
|
42
|
+
*
|
|
43
|
+
* The caller pays the full price for whatever paid capacity they need beyond
|
|
44
|
+
* baseline, for a fresh `durationBlocks` period. Any unused time remaining on
|
|
45
|
+
* their prior payment is prorated and subtracted from the charge.
|
|
46
|
+
*
|
|
47
|
+
* A new payment fully supersedes the prior one — the new paidThroughBlock
|
|
48
|
+
* becomes the account's active expiry.
|
|
19
49
|
*/
|
|
20
|
-
export declare function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export declare function
|
|
26
|
-
satoshisRequired: number;
|
|
27
|
-
bytesCovered: number;
|
|
28
|
-
};
|
|
50
|
+
export declare function quoteRefundedCharge(input: RefundedQuoteInput): RefundedQuote | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Prorated credit for the unused time remaining on a prior payment.
|
|
53
|
+
* Returns 0 when no prior payment or when it has already expired.
|
|
54
|
+
*/
|
|
55
|
+
export declare function refundCreditSats(payment: PaymentForPricing | undefined, currentBlock: number, durationBlocks: number, purchaseUnitBytes: number, satsPerUnit: number): number;
|
|
29
56
|
export { BYTES_PER_GB };
|
|
30
57
|
//# sourceMappingURL=pricing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/accounts/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,QAAA,MAAM,YAAY,aAAgB,CAAA;AAElC,MAAM,WAAW,aAAa;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB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E,MAAM,CAAA;IAClB,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,kBAAkB,GACvB,aAAa,GAAG,SAAS,CAyC3B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,iBAAiB,GAAG,SAAS,EACtC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,MAAM,GACjB,MAAM,CAMR;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/accounts/pricing.js
CHANGED
|
@@ -11,22 +11,51 @@ export function computeCapacity(input) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Computes a single quote under the "full charge minus refund credit" model.
|
|
15
|
+
*
|
|
16
|
+
* The caller pays the full price for whatever paid capacity they need beyond
|
|
17
|
+
* baseline, for a fresh `durationBlocks` period. Any unused time remaining on
|
|
18
|
+
* their prior payment is prorated and subtracted from the charge.
|
|
19
|
+
*
|
|
20
|
+
* A new payment fully supersedes the prior one — the new paidThroughBlock
|
|
21
|
+
* becomes the account's active expiry.
|
|
16
22
|
*/
|
|
17
|
-
export function
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
export function quoteRefundedCharge(input) {
|
|
24
|
+
const activePayment = input.currentPayment &&
|
|
25
|
+
input.currentPayment.paidThroughBlock > input.currentBlock
|
|
26
|
+
? input.currentPayment
|
|
27
|
+
: undefined;
|
|
28
|
+
const neededPaidBytes = Math.max(0, input.usedBytes - input.config.baselineBytes);
|
|
29
|
+
if (neededPaidBytes <= (activePayment?.bytesCovered ?? 0)) {
|
|
30
|
+
return undefined;
|
|
20
31
|
}
|
|
21
|
-
const
|
|
32
|
+
const unitsCharged = Math.max(1, Math.ceil(neededPaidBytes / input.config.purchaseUnitBytes));
|
|
33
|
+
const bytesCovered = unitsCharged * input.config.purchaseUnitBytes;
|
|
34
|
+
const fullSats = unitsCharged * input.config.satsPerUnit;
|
|
35
|
+
const refundSats = refundCreditSats(activePayment, input.currentBlock, input.config.durationBlocks, input.config.purchaseUnitBytes, input.config.satsPerUnit);
|
|
36
|
+
const chargeSats = Math.max(0, fullSats - refundSats);
|
|
37
|
+
const paidThroughBlock = input.currentBlock + input.config.durationBlocks;
|
|
22
38
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
39
|
+
bytesCovered,
|
|
40
|
+
unitsCharged,
|
|
41
|
+
fullSats,
|
|
42
|
+
refundSats,
|
|
43
|
+
chargeSats,
|
|
44
|
+
paidThroughBlock,
|
|
26
45
|
};
|
|
27
46
|
}
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Prorated credit for the unused time remaining on a prior payment.
|
|
49
|
+
* Returns 0 when no prior payment or when it has already expired.
|
|
50
|
+
*/
|
|
51
|
+
export function refundCreditSats(payment, currentBlock, durationBlocks, purchaseUnitBytes, satsPerUnit) {
|
|
52
|
+
if (!payment)
|
|
53
|
+
return 0;
|
|
54
|
+
const remaining = payment.paidThroughBlock - currentBlock;
|
|
55
|
+
if (remaining <= 0)
|
|
56
|
+
return 0;
|
|
57
|
+
const units = Math.max(1, Math.ceil(payment.bytesCovered / purchaseUnitBytes));
|
|
58
|
+
return Math.floor((units * satsPerUnit * remaining) / durationBlocks);
|
|
30
59
|
}
|
|
31
60
|
export { BYTES_PER_GB };
|
|
32
61
|
//# sourceMappingURL=pricing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/accounts/pricing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/accounts/pricing.ts"],"names":[],"mappings":"AAQA,MAAM,YAAY,GAAG,aAAa,CAAA,CAAC,SAAS;AAgB5C,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,CAAC,cAAc,EAC3B,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAC9B,KAAK,CAAC,MAAM,CAAC,WAAW,CACxB,CAAA;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC,CAAA;IACrD,MAAM,gBAAgB,GAAG,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,CAAA;IAEzE,OAAO;QACN,YAAY;QACZ,YAAY;QACZ,QAAQ;QACR,UAAU;QACV,UAAU;QACV,gBAAgB;KAChB,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC/B,OAAsC,EACtC,YAAoB,EACpB,cAAsB,EACtB,iBAAyB,EACzB,WAAmB;IAEnB,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,CAAA;IACtB,MAAM,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,YAAY,CAAA;IACzD,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,iBAAiB,CAAC,CAAC,CAAA;IAC9E,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC,GAAG,cAAc,CAAC,CAAA;AACtE,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query helpers that let the server's own wallet act as the storage-payment
|
|
3
|
+
* ledger. Payments are BRC-29 internalizations tagged with a structured set
|
|
4
|
+
* of transaction labels:
|
|
5
|
+
*
|
|
6
|
+
* - `wallet-storage-payment` — anchor for discovery
|
|
7
|
+
* - `payer:<identityKey>` — per-payer filter
|
|
8
|
+
* - `bytes:<bytesCovered>` — capacity purchased, parsed on read
|
|
9
|
+
* - `block:<paidThrough>` — last valid block, parsed on read
|
|
10
|
+
*
|
|
11
|
+
* Kept as label strings (not customInstructions / description JSON) because
|
|
12
|
+
* (a) labels are indexed for listActions filtering, and (b) BRC-29 wallet-
|
|
13
|
+
* payment internalize doesn't accept output tags or customInstructions
|
|
14
|
+
* alongside `paymentRemittance`.
|
|
15
|
+
*/
|
|
16
|
+
import type { WalletInterface } from '@bsv/sdk';
|
|
17
|
+
import type { IdentityKey } from './types';
|
|
18
|
+
export declare const PAYMENT_LABEL = "wallet-storage-payment";
|
|
19
|
+
export declare function payerLabel(identityKey: IdentityKey): string;
|
|
20
|
+
export declare function bytesLabel(bytes: number): string;
|
|
21
|
+
export declare function blockLabel(block: number): string;
|
|
22
|
+
/** Structured view of a payment extracted from an action's labels. */
|
|
23
|
+
export interface PaymentRecord {
|
|
24
|
+
txid: string;
|
|
25
|
+
bytesCovered: number;
|
|
26
|
+
paidThroughBlock: number;
|
|
27
|
+
satsPaid: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* All storage-payment actions ever recorded for this payer, oldest first
|
|
31
|
+
* (listActions orders by ascending transactionId).
|
|
32
|
+
*/
|
|
33
|
+
export declare function listPaymentsForPayer(wallet: WalletInterface, identityKey: IdentityKey): Promise<PaymentRecord[]>;
|
|
34
|
+
export declare function countPaymentsForPayer(wallet: WalletInterface, identityKey: IdentityKey): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Refund-credit model: a new payment always supersedes any prior payment,
|
|
37
|
+
* so the most recent payment whose `paidThroughBlock > currentBlock` is the
|
|
38
|
+
* one that governs current capacity. Returns undefined if there is no such
|
|
39
|
+
* active payment.
|
|
40
|
+
*/
|
|
41
|
+
export declare function latestActivePaymentForPayer(wallet: WalletInterface, identityKey: IdentityKey, currentBlock: number): Promise<PaymentRecord | undefined>;
|
|
42
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/accounts/queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,aAAa,2BAA2B,CAAA;AAErD,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAE3D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;CAChB;AAoBD;;;GAGG;AACH,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,GACtB,OAAO,CAAC,aAAa,EAAE,CAAC,CAqB1B;AAED,wBAAsB,qBAAqB,CAC1C,MAAM,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,GACtB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAChD,MAAM,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAOpC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query helpers that let the server's own wallet act as the storage-payment
|
|
3
|
+
* ledger. Payments are BRC-29 internalizations tagged with a structured set
|
|
4
|
+
* of transaction labels:
|
|
5
|
+
*
|
|
6
|
+
* - `wallet-storage-payment` — anchor for discovery
|
|
7
|
+
* - `payer:<identityKey>` — per-payer filter
|
|
8
|
+
* - `bytes:<bytesCovered>` — capacity purchased, parsed on read
|
|
9
|
+
* - `block:<paidThrough>` — last valid block, parsed on read
|
|
10
|
+
*
|
|
11
|
+
* Kept as label strings (not customInstructions / description JSON) because
|
|
12
|
+
* (a) labels are indexed for listActions filtering, and (b) BRC-29 wallet-
|
|
13
|
+
* payment internalize doesn't accept output tags or customInstructions
|
|
14
|
+
* alongside `paymentRemittance`.
|
|
15
|
+
*/
|
|
16
|
+
export const PAYMENT_LABEL = 'wallet-storage-payment';
|
|
17
|
+
export function payerLabel(identityKey) {
|
|
18
|
+
return `payer:${identityKey}`;
|
|
19
|
+
}
|
|
20
|
+
export function bytesLabel(bytes) {
|
|
21
|
+
return `bytes:${bytes}`;
|
|
22
|
+
}
|
|
23
|
+
export function blockLabel(block) {
|
|
24
|
+
return `block:${block}`;
|
|
25
|
+
}
|
|
26
|
+
function parsePaymentLabels(labels) {
|
|
27
|
+
let bytesCovered;
|
|
28
|
+
let paidThroughBlock;
|
|
29
|
+
for (const label of labels) {
|
|
30
|
+
if (label.startsWith('bytes:')) {
|
|
31
|
+
const n = Number(label.slice(6));
|
|
32
|
+
if (Number.isFinite(n))
|
|
33
|
+
bytesCovered = n;
|
|
34
|
+
}
|
|
35
|
+
else if (label.startsWith('block:')) {
|
|
36
|
+
const n = Number(label.slice(6));
|
|
37
|
+
if (Number.isFinite(n))
|
|
38
|
+
paidThroughBlock = n;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return { bytesCovered, paidThroughBlock };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* All storage-payment actions ever recorded for this payer, oldest first
|
|
45
|
+
* (listActions orders by ascending transactionId).
|
|
46
|
+
*/
|
|
47
|
+
export async function listPaymentsForPayer(wallet, identityKey) {
|
|
48
|
+
const { actions } = await wallet.listActions({
|
|
49
|
+
labels: [PAYMENT_LABEL, payerLabel(identityKey)],
|
|
50
|
+
labelQueryMode: 'all',
|
|
51
|
+
includeLabels: true,
|
|
52
|
+
limit: 10000,
|
|
53
|
+
});
|
|
54
|
+
const records = [];
|
|
55
|
+
for (const action of actions) {
|
|
56
|
+
const { bytesCovered, paidThroughBlock } = parsePaymentLabels(action.labels ?? []);
|
|
57
|
+
if (bytesCovered == null || paidThroughBlock == null)
|
|
58
|
+
continue;
|
|
59
|
+
records.push({
|
|
60
|
+
txid: action.txid,
|
|
61
|
+
bytesCovered,
|
|
62
|
+
paidThroughBlock,
|
|
63
|
+
satsPaid: action.satoshis,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return records;
|
|
67
|
+
}
|
|
68
|
+
export async function countPaymentsForPayer(wallet, identityKey) {
|
|
69
|
+
const result = await wallet.listActions({
|
|
70
|
+
labels: [PAYMENT_LABEL, payerLabel(identityKey)],
|
|
71
|
+
labelQueryMode: 'all',
|
|
72
|
+
limit: 1,
|
|
73
|
+
});
|
|
74
|
+
return result.totalActions;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Refund-credit model: a new payment always supersedes any prior payment,
|
|
78
|
+
* so the most recent payment whose `paidThroughBlock > currentBlock` is the
|
|
79
|
+
* one that governs current capacity. Returns undefined if there is no such
|
|
80
|
+
* active payment.
|
|
81
|
+
*/
|
|
82
|
+
export async function latestActivePaymentForPayer(wallet, identityKey, currentBlock) {
|
|
83
|
+
const records = await listPaymentsForPayer(wallet, identityKey);
|
|
84
|
+
// listActions returns oldest first; walk from end for the latest.
|
|
85
|
+
for (let i = records.length - 1; i >= 0; i--) {
|
|
86
|
+
if (records[i].paidThroughBlock > currentBlock)
|
|
87
|
+
return records[i];
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/accounts/queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,CAAC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,CAAA;AACjB,CAAC"}
|
package/dist/accounts/types.d.ts
CHANGED
|
@@ -1,45 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Identity key (secp256k1 public key, hex) of an account owner.
|
|
3
|
-
* Acts as the primary key for accounts — 1:1 identity → account.
|
|
4
3
|
*/
|
|
5
4
|
export type IdentityKey = string;
|
|
6
|
-
export interface Account {
|
|
7
|
-
identityKey: IdentityKey;
|
|
8
|
-
createdAt: Date;
|
|
9
|
-
updatedAt: Date;
|
|
10
|
-
}
|
|
11
|
-
export interface Payment {
|
|
12
|
-
id: number;
|
|
13
|
-
identityKey: IdentityKey;
|
|
14
|
-
txid: string;
|
|
15
|
-
bytesCovered: number;
|
|
16
|
-
satsPaid: number;
|
|
17
|
-
paidThroughBlock: number;
|
|
18
|
-
appliedAt: Date;
|
|
19
|
-
}
|
|
20
|
-
export interface NewPayment {
|
|
21
|
-
identityKey: IdentityKey;
|
|
22
|
-
txid: string;
|
|
23
|
-
bytesCovered: number;
|
|
24
|
-
satsPaid: number;
|
|
25
|
-
paidThroughBlock: number;
|
|
26
|
-
}
|
|
27
5
|
export interface AccountsConfig {
|
|
28
6
|
enabled: boolean;
|
|
29
7
|
/** Free baseline in bytes allocated to every account. */
|
|
30
8
|
baselineBytes: number;
|
|
31
|
-
/**
|
|
32
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Capacity is purchased in chunks of this size. A deficit of any size
|
|
11
|
+
* rounds up to the next whole chunk; a single chunk's worth of capacity
|
|
12
|
+
* is added to the account. Defaults to 1 GB for production-style pricing;
|
|
13
|
+
* lower values (e.g. 1 KB) make dev-time testing cheap.
|
|
14
|
+
*/
|
|
15
|
+
purchaseUnitBytes: number;
|
|
16
|
+
/** Sats charged per purchase unit. */
|
|
17
|
+
satsPerUnit: number;
|
|
33
18
|
/** How many blocks a payment remains valid for (~1 month at 10-min blocks = 4383). */
|
|
34
19
|
durationBlocks: number;
|
|
35
20
|
/** Identity keys (hex pubkey) whose requests bypass metering. Server's own identity is auto-added. */
|
|
36
21
|
freeIdentityKeys?: IdentityKey[];
|
|
37
22
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
/**
|
|
24
|
+
* BRC-29 derivation the server expects on the next incoming payment. The
|
|
25
|
+
* prefix is a constant; the suffix is the monotonic payment count for this
|
|
26
|
+
* identity. Clients use these verbatim so the server can re-derive any
|
|
27
|
+
* historical payment address later for audit.
|
|
28
|
+
*/
|
|
29
|
+
export interface NextPaymentDerivation {
|
|
41
30
|
derivationPrefix: string;
|
|
42
|
-
|
|
43
|
-
expiresAt: number;
|
|
31
|
+
derivationSuffix: string;
|
|
44
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Response shape of `GET /account/status`. When accounts metering is
|
|
35
|
+
* disabled the capacity / pricing fields are omitted; callers should branch
|
|
36
|
+
* on `accountsEnabled` to know which fields are present.
|
|
37
|
+
*/
|
|
38
|
+
export type AccountStatusResponse = {
|
|
39
|
+
identityKey: IdentityKey;
|
|
40
|
+
serverIdentityKey: IdentityKey;
|
|
41
|
+
accountsEnabled: false;
|
|
42
|
+
currentBlock?: number;
|
|
43
|
+
usedBytes?: number;
|
|
44
|
+
} | {
|
|
45
|
+
identityKey: IdentityKey;
|
|
46
|
+
serverIdentityKey: IdentityKey;
|
|
47
|
+
accountsEnabled: true;
|
|
48
|
+
currentBlock: number;
|
|
49
|
+
usedBytes: number;
|
|
50
|
+
baselineBytes: number;
|
|
51
|
+
paidBytes: number;
|
|
52
|
+
capacityBytes: number;
|
|
53
|
+
deficitBytes: number;
|
|
54
|
+
paidThroughBlock: number | null;
|
|
55
|
+
pricing: {
|
|
56
|
+
purchaseUnitBytes: number;
|
|
57
|
+
satsPerUnit: number;
|
|
58
|
+
durationBlocks: number;
|
|
59
|
+
};
|
|
60
|
+
nextPayment: NextPaymentDerivation;
|
|
61
|
+
};
|
|
45
62
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/accounts/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/accounts/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,yDAAyD;IACzD,aAAa,EAAE,MAAM,CAAA;IACrB;;;;;OAKG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,sFAAsF;IACtF,cAAc,EAAE,MAAM,CAAA;IACtB,sGAAsG;IACtG,gBAAgB,CAAC,EAAE,WAAW,EAAE,CAAA;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAC9B;IACA,WAAW,EAAE,WAAW,CAAA;IACxB,iBAAiB,EAAE,WAAW,CAAA;IAC9B,eAAe,EAAE,KAAK,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACjB,GACD;IACA,WAAW,EAAE,WAAW,CAAA;IACxB,iBAAiB,EAAE,WAAW,CAAA;IAC9B,eAAe,EAAE,IAAI,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,OAAO,EAAE;QACR,iBAAiB,EAAE,MAAM,CAAA;QACzB,WAAW,EAAE,MAAM,CAAA;QACnB,cAAc,EAAE,MAAM,CAAA;KACtB,CAAA;IACD,WAAW,EAAE,qBAAqB,CAAA;CACjC,CAAA"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for talking to a wallet-server over BRC-100 mutual auth.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the `@1sat/client` service-client pattern — extends `BaseClient`
|
|
5
|
+
* and injects an `AuthFetch`-backed fetch so the same `request` plumbing
|
|
6
|
+
* works against authenticated endpoints.
|
|
7
|
+
*/
|
|
8
|
+
import { BaseClient } from '@1sat/client';
|
|
9
|
+
import type { WalletInterface } from '@bsv/sdk';
|
|
10
|
+
import type { AccountStatusResponse } from './accounts/types';
|
|
11
|
+
export interface WalletServerClientOptions {
|
|
12
|
+
timeout?: number;
|
|
13
|
+
fetch?: typeof fetch;
|
|
14
|
+
}
|
|
15
|
+
export declare class WalletServerClient extends BaseClient {
|
|
16
|
+
constructor(baseUrl: string, wallet: WalletInterface, options?: WalletServerClientOptions);
|
|
17
|
+
/** GET /account/status — per-identity usage + capacity + pricing snapshot. */
|
|
18
|
+
accountStatus(): Promise<AccountStatusResponse>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAE7D,MAAM,WAAW,yBAAyB;IACzC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACpB;AAED,qBAAa,kBAAmB,SAAQ,UAAU;gBAEhD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,yBAA8B;IASxC,8EAA8E;IAC9E,aAAa,IAAI,OAAO,CAAC,qBAAqB,CAAC;CAG/C"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for talking to a wallet-server over BRC-100 mutual auth.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the `@1sat/client` service-client pattern — extends `BaseClient`
|
|
5
|
+
* and injects an `AuthFetch`-backed fetch so the same `request` plumbing
|
|
6
|
+
* works against authenticated endpoints.
|
|
7
|
+
*/
|
|
8
|
+
import { BaseClient } from '@1sat/client';
|
|
9
|
+
import { AuthFetch } from '@bsv/sdk/auth';
|
|
10
|
+
export class WalletServerClient extends BaseClient {
|
|
11
|
+
constructor(baseUrl, wallet, options = {}) {
|
|
12
|
+
const authFetch = new AuthFetch(wallet);
|
|
13
|
+
super(baseUrl, {
|
|
14
|
+
timeout: options.timeout,
|
|
15
|
+
fetch: options.fetch ?? buildAuthFetchShim(authFetch),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** GET /account/status — per-identity usage + capacity + pricing snapshot. */
|
|
19
|
+
accountStatus() {
|
|
20
|
+
return this.request('/account/status');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function buildAuthFetchShim(authFetch) {
|
|
24
|
+
const shim = async (input, init) => {
|
|
25
|
+
const url = typeof input === 'string'
|
|
26
|
+
? input
|
|
27
|
+
: input instanceof URL
|
|
28
|
+
? input.toString()
|
|
29
|
+
: input.url;
|
|
30
|
+
return authFetch.fetch(url, init);
|
|
31
|
+
};
|
|
32
|
+
return shim;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAQzC,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IACjD,YACC,OAAe,EACf,MAAuB,EACvB,UAAqC,EAAE;QAEvC,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAA;QACvC,KAAK,CAAC,OAAO,EAAE;YACd,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,kBAAkB,CAAC,SAAS,CAAC;SACrD,CAAC,CAAA;IACH,CAAC;IAED,8EAA8E;IAC9E,aAAa;QACZ,OAAO,IAAI,CAAC,OAAO,CAAwB,iBAAiB,CAAC,CAAA;IAC9D,CAAC;CACD;AAED,SAAS,kBAAkB,CAAC,SAAoB;IAC/C,MAAM,IAAI,GAAG,KAAK,EAAE,KAAwB,EAAE,IAAkB,EAAE,EAAE;QACnE,MAAM,GAAG,GACR,OAAO,KAAK,KAAK,QAAQ;YACxB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,KAAK,YAAY,GAAG;gBACrB,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE;gBAClB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAA;QACd,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,IAAyC,CAAC,CAAA;IACvE,CAAC,CAAA;IACD,OAAO,IAA+B,CAAA;AACvC,CAAC"}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
import type { WalletInterface } from '@bsv/sdk';
|
|
1
2
|
import { type Express } from 'express';
|
|
2
|
-
import type { Knex } from 'knex';
|
|
3
3
|
import type { AccountsConfig } from './accounts/types';
|
|
4
4
|
import type { MakeWalletLogger, WalletStorageProvider } from './types';
|
|
5
5
|
export interface WalletServerAccounts {
|
|
6
6
|
config: AccountsConfig;
|
|
7
|
-
knex: Knex;
|
|
8
7
|
currentBlock: () => Promise<number>;
|
|
9
8
|
}
|
|
10
9
|
export interface WalletServerConfig {
|
|
10
|
+
/**
|
|
11
|
+
* The wallet-toolbox `WalletInterface` this server fronts. The server
|
|
12
|
+
* exposes this wallet's storage to remote BRC-100 callers, uses the
|
|
13
|
+
* wallet for mutual-auth signing, and calls `internalizeAction` on it to
|
|
14
|
+
* record received payments. The server's identity key is this wallet's
|
|
15
|
+
* identity key.
|
|
16
|
+
*/
|
|
17
|
+
wallet: WalletInterface;
|
|
11
18
|
storage: WalletStorageProvider;
|
|
12
|
-
|
|
19
|
+
/** Identity public key (hex) of the wallet. Used for mutual-auth and the
|
|
20
|
+
* accounts gate validator. */
|
|
21
|
+
serverIdentityKey: string;
|
|
13
22
|
listen: {
|
|
14
23
|
port: number;
|
|
15
24
|
host?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWalletServer.d.ts","sourceRoot":"","sources":["../src/createWalletServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createWalletServer.d.ts","sourceRoot":"","sources":["../src/createWalletServer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAgB,EACf,KAAK,OAAO,EAIZ,MAAM,SAAS,CAAA;AAOhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAItD,OAAO,KAAK,EACX,gBAAgB,EAEhB,qBAAqB,EACrB,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,cAAc,CAAA;IACtB,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,kBAAkB;IAClC;;;;;;OAMG;IACH,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,qBAAqB,CAAA;IAC9B;kCAC8B;IAC9B,iBAAiB,EAAE,MAAM,CAAA;IACzB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC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