@bsv/wallet-toolbox-mobile 2.4.2 → 2.4.4
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/CWIStyleWalletManager.d.ts +52 -5
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +500 -128
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/Wallet.d.ts +8 -0
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +23 -9
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletAuthenticationManager.d.ts +20 -6
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
- package/out/src/WalletAuthenticationManager.js +214 -34
- package/out/src/WalletAuthenticationManager.js.map +1 -1
- package/out/src/WalletPermissionsManager.d.ts +15 -0
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +76 -28
- package/out/src/WalletPermissionsManager.js.map +1 -1
- package/out/src/index.mobile.d.ts +1 -0
- package/out/src/index.mobile.d.ts.map +1 -1
- package/out/src/index.mobile.js +1 -0
- package/out/src/index.mobile.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +4 -3
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts +13 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.js +24 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.js.map +1 -0
- package/out/src/sdk/ActionBatch.interfaces.d.ts +105 -0
- package/out/src/sdk/ActionBatch.interfaces.d.ts.map +1 -0
- package/out/src/sdk/ActionBatch.interfaces.js +3 -0
- package/out/src/sdk/ActionBatch.interfaces.js.map +1 -0
- package/out/src/sdk/WalletStorage.interfaces.d.ts +18 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/index.d.ts +1 -0
- package/out/src/sdk/index.d.ts.map +1 -1
- package/out/src/sdk/index.js +1 -0
- package/out/src/sdk/index.js.map +1 -1
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts +28 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.js +313 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.js.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts +33 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js +693 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js.map +1 -0
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +2 -1
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +4 -1
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +28 -0
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +49 -0
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +8 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +24 -0
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/methods/actionBatch.d.ts +14 -0
- package/out/src/storage/methods/actionBatch.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatch.js +644 -0
- package/out/src/storage/methods/actionBatch.js.map +1 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts +12 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatchBlobs.js +121 -0
- package/out/src/storage/methods/actionBatchBlobs.js.map +1 -0
- package/out/src/storage/methods/actionBatchValidation.d.ts +15 -0
- package/out/src/storage/methods/actionBatchValidation.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatchValidation.js +310 -0
- package/out/src/storage/methods/actionBatchValidation.js.map +1 -0
- package/out/src/storage/methods/actionPlanning.d.ts +12 -0
- package/out/src/storage/methods/actionPlanning.d.ts.map +1 -0
- package/out/src/storage/methods/actionPlanning.js +48 -0
- package/out/src/storage/methods/actionPlanning.js.map +1 -0
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +9 -25
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.d.ts +9 -0
- package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.js +36 -1
- package/out/src/storage/remoting/StorageClientBase.js.map +1 -1
- package/out/src/storage/schema/tables/TableActionBatch.d.ts +24 -0
- package/out/src/storage/schema/tables/TableActionBatch.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableActionBatch.js +3 -0
- package/out/src/storage/schema/tables/TableActionBatch.js.map +1 -0
- package/out/src/storage/schema/tables/index.d.ts +1 -0
- package/out/src/storage/schema/tables/index.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.js +1 -0
- package/out/src/storage/schema/tables/index.js.map +1 -1
- package/out/src/utility/actionBatchDigest.d.ts +9 -0
- package/out/src/utility/actionBatchDigest.d.ts.map +1 -0
- package/out/src/utility/actionBatchDigest.js +48 -0
- package/out/src/utility/actionBatchDigest.js.map +1 -0
- package/out/src/utility/beefForTxids.d.ts +9 -0
- package/out/src/utility/beefForTxids.d.ts.map +1 -0
- package/out/src/utility/beefForTxids.js +35 -0
- package/out/src/utility/beefForTxids.js.map +1 -0
- package/out/src/wab-client/WABClient.d.ts +36 -90
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/out/src/wab-client/WABClient.js +103 -151
- package/out/src/wab-client/WABClient.js.map +1 -1
- package/out/src/wab-client/WABTransport.d.ts +53 -0
- package/out/src/wab-client/WABTransport.d.ts.map +1 -0
- package/out/src/wab-client/WABTransport.js +300 -0
- package/out/src/wab-client/WABTransport.js.map +1 -0
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +10 -10
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +16 -21
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts +2 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js +14 -0
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js.map +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.plannerOutputLockingScript = plannerOutputLockingScript;
|
|
4
|
+
exports.planAction = planAction;
|
|
5
|
+
exports.addPlannerOutputs = addPlannerOutputs;
|
|
6
|
+
exports.stageTransactionOutputs = stageTransactionOutputs;
|
|
7
|
+
exports.mergePlannerBeef = mergePlannerBeef;
|
|
8
|
+
const sdk_1 = require("@bsv/sdk");
|
|
9
|
+
const WERR_errors_1 = require("../../sdk/WERR_errors");
|
|
10
|
+
const utilityHelpers_1 = require("../../utility/utilityHelpers");
|
|
11
|
+
const utilityHelpers_noBuffer_1 = require("../../utility/utilityHelpers.noBuffer");
|
|
12
|
+
const beefForTxids_1 = require("../../utility/beefForTxids");
|
|
13
|
+
const offsetKey_1 = require("../../storage/methods/offsetKey");
|
|
14
|
+
const generateChange_1 = require("../../storage/methods/generateChange");
|
|
15
|
+
const actionPlanning_1 = require("../../storage/methods/actionPlanning");
|
|
16
|
+
function outpointOf(output) {
|
|
17
|
+
if (output.txid == null)
|
|
18
|
+
throw new WERR_errors_1.WERR_INTERNAL('batch planner output is missing txid');
|
|
19
|
+
return `${output.txid}.${output.vout}`;
|
|
20
|
+
}
|
|
21
|
+
function randomDerivation(count, random) {
|
|
22
|
+
const bytes = [];
|
|
23
|
+
for (let i = 0; i < count; i++)
|
|
24
|
+
bytes.push(Math.floor(random() * 256));
|
|
25
|
+
return sdk_1.Utils.toBase64(bytes);
|
|
26
|
+
}
|
|
27
|
+
function outputFromBeef(beef, outpoint) {
|
|
28
|
+
const transaction = beef.findTxid(outpoint.txid)?.tx;
|
|
29
|
+
if (transaction == null)
|
|
30
|
+
return undefined;
|
|
31
|
+
const output = transaction?.outputs[outpoint.vout];
|
|
32
|
+
if (output == null)
|
|
33
|
+
return undefined;
|
|
34
|
+
const now = new Date();
|
|
35
|
+
return {
|
|
36
|
+
outputId: -1,
|
|
37
|
+
userId: 0,
|
|
38
|
+
transactionId: 0,
|
|
39
|
+
spendable: true,
|
|
40
|
+
change: false,
|
|
41
|
+
outputDescription: '',
|
|
42
|
+
vout: outpoint.vout,
|
|
43
|
+
satoshis: sdk_1.Validation.validateSatoshis(output.satoshis, 'source output satoshis'),
|
|
44
|
+
providedBy: 'you',
|
|
45
|
+
purpose: '',
|
|
46
|
+
type: 'custom',
|
|
47
|
+
txid: outpoint.txid,
|
|
48
|
+
lockingScript: undefined,
|
|
49
|
+
sourceTransaction: undefined,
|
|
50
|
+
created_at: now,
|
|
51
|
+
updated_at: now
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function requireManagedChange(output, name) {
|
|
55
|
+
if (output == null || !output.change || output.type !== 'P2PKH' ||
|
|
56
|
+
output.providedBy !== 'storage' || output.purpose !== 'change' ||
|
|
57
|
+
output.derivationPrefix == null || output.derivationSuffix == null) {
|
|
58
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(name, 'wallet-managed BRC-29 change');
|
|
59
|
+
}
|
|
60
|
+
return output;
|
|
61
|
+
}
|
|
62
|
+
function resolveInputOutput(state, outpoint) {
|
|
63
|
+
const key = `${outpoint.txid}.${outpoint.vout}`;
|
|
64
|
+
return state.staged.get(key) ?? state.explicit.get(key) ?? state.reserved.get(key) ??
|
|
65
|
+
(!state.discardedStagedTxids.has(outpoint.txid) ? outputFromBeef(state.sharedBeef, outpoint) : undefined) ??
|
|
66
|
+
(() => { throw new WERR_errors_1.WERR_INVALID_PARAMETER('inputBEEF', `proof data for ${key}`); })();
|
|
67
|
+
}
|
|
68
|
+
function plannerOutputLockingScript(state, output) {
|
|
69
|
+
if (output.lockingScript != null)
|
|
70
|
+
return (0, utilityHelpers_noBuffer_1.asArray)(output.lockingScript);
|
|
71
|
+
if (output.txid == null)
|
|
72
|
+
throw new WERR_errors_1.WERR_INTERNAL('batch planner output is missing txid');
|
|
73
|
+
const script = state.sharedBeef.findTxid(output.txid)?.tx?.outputs[output.vout]?.lockingScript;
|
|
74
|
+
if (script == null)
|
|
75
|
+
throw new WERR_errors_1.WERR_INTERNAL(`batch planner output ${output.txid}.${output.vout} is missing its script`);
|
|
76
|
+
return script.toBinary();
|
|
77
|
+
}
|
|
78
|
+
function sdkInputFromExplicit(state, input, vin, output, isSignAction) {
|
|
79
|
+
let providedBy = output.providedBy;
|
|
80
|
+
if (output.providedBy === 'storage')
|
|
81
|
+
providedBy = 'you-and-storage';
|
|
82
|
+
return {
|
|
83
|
+
vin,
|
|
84
|
+
sourceTxid: (0, utilityHelpers_1.verifyTruthy)(output.txid),
|
|
85
|
+
sourceVout: output.vout,
|
|
86
|
+
sourceSatoshis: output.satoshis,
|
|
87
|
+
sourceLockingScript: (0, utilityHelpers_noBuffer_1.asString)(plannerOutputLockingScript(state, output)),
|
|
88
|
+
sourceTransaction: isSignAction ? sourceTransactionFor(state, output) : undefined,
|
|
89
|
+
unlockingScriptLength: input.unlockingScriptLength,
|
|
90
|
+
providedBy,
|
|
91
|
+
type: output.type,
|
|
92
|
+
spendingDescription: input.inputDescription,
|
|
93
|
+
derivationPrefix: output.derivationPrefix,
|
|
94
|
+
derivationSuffix: output.derivationSuffix,
|
|
95
|
+
senderIdentityKey: output.senderIdentityKey
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function sdkInputFromFunding(state, output, vin, isSignAction) {
|
|
99
|
+
return {
|
|
100
|
+
vin,
|
|
101
|
+
sourceTxid: (0, utilityHelpers_1.verifyTruthy)(output.txid),
|
|
102
|
+
sourceVout: output.vout,
|
|
103
|
+
sourceSatoshis: output.satoshis,
|
|
104
|
+
sourceLockingScript: (0, utilityHelpers_noBuffer_1.asString)(plannerOutputLockingScript(state, output)),
|
|
105
|
+
sourceTransaction: isSignAction ? sourceTransactionFor(state, output) : undefined,
|
|
106
|
+
unlockingScriptLength: 107,
|
|
107
|
+
providedBy: 'storage',
|
|
108
|
+
type: 'P2PKH',
|
|
109
|
+
spendingDescription: undefined,
|
|
110
|
+
derivationPrefix: (0, utilityHelpers_1.verifyTruthy)(output.derivationPrefix),
|
|
111
|
+
derivationSuffix: (0, utilityHelpers_1.verifyTruthy)(output.derivationSuffix),
|
|
112
|
+
senderIdentityKey: output.senderIdentityKey
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function sourceTransactionFor(state, output) {
|
|
116
|
+
if (output.sourceTransaction != null)
|
|
117
|
+
return output.sourceTransaction;
|
|
118
|
+
if (output.txid == null)
|
|
119
|
+
return undefined;
|
|
120
|
+
return state.sharedBeef.findTxid(output.txid)?.tx?.toUint8Array();
|
|
121
|
+
}
|
|
122
|
+
function trimInputBeef(state, args, inputs) {
|
|
123
|
+
if (args.options.returnTXIDOnly)
|
|
124
|
+
return undefined;
|
|
125
|
+
const beef = (0, beefForTxids_1.beefForTxids)(state.sharedBeef, inputs.map(input => input.sourceTxid));
|
|
126
|
+
if (args.inputBEEF != null)
|
|
127
|
+
beef.mergeBeef(args.inputBEEF);
|
|
128
|
+
for (const txid of args.options.knownTxids)
|
|
129
|
+
if (beef.findTxid(txid) != null)
|
|
130
|
+
beef.makeTxidOnly(txid);
|
|
131
|
+
return beef.toUint8Array();
|
|
132
|
+
}
|
|
133
|
+
function requestedOutputs(args) {
|
|
134
|
+
return args.outputs.map((output, vout) => ({
|
|
135
|
+
...output,
|
|
136
|
+
vout,
|
|
137
|
+
providedBy: 'you'
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
async function planFunding(state, args, explicit, noSendChange) {
|
|
141
|
+
const available = [...state.reserved.values()].filter(output => !state.consumed.has(outpointOf(output)));
|
|
142
|
+
const allocated = new Map();
|
|
143
|
+
const noSend = [...noSendChange];
|
|
144
|
+
const changeBasket = state.begin.changeBasket;
|
|
145
|
+
const params = {
|
|
146
|
+
fixedInputs: explicit.map((output, index) => ({
|
|
147
|
+
satoshis: output.satoshis,
|
|
148
|
+
unlockingScriptLength: args.inputs[index].unlockingScriptLength
|
|
149
|
+
})),
|
|
150
|
+
fixedOutputs: [
|
|
151
|
+
...args.outputs.map(output => ({ satoshis: output.satoshis, lockingScriptLength: output.lockingScript.length / 2 })),
|
|
152
|
+
...(state.begin.commissionSatoshis > 0 ? [{ satoshis: state.begin.commissionSatoshis, lockingScriptLength: 25 }] : [])
|
|
153
|
+
],
|
|
154
|
+
feeModel: state.begin.feeModel,
|
|
155
|
+
changeInitialSatoshis: Math.max(1, changeBasket.minimumDesiredUTXOValue),
|
|
156
|
+
changeFirstSatoshis: Math.max(1, Math.round(changeBasket.minimumDesiredUTXOValue / 4)),
|
|
157
|
+
changeLockingScriptLength: 25,
|
|
158
|
+
changeUnlockingScriptLength: 107,
|
|
159
|
+
targetNetCount: changeBasket.numberOfDesiredUTXOs - state.estimatedChangeCount,
|
|
160
|
+
randomVals: args.randomVals
|
|
161
|
+
};
|
|
162
|
+
const allocate = async (targetSatoshis, exactSatoshis) => {
|
|
163
|
+
let output = noSend.pop();
|
|
164
|
+
output ??= (0, actionPlanning_1.selectCanonicalChange)(available.filter(candidate => !allocated.has(candidate.outputId)), targetSatoshis, exactSatoshis);
|
|
165
|
+
if (output == null)
|
|
166
|
+
return undefined;
|
|
167
|
+
allocated.set(output.outputId, output);
|
|
168
|
+
return { outputId: output.outputId, satoshis: output.satoshis };
|
|
169
|
+
};
|
|
170
|
+
const release = async (outputId) => {
|
|
171
|
+
const output = allocated.get(outputId);
|
|
172
|
+
if (output == null)
|
|
173
|
+
return;
|
|
174
|
+
allocated.delete(outputId);
|
|
175
|
+
if (noSendChange.includes(output))
|
|
176
|
+
noSend.push(output);
|
|
177
|
+
};
|
|
178
|
+
const result = await (0, generateChange_1.generateChangeSdk)(params, allocate, release, args.logger);
|
|
179
|
+
return {
|
|
180
|
+
allocated: result.allocatedChangeInputs.map(input => (0, utilityHelpers_1.verifyTruthy)(allocated.get(input.outputId))),
|
|
181
|
+
changeSatoshis: result.changeOutputs.map(output => output.satoshis),
|
|
182
|
+
maxPossibleSatoshisAdjustment: result.maxPossibleSatoshisAdjustment
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function makeChangeOutputs(state, fixedOutputCount, changeSatoshis, derivationPrefix, random) {
|
|
186
|
+
return changeSatoshis.map((satoshis, index) => ({
|
|
187
|
+
vout: fixedOutputCount + index,
|
|
188
|
+
satoshis,
|
|
189
|
+
lockingScript: '',
|
|
190
|
+
providedBy: 'storage',
|
|
191
|
+
purpose: 'change',
|
|
192
|
+
basket: state.begin.changeBasket.name,
|
|
193
|
+
tags: [],
|
|
194
|
+
outputDescription: '',
|
|
195
|
+
derivationSuffix: randomDerivation(16, random)
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
async function planAction(state, args) {
|
|
199
|
+
const seenOutpoints = new Set();
|
|
200
|
+
for (const outpoint of [...args.inputs.map(input => input.outpoint), ...args.options.noSendChange]) {
|
|
201
|
+
const key = `${outpoint.txid}.${outpoint.vout}`;
|
|
202
|
+
if (seenOutpoints.has(key)) {
|
|
203
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('inputs', `unique inputs; ${key} is repeated`);
|
|
204
|
+
}
|
|
205
|
+
if (state.consumed.has(key)) {
|
|
206
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('inputs', `unspent inputs; ${key} is already consumed by this action batch`);
|
|
207
|
+
}
|
|
208
|
+
seenOutpoints.add(key);
|
|
209
|
+
}
|
|
210
|
+
const explicit = args.inputs.map(input => resolveInputOutput(state, input.outpoint));
|
|
211
|
+
for (const output of explicit) {
|
|
212
|
+
if (output.change)
|
|
213
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('inputs', 'unmanaged inputs; use noSendChange for managed change');
|
|
214
|
+
}
|
|
215
|
+
const noSendChange = args.options.noSendChange.map(outpoint => requireManagedChange(resolveInputOutput(state, outpoint), `noSendChange ${outpoint.txid}.${outpoint.vout}`));
|
|
216
|
+
const funding = await planFunding(state, args, explicit, noSendChange);
|
|
217
|
+
const derivationRandom = (0, actionPlanning_1.repeatableRandom)(args.randomVals);
|
|
218
|
+
const derivationPrefix = randomDerivation(16, derivationRandom);
|
|
219
|
+
const outputs = requestedOutputs(args);
|
|
220
|
+
let commissionKeyOffset;
|
|
221
|
+
if (state.begin.commissionSatoshis > 0 && state.begin.commissionPubKeyHex != null) {
|
|
222
|
+
const commission = (0, offsetKey_1.createStorageServiceChargeScript)(state.begin.commissionPubKeyHex);
|
|
223
|
+
commissionKeyOffset = commission.keyOffset;
|
|
224
|
+
outputs.push({
|
|
225
|
+
vout: outputs.length,
|
|
226
|
+
satoshis: state.begin.commissionSatoshis,
|
|
227
|
+
lockingScript: commission.script,
|
|
228
|
+
providedBy: 'storage',
|
|
229
|
+
purpose: 'storage-commission',
|
|
230
|
+
outputDescription: 'Storage Service Charge',
|
|
231
|
+
tags: []
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (funding.maxPossibleSatoshisAdjustment != null) {
|
|
235
|
+
const adjustment = funding.maxPossibleSatoshisAdjustment;
|
|
236
|
+
if (outputs[adjustment.fixedOutputIndex]?.satoshis !== generateChange_1.maxPossibleSatoshis)
|
|
237
|
+
throw new WERR_errors_1.WERR_INTERNAL();
|
|
238
|
+
outputs[adjustment.fixedOutputIndex].satoshis = adjustment.satoshis;
|
|
239
|
+
}
|
|
240
|
+
const fixedOutputCount = outputs.length;
|
|
241
|
+
outputs.push(...makeChangeOutputs(state, fixedOutputCount, funding.changeSatoshis, derivationPrefix, derivationRandom));
|
|
242
|
+
// Legacy output randomization starts a fresh deterministic stream. Keeping
|
|
243
|
+
// that boundary is required for byte-for-byte parity with createAction.
|
|
244
|
+
if (args.options.randomizeOutputs)
|
|
245
|
+
(0, actionPlanning_1.randomizeOutputVouts)(outputs, args.randomVals);
|
|
246
|
+
const inputs = [
|
|
247
|
+
...explicit.map((output, vin) => sdkInputFromExplicit(state, args.inputs[vin], vin, output, args.isSignAction)),
|
|
248
|
+
...funding.allocated.map((output, index) => sdkInputFromFunding(state, output, explicit.length + index, args.isSignAction))
|
|
249
|
+
];
|
|
250
|
+
const consumedOutpoints = funding.allocated.map(outpointOf);
|
|
251
|
+
for (const input of args.inputs)
|
|
252
|
+
consumedOutpoints.push(`${input.outpoint.txid}.${input.outpoint.vout}`);
|
|
253
|
+
for (const outpoint of consumedOutpoints)
|
|
254
|
+
state.consumed.add(outpoint);
|
|
255
|
+
state.estimatedChangeCount += funding.changeSatoshis.length - funding.allocated.length;
|
|
256
|
+
const reference = (0, utilityHelpers_1.randomBytesBase64)(12);
|
|
257
|
+
const dcr = {
|
|
258
|
+
reference,
|
|
259
|
+
version: args.version,
|
|
260
|
+
lockTime: args.lockTime,
|
|
261
|
+
inputs,
|
|
262
|
+
outputs,
|
|
263
|
+
derivationPrefix,
|
|
264
|
+
inputBeef: trimInputBeef(state, args, inputs),
|
|
265
|
+
noSendChangeOutputVouts: args.isNoSend
|
|
266
|
+
? outputs.filter(output => output.purpose === 'change').map(output => output.vout)
|
|
267
|
+
: undefined
|
|
268
|
+
};
|
|
269
|
+
return { dcr, consumedOutpoints, commissionKeyOffset };
|
|
270
|
+
}
|
|
271
|
+
function addPlannerOutputs(target, outputs, basketName) {
|
|
272
|
+
for (const output of outputs)
|
|
273
|
+
target.set(outpointOf(output), {
|
|
274
|
+
...output,
|
|
275
|
+
sourceTransaction: undefined,
|
|
276
|
+
basketName
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function stageTransactionOutputs(state, tx, dcr) {
|
|
280
|
+
state.discardedStagedTxids.delete(tx.id('hex'));
|
|
281
|
+
const now = new Date();
|
|
282
|
+
for (const output of dcr.outputs) {
|
|
283
|
+
const isChange = output.providedBy === 'storage' && output.purpose === 'change';
|
|
284
|
+
const staged = {
|
|
285
|
+
outputId: -(state.staged.size + 1),
|
|
286
|
+
userId: 0,
|
|
287
|
+
transactionId: 0,
|
|
288
|
+
basketId: isChange ? state.begin.changeBasket.basketId : undefined,
|
|
289
|
+
basketName: output.basket,
|
|
290
|
+
tags: output.tags,
|
|
291
|
+
spendable: true,
|
|
292
|
+
change: isChange,
|
|
293
|
+
outputDescription: output.outputDescription,
|
|
294
|
+
vout: output.vout,
|
|
295
|
+
satoshis: output.satoshis,
|
|
296
|
+
providedBy: output.providedBy,
|
|
297
|
+
purpose: output.purpose ?? '',
|
|
298
|
+
type: isChange ? 'P2PKH' : 'custom',
|
|
299
|
+
txid: tx.id('hex'),
|
|
300
|
+
derivationPrefix: isChange ? dcr.derivationPrefix : undefined,
|
|
301
|
+
derivationSuffix: output.derivationSuffix,
|
|
302
|
+
customInstructions: output.customInstructions,
|
|
303
|
+
lockingScript: undefined,
|
|
304
|
+
created_at: now,
|
|
305
|
+
updated_at: now
|
|
306
|
+
};
|
|
307
|
+
state.staged.set(outpointOf(staged), staged);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function mergePlannerBeef(state, tx) {
|
|
311
|
+
state.sharedBeef.mergeRawTx(tx.toUint8Array());
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=ActionBatchPlanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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BAAiB;YAC3C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;YAC7B,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;YACnC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAClB,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;YAC7D,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;YAC7C,aAAa,EAAE,SAAS;YACxB,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,GAAG;SAChB,CAAA;QACD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB,CAAE,KAA8B,EAAE,EAAe;IAC/E,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ListActionsResult, ListOutputsResult, Validation } from '@bsv/sdk';
|
|
2
|
+
import type { PendingSignAction, Wallet } from '../../Wallet';
|
|
3
|
+
import { StorageCreateActionResult, StorageProcessActionResults } from '../../sdk/WalletStorage.interfaces';
|
|
4
|
+
import { WERR_INSUFFICIENT_FUNDS } from '../../sdk/WERR_errors';
|
|
5
|
+
export type ActionBatchMode = 'auto' | 'legacy';
|
|
6
|
+
export declare function additionalFundingTarget(error: WERR_INSUFFICIENT_FUNDS): number;
|
|
7
|
+
export declare function fundingRunwayExtension(runwayTarget: number, ewmaConfirmedInputs: number, ewmaConfirmedSatoshis: number, availableConfirmed: Array<{
|
|
8
|
+
satoshis: number;
|
|
9
|
+
}>): {
|
|
10
|
+
nextRunwayTarget: number;
|
|
11
|
+
requestedOutputs: number;
|
|
12
|
+
targetSatoshis: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export declare class ActionBatchController {
|
|
15
|
+
private readonly wallet;
|
|
16
|
+
readonly mode: ActionBatchMode;
|
|
17
|
+
private workspace?;
|
|
18
|
+
private readonly capabilities;
|
|
19
|
+
private serial;
|
|
20
|
+
constructor(wallet: Wallet, mode: ActionBatchMode);
|
|
21
|
+
get hasWorkspace(): boolean;
|
|
22
|
+
overlayListActions(persisted: ListActionsResult, args: Validation.ValidListActionsArgs): ListActionsResult;
|
|
23
|
+
overlayListOutputs(persisted: ListOutputsResult, args: Validation.ValidListOutputsArgs): ListOutputsResult;
|
|
24
|
+
private runExclusive;
|
|
25
|
+
private negotiate;
|
|
26
|
+
private begin;
|
|
27
|
+
plan(args: Validation.ValidCreateActionArgs): Promise<StorageCreateActionResult | undefined>;
|
|
28
|
+
process(prior: PendingSignAction | undefined, args: Validation.ValidProcessActionArgs): Promise<StorageProcessActionResults | undefined>;
|
|
29
|
+
ownsReference(reference: string): boolean;
|
|
30
|
+
abort(): Promise<boolean>;
|
|
31
|
+
abortAction(referenceOrTxid: string): Promise<boolean>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=ActionBatchWorkspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionBatchWorkspace.d.ts","sourceRoot":"","sources":["../../../../../src/signer/actionBatch/ActionBatchWorkspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,iBAAiB,EAEjB,UAAU,EACX,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAQ7D,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAA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