opnet 1.8.2 → 1.8.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/CHANGELOG.md +25 -0
- package/browser/_version.d.ts +1 -1
- package/browser/contracts/CallResult.d.ts +1 -0
- package/browser/contracts/interfaces/IProviderForCallResult.d.ts +2 -0
- package/browser/index.js +9930 -10100
- package/browser/noble-curves.js +3049 -2135
- package/browser/noble-hashes.js +1812 -2504
- package/browser/opnet.d.ts +1 -0
- package/browser/protobuf.js +2695 -2103
- package/browser/providers/AbstractRpcProvider.d.ts +2 -0
- package/browser/providers/interfaces/JSONRpcMethods.d.ts +1 -0
- package/browser/providers/websocket/types/WebSocketOpcodes.d.ts +2 -0
- package/browser/rolldown-runtime.js +35 -0
- package/browser/transactions/interfaces/BroadcastedTransactionPackage.d.ts +48 -0
- package/browser/utxos/UTXOsManager.d.ts +1 -0
- package/browser/vendors.js +36998 -45617
- package/browser/worker_threads-browser.js +7 -9
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/contracts/CallResult.d.ts +1 -0
- package/build/contracts/CallResult.js +59 -30
- package/build/contracts/interfaces/IProviderForCallResult.d.ts +2 -0
- package/build/opnet.d.ts +1 -0
- package/build/opnet.js +1 -0
- package/build/providers/AbstractRpcProvider.d.ts +2 -0
- package/build/providers/AbstractRpcProvider.js +15 -2
- package/build/providers/WebsocketRpcProvider.js +5 -0
- package/build/providers/interfaces/JSONRpcMethods.d.ts +1 -0
- package/build/providers/interfaces/JSONRpcMethods.js +1 -0
- package/build/providers/websocket/MethodMapping.js +6 -0
- package/build/providers/websocket/types/WebSocketOpcodes.d.ts +2 -0
- package/build/providers/websocket/types/WebSocketOpcodes.js +2 -0
- package/build/transactions/interfaces/BroadcastedTransactionPackage.d.ts +48 -0
- package/build/transactions/interfaces/BroadcastedTransactionPackage.js +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/utxos/UTXOsManager.d.ts +1 -0
- package/build/utxos/UTXOsManager.js +37 -28
- package/docs/api-reference/provider-api.md +16 -0
- package/docs/api-reference/types-interfaces.md +91 -0
- package/docs/api-reference/utxo-manager-api.md +4 -2
- package/docs/svg/tx-broadcast-flow.svg +201 -0
- package/docs/transactions/broadcasting.md +124 -9
- package/package.json +18 -13
- package/src/_version.ts +1 -1
- package/src/contracts/CallResult.ts +92 -35
- package/src/contracts/Contract.ts +11 -4
- package/src/contracts/interfaces/IProviderForCallResult.ts +5 -0
- package/src/opnet.ts +1 -0
- package/src/providers/AbstractRpcProvider.ts +52 -5
- package/src/providers/WebsocketRpcProvider.ts +7 -0
- package/src/providers/interfaces/JSONRpcMethods.ts +1 -0
- package/src/providers/websocket/MethodMapping.ts +6 -0
- package/src/providers/websocket/types/WebSocketOpcodes.ts +2 -0
- package/src/transactions/interfaces/BroadcastedTransactionPackage.ts +72 -0
- package/src/utxos/UTXOsManager.ts +82 -46
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
1
|
+
//#region src/shims/worker_threads-browser.js
|
|
2
|
+
var Worker = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
throw new Error("worker_threads is not available in browser. Use Web Workers instead.");
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
10
8
|
export { Worker };
|
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.8.
|
|
1
|
+
export declare const version = "1.8.4";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.8.
|
|
1
|
+
export const version = '1.8.4';
|
|
@@ -107,6 +107,7 @@ export declare class CallResult<T extends ContractDecodedObjectResult = {}, U ex
|
|
|
107
107
|
setEvents(events: U): void;
|
|
108
108
|
setCalldata(calldata: Uint8Array): void;
|
|
109
109
|
toOfflineBuffer(refundAddress: string, amount: bigint): Promise<Uint8Array>;
|
|
110
|
+
private max;
|
|
110
111
|
private acquire;
|
|
111
112
|
private bigintMax;
|
|
112
113
|
private getValuesFromAccessList;
|
|
@@ -4,6 +4,19 @@ import { decodeRevertData } from '../utils/RevertDecoder.js';
|
|
|
4
4
|
import { CallResultSerializer, NetworkName } from './CallResultSerializer.js';
|
|
5
5
|
import { TransactionHelper } from './TransactionHelpper.js';
|
|
6
6
|
const factory = new TransactionFactory();
|
|
7
|
+
function extractPackageFailures(packageResult) {
|
|
8
|
+
const failures = [];
|
|
9
|
+
const results = packageResult.txResults;
|
|
10
|
+
for (const [submittedTxid, result] of Object.entries(results)) {
|
|
11
|
+
if (result.error) {
|
|
12
|
+
failures.push(`tx ${submittedTxid} failed: ${result.error}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (failures.length === 0 && packageResult.packageMsg !== 'success') {
|
|
16
|
+
failures.push(`package rejected: ${packageResult.packageMsg}`);
|
|
17
|
+
}
|
|
18
|
+
return failures;
|
|
19
|
+
}
|
|
7
20
|
export class CallResult {
|
|
8
21
|
result;
|
|
9
22
|
accessList;
|
|
@@ -82,6 +95,9 @@ export class CallResult {
|
|
|
82
95
|
sendRawTransaction: () => {
|
|
83
96
|
return Promise.reject(new Error('Cannot broadcast from offline CallResult. Export signed transaction and broadcast online.'));
|
|
84
97
|
},
|
|
98
|
+
sendRawTransactionPackage: () => {
|
|
99
|
+
return Promise.reject(new Error('Cannot broadcast from offline CallResult. Export signed transaction and broadcast online.'));
|
|
100
|
+
},
|
|
85
101
|
getCSV1ForAddress: () => {
|
|
86
102
|
if (!data.csvAddress) {
|
|
87
103
|
throw new Error('CSV address not available in offline data');
|
|
@@ -241,33 +257,52 @@ export class CallResult {
|
|
|
241
257
|
};
|
|
242
258
|
}
|
|
243
259
|
async sendPresignedTransaction(signedTx) {
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
|
|
260
|
+
if (signedTx.utxoTracking.isP2WDA || !signedTx.fundingTransactionRaw) {
|
|
261
|
+
const tx = await this.#provider.sendRawTransaction(signedTx.interactionTransactionRaw, false);
|
|
262
|
+
if (!tx || tx.error) {
|
|
263
|
+
throw new Error(`Error sending transaction: ${tx?.error || 'Unknown error'}`);
|
|
247
264
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
throw new Error(`Error sending transaction: ${tx1?.error || 'Unknown error'}`);
|
|
265
|
+
if (!tx.result) {
|
|
266
|
+
throw new Error('No transaction ID returned');
|
|
251
267
|
}
|
|
252
|
-
if (!
|
|
253
|
-
throw new Error(`Error sending transaction: ${
|
|
268
|
+
if (!tx.success) {
|
|
269
|
+
throw new Error(`Error sending transaction: ${tx.result || 'Unknown error'}`);
|
|
270
|
+
}
|
|
271
|
+
this.#processUTXOTracking(signedTx);
|
|
272
|
+
return {
|
|
273
|
+
interactionAddress: signedTx.interactionAddress,
|
|
274
|
+
transactionId: tx.result,
|
|
275
|
+
peerAcknowledgements: tx.peers || 0,
|
|
276
|
+
newUTXOs: signedTx.nextUTXOs,
|
|
277
|
+
estimatedFees: signedTx.estimatedFees,
|
|
278
|
+
challengeSolution: signedTx.challengeSolution,
|
|
279
|
+
rawTransaction: signedTx.interactionTransactionRaw,
|
|
280
|
+
fundingUTXOs: signedTx.fundingUTXOs,
|
|
281
|
+
fundingInputUtxos: signedTx.fundingInputUtxos,
|
|
282
|
+
compiledTargetScript: signedTx.compiledTargetScript,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
const result = await this.#provider.sendRawTransactionPackage([signedTx.fundingTransactionRaw, signedTx.interactionTransactionRaw], true);
|
|
286
|
+
if (!result.success) {
|
|
287
|
+
throw new Error(`Error sending transaction package: ${result.error || 'Unknown error'}`);
|
|
288
|
+
}
|
|
289
|
+
if (result.packageResult) {
|
|
290
|
+
const failures = extractPackageFailures(result.packageResult);
|
|
291
|
+
if (failures.length > 0) {
|
|
292
|
+
throw new Error(`Transaction package failed:\n${failures.join('\n')}`);
|
|
254
293
|
}
|
|
255
294
|
}
|
|
256
|
-
const
|
|
257
|
-
if (
|
|
258
|
-
throw new Error(`
|
|
259
|
-
}
|
|
260
|
-
if (!tx2.result) {
|
|
261
|
-
throw new Error('No transaction ID returned');
|
|
262
|
-
}
|
|
263
|
-
if (!tx2.success) {
|
|
264
|
-
throw new Error(`Error sending transaction: ${tx2.result || 'Unknown error'}`);
|
|
295
|
+
const interactionSeqResult = result.sequentialResults?.[1];
|
|
296
|
+
if (interactionSeqResult && !interactionSeqResult.success) {
|
|
297
|
+
throw new Error(`Interaction transaction failed: ${interactionSeqResult.error || 'Unknown error'}`);
|
|
265
298
|
}
|
|
299
|
+
const interactionTxId = interactionSeqResult?.txid || signedTx.interactionTransactionRaw;
|
|
300
|
+
const peers = interactionSeqResult?.peers || 0;
|
|
266
301
|
this.#processUTXOTracking(signedTx);
|
|
267
302
|
return {
|
|
268
303
|
interactionAddress: signedTx.interactionAddress,
|
|
269
|
-
transactionId:
|
|
270
|
-
peerAcknowledgements:
|
|
304
|
+
transactionId: interactionTxId,
|
|
305
|
+
peerAcknowledgements: peers,
|
|
271
306
|
newUTXOs: signedTx.nextUTXOs,
|
|
272
307
|
estimatedFees: signedTx.estimatedFees,
|
|
273
308
|
challengeSolution: signedTx.challengeSolution,
|
|
@@ -392,6 +427,9 @@ export class CallResult {
|
|
|
392
427
|
}
|
|
393
428
|
}
|
|
394
429
|
}
|
|
430
|
+
max(a, b) {
|
|
431
|
+
return a > b ? a : b;
|
|
432
|
+
}
|
|
395
433
|
async acquire(interactionParams, amountAddition = 0n) {
|
|
396
434
|
if (!this.calldata) {
|
|
397
435
|
throw new Error('Calldata not set');
|
|
@@ -404,21 +442,12 @@ export class CallResult {
|
|
|
404
442
|
const addedOuts = interactionParams.extraOutputs ?? [];
|
|
405
443
|
const totalOuts = addedOuts.reduce((s, o) => s + BigInt(o.value), 0n);
|
|
406
444
|
const gasFee = this.bigintMax(this.estimatedSatGas, interactionParams.minGas ?? 0n);
|
|
407
|
-
const preWant = gasFee +
|
|
408
|
-
priority +
|
|
409
|
-
amountAddition +
|
|
410
|
-
totalOuts +
|
|
411
|
-
interactionParams.maximumAllowedSatToSpend;
|
|
445
|
+
const preWant = this.max(gasFee + priority + amountAddition + totalOuts, interactionParams.maximumAllowedSatToSpend);
|
|
412
446
|
let utxos = interactionParams.utxos ?? (await this.#fetchUTXOs(preWant, interactionParams));
|
|
413
447
|
let refetched = false;
|
|
414
448
|
while (true) {
|
|
415
449
|
const miningCost = TransactionHelper.estimateMiningCost(utxos, addedOuts, this.calldata.length + 200, interactionParams.network, feeRate);
|
|
416
|
-
const want = gasFee +
|
|
417
|
-
priority +
|
|
418
|
-
amountAddition +
|
|
419
|
-
totalOuts +
|
|
420
|
-
miningCost +
|
|
421
|
-
interactionParams.maximumAllowedSatToSpend;
|
|
450
|
+
const want = this.max(gasFee + priority + amountAddition + totalOuts + miningCost, interactionParams.maximumAllowedSatToSpend);
|
|
422
451
|
const have = utxos.reduce((s, u) => s + u.value, 0n);
|
|
423
452
|
if (have >= want)
|
|
424
453
|
break;
|
|
@@ -2,6 +2,7 @@ import { Network } from '@btc-vision/bitcoin';
|
|
|
2
2
|
import { Address, ChallengeSolution, IP2WSHAddress } from '@btc-vision/transaction';
|
|
3
3
|
import { UTXO, UTXOs } from '../../bitcoin/UTXOs.js';
|
|
4
4
|
import { BroadcastedTransaction } from '../../transactions/interfaces/BroadcastedTransaction.js';
|
|
5
|
+
import { BroadcastedTransactionPackage } from '../../transactions/interfaces/BroadcastedTransactionPackage.js';
|
|
5
6
|
import { RequestUTXOsParamsWithAmount } from '../../utxos/interfaces/IUTXOsManager.js';
|
|
6
7
|
export interface IUTXOManagerForCallResult {
|
|
7
8
|
getUTXOsForAmount(params: RequestUTXOsParamsWithAmount): Promise<UTXO[]>;
|
|
@@ -13,5 +14,6 @@ export interface IProviderForCallResult {
|
|
|
13
14
|
readonly utxoManager: IUTXOManagerForCallResult;
|
|
14
15
|
getChallenge(): Promise<ChallengeSolution>;
|
|
15
16
|
sendRawTransaction(tx: string, psbt: boolean): Promise<BroadcastedTransaction>;
|
|
17
|
+
sendRawTransactionPackage(txs: string[], isPackage?: boolean): Promise<BroadcastedTransactionPackage>;
|
|
16
18
|
getCSV1ForAddress(address: Address): IP2WSHAddress;
|
|
17
19
|
}
|
package/build/opnet.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export * from './storage/interfaces/IStorageValue.js';
|
|
|
70
70
|
export * from './storage/StoredValue.js';
|
|
71
71
|
export * from './contracts/interfaces/IRawContract.js';
|
|
72
72
|
export * from './transactions/interfaces/BroadcastedTransaction.js';
|
|
73
|
+
export * from './transactions/interfaces/BroadcastedTransactionPackage.js';
|
|
73
74
|
export * from './transactions/interfaces/ITransaction.js';
|
|
74
75
|
export * from './transactions/interfaces/ITransactionReceipt.js';
|
|
75
76
|
export * from './transactions/metadata/TransactionReceipt.js';
|
package/build/opnet.js
CHANGED
|
@@ -70,6 +70,7 @@ export * from './storage/interfaces/IStorageValue.js';
|
|
|
70
70
|
export * from './storage/StoredValue.js';
|
|
71
71
|
export * from './contracts/interfaces/IRawContract.js';
|
|
72
72
|
export * from './transactions/interfaces/BroadcastedTransaction.js';
|
|
73
|
+
export * from './transactions/interfaces/BroadcastedTransactionPackage.js';
|
|
73
74
|
export * from './transactions/interfaces/ITransaction.js';
|
|
74
75
|
export * from './transactions/interfaces/ITransactionReceipt.js';
|
|
75
76
|
export * from './transactions/metadata/TransactionReceipt.js';
|
|
@@ -19,6 +19,7 @@ import { OPNetTransactionTypes } from '../interfaces/opnet/OPNetTransactionTypes
|
|
|
19
19
|
import { MempoolTransactionData } from '../mempool/MempoolTransactionData.js';
|
|
20
20
|
import { StoredValue } from '../storage/StoredValue.js';
|
|
21
21
|
import { BroadcastedTransaction } from '../transactions/interfaces/BroadcastedTransaction.js';
|
|
22
|
+
import { BroadcastedTransactionPackage } from '../transactions/interfaces/BroadcastedTransactionPackage.js';
|
|
22
23
|
import { TransactionReceipt } from '../transactions/metadata/TransactionReceipt.js';
|
|
23
24
|
import { TransactionBase } from '../transactions/Transaction.js';
|
|
24
25
|
import { UTXOsManager } from '../utxos/UTXOsManager.js';
|
|
@@ -60,6 +61,7 @@ export declare abstract class AbstractRpcProvider {
|
|
|
60
61
|
gasParameters(): Promise<BlockGasParameters>;
|
|
61
62
|
sendRawTransaction(tx: string, psbt: boolean): Promise<BroadcastedTransaction>;
|
|
62
63
|
sendRawTransactions(txs: string[]): Promise<BroadcastedTransaction[]>;
|
|
64
|
+
sendRawTransactionPackage(txs: string[], isPackage?: boolean): Promise<BroadcastedTransactionPackage>;
|
|
63
65
|
getBlockWitness(height?: BigNumberish, trusted?: boolean, limit?: number, page?: number): Promise<BlockWitnesses>;
|
|
64
66
|
getReorg(fromBlock?: BigNumberish, toBlock?: BigNumberish): Promise<ReorgInformation[]>;
|
|
65
67
|
abstract _send(payload: JsonRpcPayload | JsonRpcPayload[]): Promise<JsonRpcCallResult>;
|
|
@@ -45,8 +45,8 @@ export class AbstractRpcProvider {
|
|
|
45
45
|
const address = addressRaw.toString();
|
|
46
46
|
try {
|
|
47
47
|
const pubKeyInfo = await this.getPublicKeysInfo(address, isContract);
|
|
48
|
-
return pubKeyInfo[address] ||
|
|
49
|
-
pubKeyInfo[address.startsWith('0x') ? address.slice(2) : address];
|
|
48
|
+
return (pubKeyInfo[address] ||
|
|
49
|
+
pubKeyInfo[address.startsWith('0x') ? address.slice(2) : address]);
|
|
50
50
|
}
|
|
51
51
|
catch (e) {
|
|
52
52
|
if (AddressVerificator.isValidPublicKey(address, this.network)) {
|
|
@@ -326,6 +326,19 @@ export class AbstractRpcProvider {
|
|
|
326
326
|
return rawTx.result;
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
|
+
async sendRawTransactionPackage(txs, isPackage = true) {
|
|
330
|
+
if (!txs.length) {
|
|
331
|
+
throw new Error('sendRawTransactionPackage: txs array must not be empty');
|
|
332
|
+
}
|
|
333
|
+
for (let i = 0; i < txs.length; i++) {
|
|
334
|
+
if (!/^[0-9A-Fa-f]+$/.test(txs[i])) {
|
|
335
|
+
throw new Error(`sendRawTransactionPackage: txs[${i}] is not a valid hex string`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const payload = this.buildJsonRpcPayload(JSONRpcMethods.BROADCAST_TRANSACTION_PACKAGE, [txs, isPackage]);
|
|
339
|
+
const result = await this.callPayloadSingle(payload);
|
|
340
|
+
return result.result;
|
|
341
|
+
}
|
|
329
342
|
async getBlockWitness(height = -1, trusted, limit, page) {
|
|
330
343
|
const params = [height.toString()];
|
|
331
344
|
if (trusted !== undefined && trusted !== null)
|
|
@@ -239,6 +239,11 @@ export class WebSocketRpcProvider extends AbstractRpcProvider {
|
|
|
239
239
|
2: params[0],
|
|
240
240
|
3: params[1] ?? false,
|
|
241
241
|
};
|
|
242
|
+
case JSONRpcMethods.BROADCAST_TRANSACTION_PACKAGE:
|
|
243
|
+
return {
|
|
244
|
+
2: params[0],
|
|
245
|
+
3: params[1] ?? true,
|
|
246
|
+
};
|
|
242
247
|
case JSONRpcMethods.TRANSACTION_PREIMAGE:
|
|
243
248
|
return {};
|
|
244
249
|
case JSONRpcMethods.GET_BALANCE:
|
|
@@ -8,6 +8,7 @@ export declare enum JSONRpcMethods {
|
|
|
8
8
|
GAS = "btc_gas",
|
|
9
9
|
GET_TRANSACTION_BY_HASH = "btc_getTransactionByHash",
|
|
10
10
|
BROADCAST_TRANSACTION = "btc_sendRawTransaction",
|
|
11
|
+
BROADCAST_TRANSACTION_PACKAGE = "btc_sendRawTransactionPackage",
|
|
11
12
|
TRANSACTION_PREIMAGE = "btc_preimage",
|
|
12
13
|
PUBLIC_KEY_INFO = "btc_publicKeyInfo",
|
|
13
14
|
GET_UTXOS = "btc_getUTXOs",
|
|
@@ -9,6 +9,7 @@ export var JSONRpcMethods;
|
|
|
9
9
|
JSONRpcMethods["GAS"] = "btc_gas";
|
|
10
10
|
JSONRpcMethods["GET_TRANSACTION_BY_HASH"] = "btc_getTransactionByHash";
|
|
11
11
|
JSONRpcMethods["BROADCAST_TRANSACTION"] = "btc_sendRawTransaction";
|
|
12
|
+
JSONRpcMethods["BROADCAST_TRANSACTION_PACKAGE"] = "btc_sendRawTransactionPackage";
|
|
12
13
|
JSONRpcMethods["TRANSACTION_PREIMAGE"] = "btc_preimage";
|
|
13
14
|
JSONRpcMethods["PUBLIC_KEY_INFO"] = "btc_publicKeyInfo";
|
|
14
15
|
JSONRpcMethods["GET_UTXOS"] = "btc_getUTXOs";
|
|
@@ -55,6 +55,12 @@ export const METHOD_MAPPINGS = {
|
|
|
55
55
|
requestType: 'BroadcastTransactionRequest',
|
|
56
56
|
responseType: 'BroadcastTransactionResponse',
|
|
57
57
|
},
|
|
58
|
+
[JSONRpcMethods.BROADCAST_TRANSACTION_PACKAGE]: {
|
|
59
|
+
requestOpcode: WebSocketRequestOpcode.BROADCAST_TRANSACTION_PACKAGE,
|
|
60
|
+
responseOpcode: WebSocketResponseOpcode.BROADCAST_PACKAGE_RESULT,
|
|
61
|
+
requestType: 'BroadcastTransactionPackageRequest',
|
|
62
|
+
responseType: 'BroadcastTransactionPackageResponse',
|
|
63
|
+
},
|
|
58
64
|
[JSONRpcMethods.TRANSACTION_PREIMAGE]: {
|
|
59
65
|
requestOpcode: WebSocketRequestOpcode.GET_PREIMAGE,
|
|
60
66
|
responseOpcode: WebSocketResponseOpcode.PREIMAGE,
|
|
@@ -10,6 +10,7 @@ export declare enum WebSocketRequestOpcode {
|
|
|
10
10
|
GET_TRANSACTION_BY_HASH = 32,
|
|
11
11
|
GET_TRANSACTION_RECEIPT = 33,
|
|
12
12
|
BROADCAST_TRANSACTION = 34,
|
|
13
|
+
BROADCAST_TRANSACTION_PACKAGE = 39,
|
|
13
14
|
GET_PREIMAGE = 35,
|
|
14
15
|
GET_MEMPOOL_INFO = 36,
|
|
15
16
|
GET_PENDING_TRANSACTION = 37,
|
|
@@ -43,6 +44,7 @@ export declare enum WebSocketResponseOpcode {
|
|
|
43
44
|
TRANSACTION = 160,
|
|
44
45
|
TRANSACTION_RECEIPT = 161,
|
|
45
46
|
BROADCAST_RESULT = 162,
|
|
47
|
+
BROADCAST_PACKAGE_RESULT = 167,
|
|
46
48
|
PREIMAGE = 163,
|
|
47
49
|
MEMPOOL_INFO = 164,
|
|
48
50
|
PENDING_TRANSACTION = 165,
|
|
@@ -11,6 +11,7 @@ export var WebSocketRequestOpcode;
|
|
|
11
11
|
WebSocketRequestOpcode[WebSocketRequestOpcode["GET_TRANSACTION_BY_HASH"] = 32] = "GET_TRANSACTION_BY_HASH";
|
|
12
12
|
WebSocketRequestOpcode[WebSocketRequestOpcode["GET_TRANSACTION_RECEIPT"] = 33] = "GET_TRANSACTION_RECEIPT";
|
|
13
13
|
WebSocketRequestOpcode[WebSocketRequestOpcode["BROADCAST_TRANSACTION"] = 34] = "BROADCAST_TRANSACTION";
|
|
14
|
+
WebSocketRequestOpcode[WebSocketRequestOpcode["BROADCAST_TRANSACTION_PACKAGE"] = 39] = "BROADCAST_TRANSACTION_PACKAGE";
|
|
14
15
|
WebSocketRequestOpcode[WebSocketRequestOpcode["GET_PREIMAGE"] = 35] = "GET_PREIMAGE";
|
|
15
16
|
WebSocketRequestOpcode[WebSocketRequestOpcode["GET_MEMPOOL_INFO"] = 36] = "GET_MEMPOOL_INFO";
|
|
16
17
|
WebSocketRequestOpcode[WebSocketRequestOpcode["GET_PENDING_TRANSACTION"] = 37] = "GET_PENDING_TRANSACTION";
|
|
@@ -45,6 +46,7 @@ export var WebSocketResponseOpcode;
|
|
|
45
46
|
WebSocketResponseOpcode[WebSocketResponseOpcode["TRANSACTION"] = 160] = "TRANSACTION";
|
|
46
47
|
WebSocketResponseOpcode[WebSocketResponseOpcode["TRANSACTION_RECEIPT"] = 161] = "TRANSACTION_RECEIPT";
|
|
47
48
|
WebSocketResponseOpcode[WebSocketResponseOpcode["BROADCAST_RESULT"] = 162] = "BROADCAST_RESULT";
|
|
49
|
+
WebSocketResponseOpcode[WebSocketResponseOpcode["BROADCAST_PACKAGE_RESULT"] = 167] = "BROADCAST_PACKAGE_RESULT";
|
|
48
50
|
WebSocketResponseOpcode[WebSocketResponseOpcode["PREIMAGE"] = 163] = "PREIMAGE";
|
|
49
51
|
WebSocketResponseOpcode[WebSocketResponseOpcode["MEMPOOL_INFO"] = 164] = "MEMPOOL_INFO";
|
|
50
52
|
WebSocketResponseOpcode[WebSocketResponseOpcode["PENDING_TRANSACTION"] = 165] = "PENDING_TRANSACTION";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface SequentialBroadcastTxResult {
|
|
2
|
+
readonly txid: string;
|
|
3
|
+
readonly success: boolean;
|
|
4
|
+
readonly error?: string;
|
|
5
|
+
readonly peers?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface BroadcastedTransactionPackage {
|
|
8
|
+
readonly success: boolean;
|
|
9
|
+
readonly error?: string;
|
|
10
|
+
readonly testResults?: readonly TestMempoolAcceptResult[];
|
|
11
|
+
readonly packageResult?: PackageResult;
|
|
12
|
+
readonly sequentialResults?: readonly SequentialBroadcastTxResult[];
|
|
13
|
+
readonly fellBackToSequential?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface TestMempoolAcceptResult {
|
|
16
|
+
readonly txid: string;
|
|
17
|
+
readonly wtxid: string;
|
|
18
|
+
readonly allowed?: boolean;
|
|
19
|
+
readonly vsize?: number;
|
|
20
|
+
readonly packageError?: string;
|
|
21
|
+
readonly rejectReason?: string;
|
|
22
|
+
readonly rejectDetails?: string;
|
|
23
|
+
readonly fees?: TestMempoolAcceptFees;
|
|
24
|
+
}
|
|
25
|
+
export interface TestMempoolAcceptFees {
|
|
26
|
+
readonly base: number;
|
|
27
|
+
readonly effectiveFeerate: number;
|
|
28
|
+
readonly effectiveIncludes: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
export interface PackageTxResult {
|
|
31
|
+
readonly txid: string;
|
|
32
|
+
readonly otherWtxid?: string;
|
|
33
|
+
readonly vsize?: number;
|
|
34
|
+
readonly fees?: PackageTxFees;
|
|
35
|
+
readonly error?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PackageTxFees {
|
|
38
|
+
readonly base: number;
|
|
39
|
+
readonly effectiveFeerate?: number;
|
|
40
|
+
readonly effectiveIncludes?: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
export interface PackageResult {
|
|
43
|
+
readonly packageMsg: string;
|
|
44
|
+
readonly txResults: {
|
|
45
|
+
readonly [wtxid: string]: PackageTxResult;
|
|
46
|
+
};
|
|
47
|
+
readonly replacedTransactions?: readonly string[];
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|