@bsv/wallet-toolbox-client 2.1.25 → 3.0.0-alpha.0
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/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletLogger.d.ts.map +1 -1
- package/out/src/WalletLogger.js.map +1 -1
- package/out/src/monitor/LeasedMonitorTask.d.ts +43 -0
- package/out/src/monitor/LeasedMonitorTask.d.ts.map +1 -0
- package/out/src/monitor/LeasedMonitorTask.js +89 -0
- package/out/src/monitor/LeasedMonitorTask.js.map +1 -0
- package/out/src/monitor/Monitor.d.ts +7 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +7 -0
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/V7LeasedTask.d.ts +43 -0
- package/out/src/monitor/V7LeasedTask.d.ts.map +1 -0
- package/out/src/monitor/V7LeasedTask.js +89 -0
- package/out/src/monitor/V7LeasedTask.js.map +1 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +2 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +55 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/types.d.ts +32 -0
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +50 -1
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +10 -5
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +114 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +164 -4
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/idbHelpers.d.ts +5 -0
- package/out/src/storage/idbHelpers.d.ts.map +1 -1
- package/out/src/storage/idbHelpers.js +42 -0
- package/out/src/storage/idbHelpers.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +116 -4
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +22 -5
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +172 -5
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +82 -14
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/schema/StorageIdbSchema.d.ts +43 -2
- package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
- package/out/src/storage/schema/monitorLease.d.ts +57 -0
- package/out/src/storage/schema/monitorLease.d.ts.map +1 -0
- package/out/src/storage/schema/monitorLease.js +101 -0
- package/out/src/storage/schema/monitorLease.js.map +1 -0
- package/out/src/storage/schema/processingFsm.d.ts +27 -0
- package/out/src/storage/schema/processingFsm.d.ts.map +1 -0
- package/out/src/storage/schema/processingFsm.js +132 -0
- package/out/src/storage/schema/processingFsm.js.map +1 -0
- package/out/src/storage/schema/tables/TableAction.d.ts +38 -0
- package/out/src/storage/schema/tables/TableAction.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableAction.js +3 -0
- package/out/src/storage/schema/tables/TableAction.js.map +1 -0
- package/out/src/storage/schema/tables/TableChainTip.d.ts +17 -0
- package/out/src/storage/schema/tables/TableChainTip.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableChainTip.js +3 -0
- package/out/src/storage/schema/tables/TableChainTip.js.map +1 -0
- package/out/src/storage/schema/tables/TableMonitorLease.d.ts +23 -0
- package/out/src/storage/schema/tables/TableMonitorLease.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableMonitorLease.js +3 -0
- package/out/src/storage/schema/tables/TableMonitorLease.js.map +1 -0
- package/out/src/storage/schema/tables/TableOutput.d.ts +7 -0
- package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutput.js.map +1 -1
- package/out/src/storage/schema/tables/TableTransactionNew.d.ts +50 -0
- package/out/src/storage/schema/tables/TableTransactionNew.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTransactionNew.js +3 -0
- package/out/src/storage/schema/tables/TableTransactionNew.js.map +1 -0
- package/out/src/storage/schema/tables/TableTransactionV7.d.ts +50 -0
- package/out/src/storage/schema/tables/TableTransactionV7.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTransactionV7.js +3 -0
- package/out/src/storage/schema/tables/TableTransactionV7.js.map +1 -0
- package/out/src/storage/schema/tables/TableTxAudit.d.ts +26 -0
- package/out/src/storage/schema/tables/TableTxAudit.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTxAudit.js +3 -0
- package/out/src/storage/schema/tables/TableTxAudit.js.map +1 -0
- package/out/src/storage/schema/tables/index.d.ts +5 -0
- package/out/src/storage/schema/tables/index.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.js +5 -0
- package/out/src/storage/schema/tables/index.js.map +1 -1
- package/out/src/storage/schema/transactionCrud.d.ts +41 -0
- package/out/src/storage/schema/transactionCrud.d.ts.map +1 -0
- package/out/src/storage/schema/transactionCrud.js +205 -0
- package/out/src/storage/schema/transactionCrud.js.map +1 -0
- package/out/src/storage/schema/transactionService.d.ts +315 -0
- package/out/src/storage/schema/transactionService.d.ts.map +1 -0
- package/out/src/storage/schema/transactionService.js +783 -0
- package/out/src/storage/schema/transactionService.js.map +1 -0
- package/out/src/storage/schema/txAudit.d.ts +33 -0
- package/out/src/storage/schema/txAudit.d.ts.map +1 -0
- package/out/src/storage/schema/txAudit.js +64 -0
- package/out/src/storage/schema/txAudit.js.map +1 -0
- package/out/src/storage/schema/v7Crud.d.ts +41 -0
- package/out/src/storage/schema/v7Crud.d.ts.map +1 -0
- package/out/src/storage/schema/v7Crud.js +205 -0
- package/out/src/storage/schema/v7Crud.js.map +1 -0
- package/out/src/storage/schema/v7Fsm.d.ts +27 -0
- package/out/src/storage/schema/v7Fsm.d.ts.map +1 -0
- package/out/src/storage/schema/v7Fsm.js +124 -0
- package/out/src/storage/schema/v7Fsm.js.map +1 -0
- package/out/src/storage/schema/v7MonitorLease.d.ts +57 -0
- package/out/src/storage/schema/v7MonitorLease.d.ts.map +1 -0
- package/out/src/storage/schema/v7MonitorLease.js +101 -0
- package/out/src/storage/schema/v7MonitorLease.js.map +1 -0
- package/out/src/storage/schema/v7Service.d.ts +305 -0
- package/out/src/storage/schema/v7Service.d.ts.map +1 -0
- package/out/src/storage/schema/v7Service.js +757 -0
- package/out/src/storage/schema/v7Service.js.map +1 -0
- package/out/src/storage/schema/v7TxAudit.d.ts +33 -0
- package/out/src/storage/schema/v7TxAudit.d.ts.map +1 -0
- package/out/src/storage/schema/v7TxAudit.js +64 -0
- package/out/src/storage/schema/v7TxAudit.js.map +1 -0
- package/out/src/storage/storageProviderHelpers.js +1 -1
- package/out/src/storage/storageProviderHelpers.js.map +1 -1
- package/out/tsconfig.client.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as sdk from '../../../sdk';
|
|
2
|
+
/**
|
|
3
|
+
* per-event audit log for transactions and actions.
|
|
4
|
+
*
|
|
5
|
+
* Each row records a single observable event scoped to either a transaction
|
|
6
|
+
* (per-txid) or an action (per-user) or both. Append-only.
|
|
7
|
+
*/
|
|
8
|
+
export interface TableTxAudit extends sdk.EntityTimeStamp {
|
|
9
|
+
created_at: Date;
|
|
10
|
+
updated_at: Date;
|
|
11
|
+
/** PK */
|
|
12
|
+
auditId: number;
|
|
13
|
+
/** FK -> transactions.transactionId, optional for action-only events */
|
|
14
|
+
transactionId?: number;
|
|
15
|
+
/** FK -> actions.actionId, optional for tx-only events */
|
|
16
|
+
actionId?: number;
|
|
17
|
+
/** Stable event identifier, e.g. 'processing.changed', 'proof.acquired' */
|
|
18
|
+
event: string;
|
|
19
|
+
/** Optional FSM source state for transitions */
|
|
20
|
+
fromState?: string;
|
|
21
|
+
/** Optional FSM target state for transitions */
|
|
22
|
+
toState?: string;
|
|
23
|
+
/** JSON-encoded event payload */
|
|
24
|
+
detailsJson?: string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=TableTxAudit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableTxAudit.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableTxAudit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,GAAG,CAAC,eAAe;IACvD,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS;IACT,OAAO,EAAE,MAAM,CAAA;IACf,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableTxAudit.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableTxAudit.ts"],"names":[],"mappings":""}
|
|
@@ -14,4 +14,9 @@ export * from './TableTxLabel';
|
|
|
14
14
|
export * from './TableTxLabelMap';
|
|
15
15
|
export * from './TableMonitorEvent';
|
|
16
16
|
export * from './TableSyncState';
|
|
17
|
+
export * from './TableAction';
|
|
18
|
+
export * from './TableTransactionNew';
|
|
19
|
+
export * from './TableChainTip';
|
|
20
|
+
export * from './TableTxAudit';
|
|
21
|
+
export * from './TableMonitorLease';
|
|
17
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA"}
|
|
@@ -30,4 +30,9 @@ __exportStar(require("./TableTxLabel"), exports);
|
|
|
30
30
|
__exportStar(require("./TableTxLabelMap"), exports);
|
|
31
31
|
__exportStar(require("./TableMonitorEvent"), exports);
|
|
32
32
|
__exportStar(require("./TableSyncState"), exports);
|
|
33
|
+
__exportStar(require("./TableAction"), exports);
|
|
34
|
+
__exportStar(require("./TableTransactionNew"), exports);
|
|
35
|
+
__exportStar(require("./TableChainTip"), exports);
|
|
36
|
+
__exportStar(require("./TableTxAudit"), exports);
|
|
37
|
+
__exportStar(require("./TableMonitorLease"), exports);
|
|
33
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,kDAA+B;AAC/B,qDAAkC;AAClC,8CAA2B;AAC3B,qDAAkC;AAClC,0DAAuC;AACvC,sDAAmC;AACnC,qDAAkC;AAClC,oDAAiC;AACjC,gDAA6B;AAC7B,mDAAgC;AAChC,sDAAmC;AACnC,iDAA8B;AAC9B,oDAAiC;AACjC,sDAAmC;AACnC,mDAAgC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,kDAA+B;AAC/B,qDAAkC;AAClC,8CAA2B;AAC3B,qDAAkC;AAClC,0DAAuC;AACvC,sDAAmC;AACnC,qDAAkC;AAClC,oDAAiC;AACjC,gDAA6B;AAC7B,mDAAgC;AAChC,sDAAmC;AACnC,iDAA8B;AAC9B,oDAAiC;AACjC,sDAAmC;AACnC,mDAAgC;AAChC,gDAA6B;AAC7B,wDAAqC;AACrC,kDAA+B;AAC/B,iDAA8B;AAC9B,sDAAmC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Knex } from 'knex';
|
|
2
|
+
import * as sdk from '../../sdk';
|
|
3
|
+
import { TableAction, TableChainTip, TableTransactionNew } from './tables';
|
|
4
|
+
/** Read a single `transactions` (new canonical) row by txid, returning `undefined` if absent. */
|
|
5
|
+
export declare function findTransactionNewByTxid(knex: Knex, txid: string): Promise<TableTransactionNew | undefined>;
|
|
6
|
+
/** Read a single `transactions` (new canonical) row by PK. */
|
|
7
|
+
export declare function findTransactionNew(knex: Knex, transactionId: number): Promise<TableTransactionNew | undefined>;
|
|
8
|
+
/** Insert a new `transactions` (new canonical) row. Caller supplies the full body. */
|
|
9
|
+
export declare function insertTransactionNew(knex: Knex, row: Omit<TableTransactionNew, 'transactionId' | 'created_at' | 'updated_at'>, now?: Date): Promise<number>;
|
|
10
|
+
/**
|
|
11
|
+
* Transition the processing column atomically and append a `tx_audit` row.
|
|
12
|
+
* Returns the new `TableTransactionNew` on success and `undefined` when the
|
|
13
|
+
* source state did not match the row (CAS failed) or the transition was
|
|
14
|
+
* rejected by the FSM.
|
|
15
|
+
*
|
|
16
|
+
* Optimistic concurrency: the caller passes the `expectedFromState` they
|
|
17
|
+
* read in the same logical operation; the update only fires when the row's
|
|
18
|
+
* current `processing` still equals that value.
|
|
19
|
+
*/
|
|
20
|
+
export declare function transitionProcessing(knex: Knex, args: {
|
|
21
|
+
transactionId: number;
|
|
22
|
+
expectedFromState: sdk.ProcessingStatus;
|
|
23
|
+
toState: sdk.ProcessingStatus;
|
|
24
|
+
details?: Record<string, unknown>;
|
|
25
|
+
provider?: string;
|
|
26
|
+
providerStatus?: string;
|
|
27
|
+
}, now?: Date): Promise<TableTransactionNew | undefined>;
|
|
28
|
+
/** Find an action row by `(userId, transactionId)`. */
|
|
29
|
+
export declare function findAction(knex: Knex, userId: number, transactionId: number): Promise<TableAction | undefined>;
|
|
30
|
+
export declare function insertAction(knex: Knex, row: Omit<TableAction, 'actionId' | 'created_at' | 'updated_at'>, now?: Date): Promise<number>;
|
|
31
|
+
/** Get the singleton chain tip row (`id = 1`). */
|
|
32
|
+
export declare function getChainTip(knex: Knex): Promise<TableChainTip | undefined>;
|
|
33
|
+
/** Upsert the singleton chain tip. Always uses `id = 1`. */
|
|
34
|
+
export declare function setChainTip(knex: Knex, args: {
|
|
35
|
+
height: number;
|
|
36
|
+
blockHash: string;
|
|
37
|
+
merkleRoot?: string;
|
|
38
|
+
}, now?: Date): Promise<void>;
|
|
39
|
+
export declare function mapTransactionRow(row: any): TableTransactionNew;
|
|
40
|
+
export declare function mapActionRow(row: any): TableAction;
|
|
41
|
+
//# sourceMappingURL=transactionCrud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionCrud.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/transactionCrud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,KAAK,GAAG,MAAM,WAAW,CAAA;AAChC,OAAO,EACL,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAA;AAGjB,iGAAiG;AACjG,wBAAsB,wBAAwB,CAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAGlH;AAED,8DAA8D;AAC9D,wBAAsB,kBAAkB,CAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAGrH;AAED,sFAAsF;AACtF,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC,EAC7E,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,MAAM,CAAC,CAKjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV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
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findTransactionNewByTxid = findTransactionNewByTxid;
|
|
4
|
+
exports.findTransactionNew = findTransactionNew;
|
|
5
|
+
exports.insertTransactionNew = insertTransactionNew;
|
|
6
|
+
exports.transitionProcessing = transitionProcessing;
|
|
7
|
+
exports.findAction = findAction;
|
|
8
|
+
exports.insertAction = insertAction;
|
|
9
|
+
exports.getChainTip = getChainTip;
|
|
10
|
+
exports.setChainTip = setChainTip;
|
|
11
|
+
exports.mapTransactionRow = mapTransactionRow;
|
|
12
|
+
exports.mapActionRow = mapActionRow;
|
|
13
|
+
const txAudit_1 = require("./txAudit");
|
|
14
|
+
/** Read a single `transactions` (new canonical) row by txid, returning `undefined` if absent. */
|
|
15
|
+
async function findTransactionNewByTxid(knex, txid) {
|
|
16
|
+
const row = await knex('transactions').where({ txid }).first();
|
|
17
|
+
return row != null ? mapTransactionRow(row) : undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Read a single `transactions` (new canonical) row by PK. */
|
|
20
|
+
async function findTransactionNew(knex, transactionId) {
|
|
21
|
+
const row = await knex('transactions').where({ transactionId }).first();
|
|
22
|
+
return row != null ? mapTransactionRow(row) : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Insert a new `transactions` (new canonical) row. Caller supplies the full body. */
|
|
25
|
+
async function insertTransactionNew(knex, row, now = new Date()) {
|
|
26
|
+
const [id] = await knex('transactions').insert(unmapTransactionRow(row, now));
|
|
27
|
+
if (typeof id === 'number' && id > 0)
|
|
28
|
+
return id;
|
|
29
|
+
const r = await knex('transactions').where({ txid: row.txid }).first('transactionId');
|
|
30
|
+
return r.transactionId;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Transition the processing column atomically and append a `tx_audit` row.
|
|
34
|
+
* Returns the new `TableTransactionNew` on success and `undefined` when the
|
|
35
|
+
* source state did not match the row (CAS failed) or the transition was
|
|
36
|
+
* rejected by the FSM.
|
|
37
|
+
*
|
|
38
|
+
* Optimistic concurrency: the caller passes the `expectedFromState` they
|
|
39
|
+
* read in the same logical operation; the update only fires when the row's
|
|
40
|
+
* current `processing` still equals that value.
|
|
41
|
+
*/
|
|
42
|
+
async function transitionProcessing(knex, args, now = new Date()) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
const ok = await (0, txAudit_1.auditProcessingTransition)(knex, args.transactionId, args.expectedFromState, args.toState, args.details, now);
|
|
45
|
+
if (!ok)
|
|
46
|
+
return undefined;
|
|
47
|
+
const updated = await knex('transactions')
|
|
48
|
+
.where({ transactionId: args.transactionId, processing: args.expectedFromState })
|
|
49
|
+
.update({
|
|
50
|
+
processing: args.toState,
|
|
51
|
+
processing_changed_at: now,
|
|
52
|
+
last_provider: (_a = args.provider) !== null && _a !== void 0 ? _a : null,
|
|
53
|
+
last_provider_status: (_b = args.providerStatus) !== null && _b !== void 0 ? _b : null,
|
|
54
|
+
updated_at: now
|
|
55
|
+
});
|
|
56
|
+
if (updated === 0)
|
|
57
|
+
return undefined;
|
|
58
|
+
const row = await knex('transactions').where({ transactionId: args.transactionId }).first();
|
|
59
|
+
return mapTransactionRow(row);
|
|
60
|
+
}
|
|
61
|
+
/** Find an action row by `(userId, transactionId)`. */
|
|
62
|
+
async function findAction(knex, userId, transactionId) {
|
|
63
|
+
const row = await knex('actions').where({ userId, transactionId }).first();
|
|
64
|
+
return row != null ? mapActionRow(row) : undefined;
|
|
65
|
+
}
|
|
66
|
+
async function insertAction(knex, row, now = new Date()) {
|
|
67
|
+
var _a;
|
|
68
|
+
const [id] = await knex('actions').insert({
|
|
69
|
+
userId: row.userId,
|
|
70
|
+
transactionId: row.transactionId,
|
|
71
|
+
reference: row.reference,
|
|
72
|
+
description: row.description,
|
|
73
|
+
isOutgoing: row.isOutgoing,
|
|
74
|
+
satoshis_delta: row.satoshisDelta,
|
|
75
|
+
user_nosend: row.userNosend,
|
|
76
|
+
hidden: row.hidden,
|
|
77
|
+
user_aborted: row.userAborted,
|
|
78
|
+
notify_json: (_a = row.notifyJson) !== null && _a !== void 0 ? _a : null,
|
|
79
|
+
row_version: row.rowVersion,
|
|
80
|
+
created_at: now,
|
|
81
|
+
updated_at: now
|
|
82
|
+
});
|
|
83
|
+
if (typeof id === 'number' && id > 0)
|
|
84
|
+
return id;
|
|
85
|
+
const r = await knex('actions').where({ userId: row.userId, transactionId: row.transactionId }).first('actionId');
|
|
86
|
+
return r.actionId;
|
|
87
|
+
}
|
|
88
|
+
/** Get the singleton chain tip row (`id = 1`). */
|
|
89
|
+
async function getChainTip(knex) {
|
|
90
|
+
const row = await knex('chain_tip').where({ id: 1 }).first();
|
|
91
|
+
return row != null ? mapChainTipRow(row) : undefined;
|
|
92
|
+
}
|
|
93
|
+
/** Upsert the singleton chain tip. Always uses `id = 1`. */
|
|
94
|
+
async function setChainTip(knex, args, now = new Date()) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
const existing = await knex('chain_tip').where({ id: 1 }).first('id');
|
|
97
|
+
if (existing == null) {
|
|
98
|
+
await knex('chain_tip').insert({
|
|
99
|
+
id: 1,
|
|
100
|
+
height: args.height,
|
|
101
|
+
block_hash: args.blockHash,
|
|
102
|
+
merkle_root: (_a = args.merkleRoot) !== null && _a !== void 0 ? _a : null,
|
|
103
|
+
observed_at: now,
|
|
104
|
+
created_at: now,
|
|
105
|
+
updated_at: now
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
await knex('chain_tip').where({ id: 1 }).update({
|
|
110
|
+
height: args.height,
|
|
111
|
+
block_hash: args.blockHash,
|
|
112
|
+
merkle_root: (_b = args.merkleRoot) !== null && _b !== void 0 ? _b : null,
|
|
113
|
+
observed_at: now,
|
|
114
|
+
updated_at: now
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function mapTransactionRow(row) {
|
|
118
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
119
|
+
return {
|
|
120
|
+
created_at: new Date(row.created_at),
|
|
121
|
+
updated_at: new Date(row.updated_at),
|
|
122
|
+
transactionId: row.transactionId,
|
|
123
|
+
txid: row.txid,
|
|
124
|
+
processing: row.processing,
|
|
125
|
+
processingChangedAt: new Date(row.processing_changed_at),
|
|
126
|
+
nextActionAt: row.next_action_at != null ? new Date(row.next_action_at) : undefined,
|
|
127
|
+
attempts: row.attempts,
|
|
128
|
+
rebroadcastCycles: row.rebroadcast_cycles,
|
|
129
|
+
wasBroadcast: !!row.was_broadcast,
|
|
130
|
+
idempotencyKey: (_a = row.idempotency_key) !== null && _a !== void 0 ? _a : undefined,
|
|
131
|
+
batch: (_b = row.batch) !== null && _b !== void 0 ? _b : undefined,
|
|
132
|
+
rawTx: row.raw_tx != null ? Array.from(row.raw_tx.values()) : undefined,
|
|
133
|
+
inputBeef: row.input_beef != null ? Array.from(row.input_beef.values()) : undefined,
|
|
134
|
+
height: (_c = row.height) !== null && _c !== void 0 ? _c : undefined,
|
|
135
|
+
merkleIndex: (_d = row.merkle_index) !== null && _d !== void 0 ? _d : undefined,
|
|
136
|
+
merklePath: row.merkle_path != null ? Array.from(row.merkle_path.values()) : undefined,
|
|
137
|
+
merkleRoot: (_e = row.merkle_root) !== null && _e !== void 0 ? _e : undefined,
|
|
138
|
+
blockHash: (_f = row.block_hash) !== null && _f !== void 0 ? _f : undefined,
|
|
139
|
+
isCoinbase: !!row.is_coinbase,
|
|
140
|
+
lastProvider: (_g = row.last_provider) !== null && _g !== void 0 ? _g : undefined,
|
|
141
|
+
lastProviderStatus: (_h = row.last_provider_status) !== null && _h !== void 0 ? _h : undefined,
|
|
142
|
+
frozenReason: (_j = row.frozen_reason) !== null && _j !== void 0 ? _j : undefined,
|
|
143
|
+
rowVersion: row.row_version
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function unmapTransactionRow(row, now) {
|
|
147
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
148
|
+
return {
|
|
149
|
+
txid: row.txid,
|
|
150
|
+
processing: row.processing,
|
|
151
|
+
processing_changed_at: row.processingChangedAt,
|
|
152
|
+
next_action_at: (_a = row.nextActionAt) !== null && _a !== void 0 ? _a : null,
|
|
153
|
+
attempts: row.attempts,
|
|
154
|
+
rebroadcast_cycles: row.rebroadcastCycles,
|
|
155
|
+
was_broadcast: row.wasBroadcast,
|
|
156
|
+
idempotency_key: (_b = row.idempotencyKey) !== null && _b !== void 0 ? _b : null,
|
|
157
|
+
batch: (_c = row.batch) !== null && _c !== void 0 ? _c : null,
|
|
158
|
+
raw_tx: row.rawTx != null ? Buffer.from(row.rawTx) : null,
|
|
159
|
+
input_beef: row.inputBeef != null ? Buffer.from(row.inputBeef) : null,
|
|
160
|
+
height: (_d = row.height) !== null && _d !== void 0 ? _d : null,
|
|
161
|
+
merkle_index: (_e = row.merkleIndex) !== null && _e !== void 0 ? _e : null,
|
|
162
|
+
merkle_path: row.merklePath != null ? Buffer.from(row.merklePath) : null,
|
|
163
|
+
merkle_root: (_f = row.merkleRoot) !== null && _f !== void 0 ? _f : null,
|
|
164
|
+
block_hash: (_g = row.blockHash) !== null && _g !== void 0 ? _g : null,
|
|
165
|
+
is_coinbase: row.isCoinbase,
|
|
166
|
+
last_provider: (_h = row.lastProvider) !== null && _h !== void 0 ? _h : null,
|
|
167
|
+
last_provider_status: (_j = row.lastProviderStatus) !== null && _j !== void 0 ? _j : null,
|
|
168
|
+
frozen_reason: (_k = row.frozenReason) !== null && _k !== void 0 ? _k : null,
|
|
169
|
+
row_version: row.rowVersion,
|
|
170
|
+
created_at: now,
|
|
171
|
+
updated_at: now
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function mapActionRow(row) {
|
|
175
|
+
var _a;
|
|
176
|
+
return {
|
|
177
|
+
created_at: new Date(row.created_at),
|
|
178
|
+
updated_at: new Date(row.updated_at),
|
|
179
|
+
actionId: row.actionId,
|
|
180
|
+
userId: row.userId,
|
|
181
|
+
transactionId: row.transactionId,
|
|
182
|
+
reference: row.reference,
|
|
183
|
+
description: row.description,
|
|
184
|
+
isOutgoing: !!row.isOutgoing,
|
|
185
|
+
satoshisDelta: row.satoshis_delta,
|
|
186
|
+
userNosend: !!row.user_nosend,
|
|
187
|
+
hidden: !!row.hidden,
|
|
188
|
+
userAborted: !!row.user_aborted,
|
|
189
|
+
notifyJson: (_a = row.notify_json) !== null && _a !== void 0 ? _a : undefined,
|
|
190
|
+
rowVersion: row.row_version
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function mapChainTipRow(row) {
|
|
194
|
+
var _a;
|
|
195
|
+
return {
|
|
196
|
+
created_at: new Date(row.created_at),
|
|
197
|
+
updated_at: new Date(row.updated_at),
|
|
198
|
+
id: row.id,
|
|
199
|
+
height: row.height,
|
|
200
|
+
blockHash: row.block_hash,
|
|
201
|
+
merkleRoot: (_a = row.merkle_root) !== null && _a !== void 0 ? _a : undefined,
|
|
202
|
+
observedAt: new Date(row.observed_at)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=transactionCrud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionCrud.js","sourceRoot":"","sources":["../../../../../src/storage/schema/transactionCrud.ts"],"names":[],"mappings":";;AAUA,4DAGC;AAGD,gDAGC;AAGD,oDASC;AAYD,oDAiCC;AAGD,gCAOC;AAED,oCAuBC;AAGD,kCAGC;AAGD,kCAyBC;AAED,8CA2BC;AAiCD,oCAiBC;AAzND,uCAAqD;AAErD,iGAAiG;AAC1F,KAAK,UAAU,wBAAwB,CAAE,IAAU,EAAE,IAAY;IACtE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;IAC9D,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACzD,CAAC;AAED,8DAA8D;AACvD,KAAK,UA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4
|
+
import { TableAction, TableOutput, TableTransactionNew } from './tables';
|
|
5
|
+
import { MonitorLeaseClaim, MonitorLeaseRelease, MonitorLeaseRenew, MonitorLeaseResult } from './monitorLease';
|
|
6
|
+
/**
|
|
7
|
+
* High-level service over the new-schema storage primitives.
|
|
8
|
+
*
|
|
9
|
+
* Storage methods and the Monitor call into this surface rather than the
|
|
10
|
+
* lower-level CRUD/FSM/audit/lease modules so that:
|
|
11
|
+
* - Every processing transition is audited.
|
|
12
|
+
* - Optimistic concurrency is uniformly enforced.
|
|
13
|
+
* - Chain tip + monitor lease access have one canonical entry point.
|
|
14
|
+
*
|
|
15
|
+
* Construction takes a Knex handle; instances are stateless and cheap to
|
|
16
|
+
* create — typically one per request or per Monitor task tick.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Extract the merkle leaf index for `txid` from a BUMP-encoded merkle path.
|
|
20
|
+
*
|
|
21
|
+
* The BUMP format encodes level 0 leaves with `txid: true` and an `offset`
|
|
22
|
+
* equal to the position of the transaction in its block. For a single-tx
|
|
23
|
+
* proof exactly one leaf is flagged; for trimmed compound proofs the leaf
|
|
24
|
+
* matching `txid` is selected.
|
|
25
|
+
*/
|
|
26
|
+
export declare function indexFromMerklePath(merklePath: number[], txid: string): number;
|
|
27
|
+
export declare class TransactionService {
|
|
28
|
+
private readonly knex;
|
|
29
|
+
constructor(knex: Knex);
|
|
30
|
+
findByTxid(txid: string): Promise<TableTransactionNew | undefined>;
|
|
31
|
+
findById(transactionId: number): Promise<TableTransactionNew | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Insert a new new transaction row. The row is created in `queued` state
|
|
34
|
+
* unless the caller overrides `processing`.
|
|
35
|
+
*/
|
|
36
|
+
create(args: {
|
|
37
|
+
txid: string;
|
|
38
|
+
processing?: sdk.ProcessingStatus;
|
|
39
|
+
rawTx?: number[];
|
|
40
|
+
inputBeef?: number[];
|
|
41
|
+
batch?: string;
|
|
42
|
+
idempotencyKey?: string;
|
|
43
|
+
isCoinbase?: boolean;
|
|
44
|
+
now?: Date;
|
|
45
|
+
}): Promise<TableTransactionNew>;
|
|
46
|
+
/**
|
|
47
|
+
* Transition processing state with optimistic concurrency. Returns
|
|
48
|
+
* `undefined` when the FSM rejects the move OR the row's current state no
|
|
49
|
+
* longer matches `expectedFrom`.
|
|
50
|
+
*/
|
|
51
|
+
transition(args: {
|
|
52
|
+
transactionId: number;
|
|
53
|
+
expectedFrom: sdk.ProcessingStatus;
|
|
54
|
+
to: sdk.ProcessingStatus;
|
|
55
|
+
provider?: string;
|
|
56
|
+
providerStatus?: string;
|
|
57
|
+
details?: Record<string, unknown>;
|
|
58
|
+
now?: Date;
|
|
59
|
+
}): Promise<TableTransactionNew | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Record acquisition of a Merkle proof for a transaction. Atomically:
|
|
62
|
+
* - Updates proof columns (height, index, merkle_path, merkle_root, block_hash)
|
|
63
|
+
* - Transitions processing to `confirmed` from any spendable-class state.
|
|
64
|
+
* - Writes a `proof.acquired` audit row.
|
|
65
|
+
*
|
|
66
|
+
* The merkle leaf index is derived from `merklePath` (BUMP) using the row's
|
|
67
|
+
* `txid`; callers do not pass it.
|
|
68
|
+
*/
|
|
69
|
+
recordProof(args: {
|
|
70
|
+
transactionId: number;
|
|
71
|
+
height: number;
|
|
72
|
+
merklePath: number[];
|
|
73
|
+
merkleRoot: string;
|
|
74
|
+
blockHash: string;
|
|
75
|
+
expectedFrom: sdk.ProcessingStatus;
|
|
76
|
+
now?: Date;
|
|
77
|
+
}): Promise<TableTransactionNew | undefined>;
|
|
78
|
+
findActionForUser(userId: number, transactionId: number): Promise<TableAction | undefined>;
|
|
79
|
+
createAction(args: {
|
|
80
|
+
userId: number;
|
|
81
|
+
transactionId: number;
|
|
82
|
+
reference: string;
|
|
83
|
+
description: string;
|
|
84
|
+
isOutgoing: boolean;
|
|
85
|
+
satoshisDelta: number;
|
|
86
|
+
userNosend?: boolean;
|
|
87
|
+
notifyJson?: string;
|
|
88
|
+
now?: Date;
|
|
89
|
+
}): Promise<number>;
|
|
90
|
+
getChainTip(): Promise<{
|
|
91
|
+
height: number;
|
|
92
|
+
blockHash: string;
|
|
93
|
+
} | undefined>;
|
|
94
|
+
setChainTip(args: {
|
|
95
|
+
height: number;
|
|
96
|
+
blockHash: string;
|
|
97
|
+
merkleRoot?: string;
|
|
98
|
+
now?: Date;
|
|
99
|
+
}): Promise<void>;
|
|
100
|
+
tryClaimLease(claim: MonitorLeaseClaim, now?: Date): Promise<MonitorLeaseResult>;
|
|
101
|
+
renewLease(renew: MonitorLeaseRenew, now?: Date): Promise<MonitorLeaseResult>;
|
|
102
|
+
releaseLease(release: MonitorLeaseRelease): Promise<boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* #1 — Look up an action + its backing transaction by (userId, reference).
|
|
105
|
+
*/
|
|
106
|
+
findActionByReference(userId: number, reference: string): Promise<{
|
|
107
|
+
action: TableAction;
|
|
108
|
+
transaction: TableTransactionNew;
|
|
109
|
+
} | undefined>;
|
|
110
|
+
/**
|
|
111
|
+
* #2 — Look up an action + its backing transaction by (userId, txid).
|
|
112
|
+
*/
|
|
113
|
+
findActionByUserTxid(userId: number, txid: string): Promise<{
|
|
114
|
+
action: TableAction;
|
|
115
|
+
transaction: TableTransactionNew;
|
|
116
|
+
} | undefined>;
|
|
117
|
+
/**
|
|
118
|
+
* #3 — Upsert: find existing action for (userId, txid) or create both the new
|
|
119
|
+
* transaction row and the action row.
|
|
120
|
+
*/
|
|
121
|
+
findOrCreateActionForTxid(args: {
|
|
122
|
+
userId: number;
|
|
123
|
+
txid: string;
|
|
124
|
+
isOutgoing: boolean;
|
|
125
|
+
description: string;
|
|
126
|
+
satoshisDelta: number;
|
|
127
|
+
reference: string;
|
|
128
|
+
rawTx?: number[];
|
|
129
|
+
inputBeef?: number[];
|
|
130
|
+
processing?: sdk.ProcessingStatus;
|
|
131
|
+
now?: Date;
|
|
132
|
+
}): Promise<{
|
|
133
|
+
action: TableAction;
|
|
134
|
+
transaction: TableTransactionNew;
|
|
135
|
+
isNew: boolean;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* #4 — Atomically update the satoshisDelta column on an action row.
|
|
139
|
+
*/
|
|
140
|
+
updateActionSatoshisDelta(actionId: number, delta: number, now?: Date): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* #5 — Create a new transaction row already in `confirmed` state with all proof
|
|
143
|
+
* columns populated. Useful for internalised transactions that arrive with a
|
|
144
|
+
* Merkle proof (bump) already attached.
|
|
145
|
+
*/
|
|
146
|
+
createWithProof(args: {
|
|
147
|
+
txid: string;
|
|
148
|
+
rawTx?: number[];
|
|
149
|
+
inputBeef?: number[];
|
|
150
|
+
height: number;
|
|
151
|
+
merklePath: number[];
|
|
152
|
+
merkleRoot: string;
|
|
153
|
+
blockHash: string;
|
|
154
|
+
isCoinbase?: boolean;
|
|
155
|
+
now?: Date;
|
|
156
|
+
}): Promise<TableTransactionNew>;
|
|
157
|
+
/**
|
|
158
|
+
* #6 — Find an existing new transaction row for the given txid (suitable for
|
|
159
|
+
* the broadcast queue) or create a new one in `queued` state.
|
|
160
|
+
*/
|
|
161
|
+
findOrCreateForBroadcast(args: {
|
|
162
|
+
txid: string;
|
|
163
|
+
rawTx: number[];
|
|
164
|
+
inputBeef?: number[];
|
|
165
|
+
batch?: string;
|
|
166
|
+
processing?: sdk.ProcessingStatus;
|
|
167
|
+
now?: Date;
|
|
168
|
+
}): Promise<{
|
|
169
|
+
transaction: TableTransactionNew;
|
|
170
|
+
isNew: boolean;
|
|
171
|
+
}>;
|
|
172
|
+
/**
|
|
173
|
+
* #7 — Bulk transition: attempt `transition` for each id; collect results.
|
|
174
|
+
* When `expectedFrom` is omitted the current state of each row is used as
|
|
175
|
+
* the expected source (lenient mode — only the FSM is checked).
|
|
176
|
+
*/
|
|
177
|
+
transitionMany(args: {
|
|
178
|
+
transactionIds: number[];
|
|
179
|
+
expectedFrom?: sdk.ProcessingStatus;
|
|
180
|
+
to: sdk.ProcessingStatus;
|
|
181
|
+
provider?: string;
|
|
182
|
+
providerStatus?: string;
|
|
183
|
+
details?: Record<string, unknown>;
|
|
184
|
+
now?: Date;
|
|
185
|
+
}): Promise<{
|
|
186
|
+
updated: number[];
|
|
187
|
+
skipped: number[];
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* #8 — Bulk-set the `batch` column for a list of transaction ids.
|
|
191
|
+
* Pass `undefined` to clear the batch tag.
|
|
192
|
+
*/
|
|
193
|
+
setBatch(transactionIds: number[], batch: string | undefined, now?: Date): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* #9 — Atomically increment the `attempts` counter for one transaction and
|
|
196
|
+
* write an `attempts.incremented` audit entry.
|
|
197
|
+
*/
|
|
198
|
+
incrementAttempts(transactionId: number, now?: Date): Promise<TableTransactionNew | undefined>;
|
|
199
|
+
/**
|
|
200
|
+
* #10 — Record the outcome of a broadcast attempt. Transitions processing
|
|
201
|
+
* state, updates `wasBroadcast` and `lastProvider*` columns, and writes an
|
|
202
|
+
* audit row.
|
|
203
|
+
*/
|
|
204
|
+
recordBroadcastResult(args: {
|
|
205
|
+
transactionId: number;
|
|
206
|
+
txid: string;
|
|
207
|
+
status: sdk.ProcessingStatus;
|
|
208
|
+
provider: string;
|
|
209
|
+
providerStatus?: string;
|
|
210
|
+
wasBroadcast?: boolean;
|
|
211
|
+
details?: Record<string, unknown>;
|
|
212
|
+
now?: Date;
|
|
213
|
+
}): Promise<TableTransactionNew | undefined>;
|
|
214
|
+
/**
|
|
215
|
+
* #11 — Append a free-form history note to the audit log for a transaction.
|
|
216
|
+
*/
|
|
217
|
+
recordHistoryNote(transactionId: number, note: {
|
|
218
|
+
what: string;
|
|
219
|
+
[k: string]: unknown;
|
|
220
|
+
}, now?: Date): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* #12 — For each txid that exists in the new transactions table, merge the
|
|
223
|
+
* raw transaction bytes and (where available) the Merkle path into `beef`.
|
|
224
|
+
* Txids not present in new-schema are silently skipped.
|
|
225
|
+
*/
|
|
226
|
+
mergeBeefForTxids(beef: Beef, txids: string[]): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* #13 — Collect broadcast-readiness info and a populated Beef for a list of
|
|
229
|
+
* txids. Each entry is classified as:
|
|
230
|
+
* - `readyToSend` — queued/sending → still needs broadcast
|
|
231
|
+
* - `alreadySent` — sent/seen/seen_multi/unconfirmed/confirmed → already on network
|
|
232
|
+
* - `error` — invalid/doubleSpend → terminal failure
|
|
233
|
+
* - `unknown` — not found in new-schema
|
|
234
|
+
*/
|
|
235
|
+
collectReqsAndBeef(txids: string[], extraTxids?: string[]): Promise<{
|
|
236
|
+
beef: Beef;
|
|
237
|
+
details: Array<{
|
|
238
|
+
txid: string;
|
|
239
|
+
status: 'readyToSend' | 'alreadySent' | 'error' | 'unknown';
|
|
240
|
+
reason?: string;
|
|
241
|
+
}>;
|
|
242
|
+
}>;
|
|
243
|
+
/**
|
|
244
|
+
* #14 — Paginated list of actions (per-user transaction views) with optional
|
|
245
|
+
* status and label filters.
|
|
246
|
+
*
|
|
247
|
+
* After the the schema cutover `tx_labels_map.transactionId` references `actions.actionId`
|
|
248
|
+
* (not `transactions.transactionId`).
|
|
249
|
+
*/
|
|
250
|
+
listActionsForUser(args: {
|
|
251
|
+
userId: number;
|
|
252
|
+
statusFilter?: sdk.ProcessingStatus[];
|
|
253
|
+
labelIds?: number[];
|
|
254
|
+
labelQueryMode?: 'all' | 'any';
|
|
255
|
+
createdAtFrom?: Date;
|
|
256
|
+
createdAtTo?: Date;
|
|
257
|
+
limit: number;
|
|
258
|
+
offset: number;
|
|
259
|
+
}): Promise<{
|
|
260
|
+
rows: Array<TableAction & {
|
|
261
|
+
txid: string;
|
|
262
|
+
processing: sdk.ProcessingStatus;
|
|
263
|
+
height?: number;
|
|
264
|
+
}>;
|
|
265
|
+
total?: number;
|
|
266
|
+
}>;
|
|
267
|
+
/**
|
|
268
|
+
* #15 — Paginated list of outputs with their backing transaction processing
|
|
269
|
+
* state. Optional filters: basket, tag set, processing state, spent flag.
|
|
270
|
+
*/
|
|
271
|
+
listOutputsForUser(args: {
|
|
272
|
+
userId: number;
|
|
273
|
+
basketId?: number;
|
|
274
|
+
tagIds?: number[];
|
|
275
|
+
tagQueryMode?: 'all' | 'any';
|
|
276
|
+
processingFilter: sdk.ProcessingStatus[];
|
|
277
|
+
includeSpent: boolean;
|
|
278
|
+
limit: number;
|
|
279
|
+
offset: number;
|
|
280
|
+
includeLockingScripts?: boolean;
|
|
281
|
+
}): Promise<{
|
|
282
|
+
rows: Array<TableOutput & {
|
|
283
|
+
processing: sdk.ProcessingStatus;
|
|
284
|
+
}>;
|
|
285
|
+
total?: number;
|
|
286
|
+
}>;
|
|
287
|
+
/**
|
|
288
|
+
* Post-cutover helper: rewrite `tx_labels_map.transactionId` rows that were
|
|
289
|
+
* written with the legacy transactionId (before the real txid + actionId were
|
|
290
|
+
* known) so that they now point at the new-schema `actions.actionId`.
|
|
291
|
+
*
|
|
292
|
+
* Call this once per new outgoing transaction immediately after
|
|
293
|
+
* `findOrCreateActionForTxid` resolves the actionId.
|
|
294
|
+
*
|
|
295
|
+
* This is a no-op when:
|
|
296
|
+
* - `legacyTransactionId` has no rows in `tx_labels_map` (no labels on the tx)
|
|
297
|
+
* - `legacyTransactionId === actionId` (should not happen in practice but
|
|
298
|
+
* is safe to call anyway)
|
|
299
|
+
*/
|
|
300
|
+
repointLabelsToActionId(legacyTransactionId: number, actionId: number, now?: Date): Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* After `processAction` creates the new `transactions` row, remap
|
|
303
|
+
* `outputs.transactionId` and `outputs.spentBy` from the bridge-period
|
|
304
|
+
* `transactions_legacy.transactionId` to the real `transactions.transactionId`.
|
|
305
|
+
*
|
|
306
|
+
* During `createAction`, new outputs are inserted with `transactionId =
|
|
307
|
+
* legacyTransactionId` (bypassing FK constraints). `listActionsKnex` queries
|
|
308
|
+
* outputs by new transactionId, so without this remap the outputs would be
|
|
309
|
+
* invisible to `listActions`.
|
|
310
|
+
*
|
|
311
|
+
* This is a no-op when `legacyTransactionId === newTransactionId`.
|
|
312
|
+
*/
|
|
313
|
+
repointOutputsToNewTransactionId(legacyTransactionId: number, newTransactionId: number, now?: Date): Promise<void>;
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=transactionService.d.ts.map
|