@bsv/sdk 1.8.0 → 1.8.2
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/cjs/package.json +1 -1
- package/dist/cjs/src/kvstore/GlobalKVStore.js +420 -0
- package/dist/cjs/src/kvstore/GlobalKVStore.js.map +1 -0
- package/dist/cjs/src/kvstore/LocalKVStore.js +6 -6
- package/dist/cjs/src/kvstore/LocalKVStore.js.map +1 -1
- package/dist/cjs/src/kvstore/index.js +3 -1
- package/dist/cjs/src/kvstore/index.js.map +1 -1
- package/dist/cjs/src/kvstore/kvStoreInterpreter.js +74 -0
- package/dist/cjs/src/kvstore/kvStoreInterpreter.js.map +1 -0
- package/dist/cjs/src/kvstore/types.js +11 -0
- package/dist/cjs/src/kvstore/types.js.map +1 -0
- package/dist/cjs/src/overlay-tools/Historian.js +153 -0
- package/dist/cjs/src/overlay-tools/Historian.js.map +1 -0
- package/dist/cjs/src/script/templates/PushDrop.js +2 -2
- package/dist/cjs/src/script/templates/PushDrop.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/kvstore/GlobalKVStore.js +416 -0
- package/dist/esm/src/kvstore/GlobalKVStore.js.map +1 -0
- package/dist/esm/src/kvstore/LocalKVStore.js +6 -6
- package/dist/esm/src/kvstore/LocalKVStore.js.map +1 -1
- package/dist/esm/src/kvstore/index.js +1 -0
- package/dist/esm/src/kvstore/index.js.map +1 -1
- package/dist/esm/src/kvstore/kvStoreInterpreter.js +47 -0
- package/dist/esm/src/kvstore/kvStoreInterpreter.js.map +1 -0
- package/dist/esm/src/kvstore/types.js +8 -0
- package/dist/esm/src/kvstore/types.js.map +1 -0
- package/dist/esm/src/overlay-tools/Historian.js +155 -0
- package/dist/esm/src/overlay-tools/Historian.js.map +1 -0
- package/dist/esm/src/script/templates/PushDrop.js +2 -2
- package/dist/esm/src/script/templates/PushDrop.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/kvstore/GlobalKVStore.d.ts +129 -0
- package/dist/types/src/kvstore/GlobalKVStore.d.ts.map +1 -0
- package/dist/types/src/kvstore/index.d.ts +1 -0
- package/dist/types/src/kvstore/index.d.ts.map +1 -1
- package/dist/types/src/kvstore/kvStoreInterpreter.d.ts +22 -0
- package/dist/types/src/kvstore/kvStoreInterpreter.d.ts.map +1 -0
- package/dist/types/src/kvstore/types.d.ts +106 -0
- package/dist/types/src/kvstore/types.d.ts.map +1 -0
- package/dist/types/src/overlay-tools/Historian.d.ts +92 -0
- package/dist/types/src/overlay-tools/Historian.d.ts.map +1 -0
- package/dist/types/src/script/templates/PushDrop.d.ts +6 -5
- package/dist/types/src/script/templates/PushDrop.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +3 -3
- package/dist/umd/bundle.js.map +1 -1
- package/docs/reference/compat.md +15 -27
- package/docs/reference/identity.md +12 -16
- package/docs/reference/kvstore.md +471 -4
- package/docs/reference/messages.md +0 -8
- package/docs/reference/overlay-tools.md +15 -22
- package/docs/reference/primitives.md +168 -168
- package/docs/reference/registry.md +9 -19
- package/docs/reference/script.md +35 -48
- package/docs/reference/storage.md +10 -14
- package/docs/reference/totp.md +5 -5
- package/docs/reference/transaction.md +117 -69
- package/docs/reference/wallet.md +131 -135
- package/package.json +1 -1
- package/src/kvstore/GlobalKVStore.ts +478 -0
- package/src/kvstore/LocalKVStore.ts +7 -7
- package/src/kvstore/__tests/GlobalKVStore.test.ts +965 -0
- package/src/kvstore/__tests/LocalKVStore.test.ts +72 -0
- package/src/kvstore/index.ts +1 -0
- package/src/kvstore/kvStoreInterpreter.ts +49 -0
- package/src/kvstore/types.ts +114 -0
- package/src/overlay-tools/Historian.ts +195 -0
- package/src/overlay-tools/__tests/Historian.test.ts +690 -0
- package/src/script/templates/PushDrop.ts +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/kvstore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/kvstore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InterpreterFunction } from '../overlay-tools/Historian.js';
|
|
2
|
+
import { WalletProtocol } from '../wallet/Wallet.interfaces.js';
|
|
3
|
+
export interface KVContext {
|
|
4
|
+
key: string;
|
|
5
|
+
protocolID: WalletProtocol;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* KVStore interpreter used by Historian.
|
|
9
|
+
*
|
|
10
|
+
* Validates the KVStore PushDrop tokens: [protocolID, key, value, controller, signature].
|
|
11
|
+
* Filters outputs by the provided key in the interpreter context.
|
|
12
|
+
* Produces the plaintext value for matching outputs; returns undefined otherwise.
|
|
13
|
+
*
|
|
14
|
+
* @param transaction - The transaction to inspect.
|
|
15
|
+
* @param outputIndex - The index of the output within transaction.outputs.
|
|
16
|
+
* @param ctx - { key: string, protocolID: WalletProtocol } — per-call context specifying which key to match.
|
|
17
|
+
*
|
|
18
|
+
* @returns string | undefined — the decoded KV value if the output is a valid KVStore token for the
|
|
19
|
+
* given key; otherwise undefined.
|
|
20
|
+
*/
|
|
21
|
+
export declare const kvStoreInterpreter: InterpreterFunction<string, KVContext>;
|
|
22
|
+
//# sourceMappingURL=kvStoreInterpreter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kvStoreInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/kvstore/kvStoreInterpreter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAE/D,MAAM,WAAW,SAAS;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,cAAc,CAAA;CAAE;AAEtE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,EAAE,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAyBrE,CAAA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Beef } from '../transaction/Beef.js';
|
|
2
|
+
import { PubKeyHex, WalletProtocol } from '../wallet/Wallet.interfaces.js';
|
|
3
|
+
import { WalletInterface } from '../wallet/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration interface for GlobalKVStore operations.
|
|
6
|
+
* Defines all options for connecting to overlay services and managing KVStore behavior.
|
|
7
|
+
*/
|
|
8
|
+
export interface KVStoreConfig {
|
|
9
|
+
/** The overlay service host URL */
|
|
10
|
+
overlayHost?: string;
|
|
11
|
+
/** Protocol ID for the KVStore protocol */
|
|
12
|
+
protocolID?: WalletProtocol;
|
|
13
|
+
/** Service name for overlay submission */
|
|
14
|
+
serviceName?: string;
|
|
15
|
+
/** Amount of satoshis for each token */
|
|
16
|
+
tokenAmount?: number;
|
|
17
|
+
/** Topics for overlay submission */
|
|
18
|
+
topics?: string[];
|
|
19
|
+
/** Originator */
|
|
20
|
+
originator?: string;
|
|
21
|
+
/** Wallet interface for operations */
|
|
22
|
+
wallet?: WalletInterface;
|
|
23
|
+
/** Network preset for overlay services */
|
|
24
|
+
networkPreset?: 'mainnet' | 'testnet' | 'local';
|
|
25
|
+
/** Whether to accept delayed broadcast */
|
|
26
|
+
acceptDelayedBroadcast?: boolean;
|
|
27
|
+
/** Description for token set */
|
|
28
|
+
tokenSetDescription?: string;
|
|
29
|
+
/** Description for token update */
|
|
30
|
+
tokenUpdateDescription?: string;
|
|
31
|
+
/** Description for token removal */
|
|
32
|
+
tokenRemovalDescription?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Query parameters for KVStore lookups from overlay services.
|
|
36
|
+
* Used when searching for existing key-value pairs in the network.
|
|
37
|
+
*/
|
|
38
|
+
export interface KVStoreQuery {
|
|
39
|
+
key?: string;
|
|
40
|
+
controller?: PubKeyHex;
|
|
41
|
+
protocolID?: WalletProtocol;
|
|
42
|
+
limit?: number;
|
|
43
|
+
skip?: number;
|
|
44
|
+
sortOrder?: 'asc' | 'desc';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for configuring KVStore get operations (local processing)
|
|
48
|
+
*/
|
|
49
|
+
export interface KVStoreGetOptions {
|
|
50
|
+
/** Whether to build and include history for each entry */
|
|
51
|
+
history?: boolean;
|
|
52
|
+
/** Whether to include token transaction data in results */
|
|
53
|
+
includeToken?: boolean;
|
|
54
|
+
/** Service name for overlay retrieval */
|
|
55
|
+
serviceName?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface KVStoreSetOptions {
|
|
58
|
+
protocolID?: WalletProtocol;
|
|
59
|
+
tokenSetDescription?: string;
|
|
60
|
+
tokenUpdateDescription?: string;
|
|
61
|
+
tokenAmount?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface KVStoreRemoveOptions {
|
|
64
|
+
protocolID?: WalletProtocol;
|
|
65
|
+
tokenRemovalDescription?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* KVStore entry returned from queries
|
|
69
|
+
*/
|
|
70
|
+
export interface KVStoreEntry {
|
|
71
|
+
key: string;
|
|
72
|
+
value: string;
|
|
73
|
+
controller: PubKeyHex;
|
|
74
|
+
protocolID: WalletProtocol;
|
|
75
|
+
token?: KVStoreToken;
|
|
76
|
+
history?: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Result structure for KVStore lookups from overlay services.
|
|
80
|
+
* Contains the transaction output information for a found key-value pair.
|
|
81
|
+
*/
|
|
82
|
+
export interface KVStoreLookupResult {
|
|
83
|
+
txid: string;
|
|
84
|
+
outputIndex: number;
|
|
85
|
+
outputScript: string;
|
|
86
|
+
satoshis: number;
|
|
87
|
+
history?: (output: any, currentDepth: number) => Promise<boolean>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Token structure containing a KVStore token from overlay services.
|
|
91
|
+
* Wraps the transaction data and metadata for a key-value pair.
|
|
92
|
+
*/
|
|
93
|
+
export interface KVStoreToken {
|
|
94
|
+
txid: string;
|
|
95
|
+
outputIndex: number;
|
|
96
|
+
satoshis: number;
|
|
97
|
+
beef: Beef;
|
|
98
|
+
}
|
|
99
|
+
export declare const kvProtocol: {
|
|
100
|
+
protocolID: number;
|
|
101
|
+
key: number;
|
|
102
|
+
value: number;
|
|
103
|
+
controller: number;
|
|
104
|
+
signature: number;
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/kvstore/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,iBAAiB;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,sCAAsC;IACtC,MAAM,CAAC,EAAE,eAAe,CAA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C,EAAE,YAAY,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAClE;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,IAAI,CAAA;CACX;AAED,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import Transaction from '../transaction/Transaction.js';
|
|
2
|
+
/**
|
|
3
|
+
* Interpreter function signature used by Historian.
|
|
4
|
+
*
|
|
5
|
+
* Generics:
|
|
6
|
+
* - T: The decoded/typed value produced for a matching output. Returning `undefined`
|
|
7
|
+
* means “this output does not contribute to history.”
|
|
8
|
+
* - C: The per-call context passed through Historian to the interpreter. This carries
|
|
9
|
+
* any metadata needed to interpret outputs (e.g., `{ key: string }` for KVStore).
|
|
10
|
+
*
|
|
11
|
+
* Params:
|
|
12
|
+
* - tx: The transaction containing the output to interpret.
|
|
13
|
+
* - outputIndex: Index of the output within `tx.outputs`.
|
|
14
|
+
* - ctx: Optional context object of type C, supplied at [Historian.buildHistory(startTx, context)]
|
|
15
|
+
*
|
|
16
|
+
* Returns:
|
|
17
|
+
* - `T | undefined` (or a Promise thereof). `undefined` indicates a non-applicable or
|
|
18
|
+
* un-decodable output for the given context.
|
|
19
|
+
*/
|
|
20
|
+
export type InterpreterFunction<T, C = unknown> = (tx: Transaction, outputIndex: number, ctx?: C) => Promise<T | undefined> | T | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Historian builds a chronological history (oldest → newest) of typed values by traversing
|
|
23
|
+
* a transaction's input ancestry and interpreting each output with a provided interpreter.
|
|
24
|
+
*
|
|
25
|
+
* Core ideas:
|
|
26
|
+
* - You provide an interpreter `(tx, outputIndex) => T | undefined` that decodes one output
|
|
27
|
+
* into your domain value (e.g., kvstore entries). If it returns `undefined`, that output
|
|
28
|
+
* contributes nothing to history.
|
|
29
|
+
* - Traversal follows `Transaction.inputs[].sourceTransaction` recursively, so callers must
|
|
30
|
+
* supply transactions whose inputs have `sourceTransaction` populated (e.g., via overlay
|
|
31
|
+
* history reconstruction).
|
|
32
|
+
* - The traversal visits each transaction once (cycle-safe) and collects interpreted values
|
|
33
|
+
* in reverse-chronological order, then returns them as chronological (oldest-first).
|
|
34
|
+
* - Optional caching support: provide a `historyCache` Map to cache complete history results
|
|
35
|
+
* and avoid re-traversing identical transaction chains with the same context.
|
|
36
|
+
*
|
|
37
|
+
* Usage:
|
|
38
|
+
* - Construct with an interpreter (and optional cache)
|
|
39
|
+
* - Call historian.buildHistory(tx, context) to get an array of values representing the history of a token over time.
|
|
40
|
+
*
|
|
41
|
+
* Example:
|
|
42
|
+
* const cache = new Map() // Optional: for caching repeated queries
|
|
43
|
+
* const historian = new Historian(interpreter, { historyCache: cache })
|
|
44
|
+
* const history = await historian.buildHistory(tipTransaction, context)
|
|
45
|
+
* // history: T[] (e.g., prior values for a protected kvstore key)
|
|
46
|
+
*
|
|
47
|
+
* Caching:
|
|
48
|
+
* - Cache keys are generated from `interpreterVersion|txid|contextKey`
|
|
49
|
+
* - Cached results are immutable snapshots to prevent external mutation
|
|
50
|
+
* - Bump `interpreterVersion` when interpreter semantics change to invalidate old cache entries
|
|
51
|
+
*/
|
|
52
|
+
export declare class Historian<T, C = unknown> {
|
|
53
|
+
private readonly interpreter;
|
|
54
|
+
private readonly debug;
|
|
55
|
+
private readonly historyCache?;
|
|
56
|
+
private readonly interpreterVersion;
|
|
57
|
+
private readonly ctxKeyFn;
|
|
58
|
+
/**
|
|
59
|
+
* Create a new Historian instance
|
|
60
|
+
*
|
|
61
|
+
* @param interpreter - Function to interpret transaction outputs into typed values
|
|
62
|
+
* @param options - Configuration options
|
|
63
|
+
* @param options.debug - Enable debug logging (default: false)
|
|
64
|
+
* @param options.historyCache - Optional external cache for complete history results
|
|
65
|
+
* @param options.interpreterVersion - Version identifier for cache invalidation (default: 'v1')
|
|
66
|
+
* @param options.ctxKeyFn - Custom function to serialize context for cache keys (default: JSON.stringify)
|
|
67
|
+
*/
|
|
68
|
+
constructor(interpreter: InterpreterFunction<T, C>, options?: {
|
|
69
|
+
debug?: boolean;
|
|
70
|
+
/** Optional cache for entire history results keyed by (version|txid|ctxKey) */
|
|
71
|
+
historyCache?: Map<string, readonly T[]>;
|
|
72
|
+
/** Bump this if interpreter semantics change to invalidate cache */
|
|
73
|
+
interpreterVersion?: string;
|
|
74
|
+
/** Deterministic, non-secret key for context. Default is JSON.stringify(ctx) */
|
|
75
|
+
ctxKeyFn?: (ctx?: C) => string;
|
|
76
|
+
});
|
|
77
|
+
private historyKey;
|
|
78
|
+
/**
|
|
79
|
+
* Build history by traversing input chain from a starting transaction
|
|
80
|
+
* Returns values in chronological order (oldest first)
|
|
81
|
+
*
|
|
82
|
+
* If caching is enabled, will first check for cached results matching the
|
|
83
|
+
* startTransaction and context. On cache miss, performs full traversal and
|
|
84
|
+
* stores the result for future queries.
|
|
85
|
+
*
|
|
86
|
+
* @param startTransaction - The transaction to start traversal from
|
|
87
|
+
* @param context - The context to pass to the interpreter
|
|
88
|
+
* @returns Array of interpreted values in chronological order
|
|
89
|
+
*/
|
|
90
|
+
buildHistory(startTransaction: Transaction, context?: C): Promise<T[]>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=Historian.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Historian.d.ts","sourceRoot":"","sources":["../../../../src/overlay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1
|
import { ScriptTemplate, LockingScript, UnlockingScript } from '../index.js';
|
|
2
2
|
import { PublicKey } from '../../primitives/index.js';
|
|
3
|
-
import { WalletInterface
|
|
3
|
+
import { WalletInterface } from '../../wallet/Wallet.interfaces.js';
|
|
4
4
|
import { Transaction } from '../../transaction/index.js';
|
|
5
|
+
import { WalletProtocol } from '../../wallet/Wallet.interfaces.js';
|
|
5
6
|
export default class PushDrop implements ScriptTemplate {
|
|
6
7
|
wallet: WalletInterface;
|
|
7
8
|
originator?: string;
|
|
@@ -26,18 +27,18 @@ export default class PushDrop implements ScriptTemplate {
|
|
|
26
27
|
* Creates a PushDrop locking script with arbitrary data fields and a public key lock.
|
|
27
28
|
*
|
|
28
29
|
* @param {number[][]} fields - The token fields to include in the locking script.
|
|
29
|
-
* @param {
|
|
30
|
+
* @param {WalletProtocol} protocolID - The protocol ID to use.
|
|
30
31
|
* @param {string} keyID - The key ID to use.
|
|
31
32
|
* @param {string} counterparty - The counterparty involved in the transaction, "self" or "anyone".
|
|
32
33
|
* @param {boolean} [forSelf=false] - Flag indicating if the lock is for the creator (default no).
|
|
33
34
|
* @param {boolean} [includeSignature=true] - Flag indicating if a signature should be included in the script (default yes).
|
|
34
35
|
* @returns {Promise<LockingScript>} The generated PushDrop locking script.
|
|
35
36
|
*/
|
|
36
|
-
lock(fields: number[][], protocolID:
|
|
37
|
+
lock(fields: number[][], protocolID: WalletProtocol, keyID: string, counterparty: string, forSelf?: boolean, includeSignature?: boolean, lockPosition?: 'before' | 'after'): Promise<LockingScript>;
|
|
37
38
|
/**
|
|
38
39
|
* Creates an unlocking script for spending a PushDrop token output.
|
|
39
40
|
*
|
|
40
|
-
* @param {
|
|
41
|
+
* @param {WalletProtocol} protocolID - The protocol ID to use.
|
|
41
42
|
* @param {string} keyID - The key ID to use.
|
|
42
43
|
* @param {string} counterparty - The counterparty involved in the transaction, "self" or "anyone".
|
|
43
44
|
* @param {string} [sourceTXID] - The TXID of the source transaction.
|
|
@@ -47,7 +48,7 @@ export default class PushDrop implements ScriptTemplate {
|
|
|
47
48
|
* @param {boolean} [anyoneCanPay=false] - Specifies if the anyone-can-pay flag is set.
|
|
48
49
|
* @returns {Object} An object containing functions to sign the transaction and estimate the script length.
|
|
49
50
|
*/
|
|
50
|
-
unlock(protocolID:
|
|
51
|
+
unlock(protocolID: WalletProtocol, keyID: string, counterparty: string, signOutputs?: 'all' | 'none' | 'single', anyoneCanPay?: boolean, sourceSatoshis?: number, lockingScript?: LockingScript): {
|
|
51
52
|
sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>;
|
|
52
53
|
estimateLength: () => Promise<73>;
|
|
53
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushDrop.d.ts","sourceRoot":"","sources":["../../../../../src/script/templates/PushDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAM,MAAM,aAAa,CAAA;AAChF,OAAO,EAKL,SAAS,EACV,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"PushDrop.d.ts","sourceRoot":"","sources":["../../../../../src/script/templates/PushDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAM,MAAM,aAAa,CAAA;AAChF,OAAO,EAKL,SAAS,EACV,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAgDlE,MAAM,CAAC,OAAO,OAAO,QAAS,YAAW,cAAc;IACrD,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG;QACpC,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