@meshsdk/bitcoin 1.9.0-beta.78 → 1.9.0-beta.79
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/index.cjs +586 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +156 -7
- package/dist/index.d.ts +156 -7
- package/dist/index.js +585 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -518,6 +518,9 @@ __export(index_exports, {
|
|
|
518
518
|
EmbeddedWallet: function() {
|
|
519
519
|
return EmbeddedWallet;
|
|
520
520
|
},
|
|
521
|
+
MaestroProvider: function() {
|
|
522
|
+
return MaestroProvider;
|
|
523
|
+
},
|
|
521
524
|
bip32: function() {
|
|
522
525
|
return bip32;
|
|
523
526
|
},
|
|
@@ -4002,6 +4005,589 @@ var BlockstreamProvider = /*#__PURE__*/ function() {
|
|
|
4002
4005
|
]);
|
|
4003
4006
|
return BlockstreamProvider;
|
|
4004
4007
|
}();
|
|
4008
|
+
// src/providers/maestro.ts
|
|
4009
|
+
var MaestroProvider = /*#__PURE__*/ function() {
|
|
4010
|
+
function MaestroProvider(param) {
|
|
4011
|
+
var network = param.network, apiKey = param.apiKey;
|
|
4012
|
+
_class_call_check(this, MaestroProvider);
|
|
4013
|
+
this._axiosInstance = axios_default.create({
|
|
4014
|
+
baseURL: "https://xbt-".concat(network, ".gomaestro-api.org/v0"),
|
|
4015
|
+
headers: {
|
|
4016
|
+
"api-key": apiKey
|
|
4017
|
+
}
|
|
4018
|
+
});
|
|
4019
|
+
this._network = network;
|
|
4020
|
+
}
|
|
4021
|
+
_create_class(MaestroProvider, [
|
|
4022
|
+
{
|
|
4023
|
+
key: "fetchScript",
|
|
4024
|
+
value: /**
|
|
4025
|
+
* Get information about a script hash.
|
|
4026
|
+
* @param hash - The script hash.
|
|
4027
|
+
* @returns ScriptInfo
|
|
4028
|
+
* @note Maestro does not have any endpoint available for this yet
|
|
4029
|
+
*/ function fetchScript(hash) {
|
|
4030
|
+
return _async_to_generator(function() {
|
|
4031
|
+
return _ts_generator(this, function(_state) {
|
|
4032
|
+
throw new Error("fetchScript is not implemented - Maestro does not have any endpoint available for this yet");
|
|
4033
|
+
});
|
|
4034
|
+
})();
|
|
4035
|
+
}
|
|
4036
|
+
},
|
|
4037
|
+
{
|
|
4038
|
+
key: "fetchScriptTransactions",
|
|
4039
|
+
value: /**
|
|
4040
|
+
* Get transaction history for the specified script hash, sorted with newest first.
|
|
4041
|
+
* @param hash - The script hash.
|
|
4042
|
+
* @param last_seen_txid - The last seen transaction ID (optional).
|
|
4043
|
+
* @returns TransactionsInfo[]
|
|
4044
|
+
* @note Maestro does not have any endpoint available for this yet
|
|
4045
|
+
*/ function fetchScriptTransactions(hash, last_seen_txid) {
|
|
4046
|
+
return _async_to_generator(function() {
|
|
4047
|
+
return _ts_generator(this, function(_state) {
|
|
4048
|
+
throw new Error("fetchScriptTransactions is not implemented - Maestro does not have any endpoint available for this yet");
|
|
4049
|
+
});
|
|
4050
|
+
})();
|
|
4051
|
+
}
|
|
4052
|
+
},
|
|
4053
|
+
{
|
|
4054
|
+
key: "fetchScriptUTxOs",
|
|
4055
|
+
value: /**
|
|
4056
|
+
* Get the list of unspent transaction outputs associated with the script hash.
|
|
4057
|
+
* @param hash - The script hash.
|
|
4058
|
+
* @returns UTxO[]
|
|
4059
|
+
* @note Maestro does not have any endpoint available for this yet
|
|
4060
|
+
*/ function fetchScriptUTxOs(hash) {
|
|
4061
|
+
return _async_to_generator(function() {
|
|
4062
|
+
return _ts_generator(this, function(_state) {
|
|
4063
|
+
throw new Error("fetchScriptUTxOs is not implemented - Maestro does not have any endpoint available for this yet");
|
|
4064
|
+
});
|
|
4065
|
+
})();
|
|
4066
|
+
}
|
|
4067
|
+
},
|
|
4068
|
+
{
|
|
4069
|
+
key: "fetchAddress",
|
|
4070
|
+
value: /**
|
|
4071
|
+
* Get information about an address.
|
|
4072
|
+
* @param address - The address.
|
|
4073
|
+
* @returns AddressInfo
|
|
4074
|
+
*/ function fetchAddress(address) {
|
|
4075
|
+
return _async_to_generator(function() {
|
|
4076
|
+
var _ref, data, status, error;
|
|
4077
|
+
return _ts_generator(this, function(_state) {
|
|
4078
|
+
switch(_state.label){
|
|
4079
|
+
case 0:
|
|
4080
|
+
_state.trys.push([
|
|
4081
|
+
0,
|
|
4082
|
+
2,
|
|
4083
|
+
,
|
|
4084
|
+
3
|
|
4085
|
+
]);
|
|
4086
|
+
return [
|
|
4087
|
+
4,
|
|
4088
|
+
this._axiosInstance.get("/esplora/address/".concat(address))
|
|
4089
|
+
];
|
|
4090
|
+
case 1:
|
|
4091
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4092
|
+
if (status === 200) return [
|
|
4093
|
+
2,
|
|
4094
|
+
data
|
|
4095
|
+
];
|
|
4096
|
+
throw parseHttpError(data);
|
|
4097
|
+
case 2:
|
|
4098
|
+
error = _state.sent();
|
|
4099
|
+
throw parseHttpError(error);
|
|
4100
|
+
case 3:
|
|
4101
|
+
return [
|
|
4102
|
+
2
|
|
4103
|
+
];
|
|
4104
|
+
}
|
|
4105
|
+
});
|
|
4106
|
+
}).call(this);
|
|
4107
|
+
}
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
key: "fetchAddressTransactions",
|
|
4111
|
+
value: /**
|
|
4112
|
+
* Get transaction history for the specified address, sorted with newest first.
|
|
4113
|
+
* Returns up to 50 mempool transactions plus the first 25 confirmed transactions. You can request more confirmed transactions using `last_seen_txid`.
|
|
4114
|
+
* @param address - The address.
|
|
4115
|
+
* @param last_seen_txid - The last seen transaction ID (optional).
|
|
4116
|
+
* @returns TransactionsInfo[]
|
|
4117
|
+
*/ function fetchAddressTransactions(address, last_seen_txid) {
|
|
4118
|
+
return _async_to_generator(function() {
|
|
4119
|
+
var url, _ref, data, status, error;
|
|
4120
|
+
return _ts_generator(this, function(_state) {
|
|
4121
|
+
switch(_state.label){
|
|
4122
|
+
case 0:
|
|
4123
|
+
_state.trys.push([
|
|
4124
|
+
0,
|
|
4125
|
+
2,
|
|
4126
|
+
,
|
|
4127
|
+
3
|
|
4128
|
+
]);
|
|
4129
|
+
url = last_seen_txid ? "/esplora/address/".concat(address, "/txs/chain/").concat(last_seen_txid) : "/esplora/address/".concat(address, "/txs");
|
|
4130
|
+
return [
|
|
4131
|
+
4,
|
|
4132
|
+
this._axiosInstance.get(url)
|
|
4133
|
+
];
|
|
4134
|
+
case 1:
|
|
4135
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4136
|
+
if (status === 200) return [
|
|
4137
|
+
2,
|
|
4138
|
+
data
|
|
4139
|
+
];
|
|
4140
|
+
throw parseHttpError(data);
|
|
4141
|
+
case 2:
|
|
4142
|
+
error = _state.sent();
|
|
4143
|
+
throw parseHttpError(error);
|
|
4144
|
+
case 3:
|
|
4145
|
+
return [
|
|
4146
|
+
2
|
|
4147
|
+
];
|
|
4148
|
+
}
|
|
4149
|
+
});
|
|
4150
|
+
}).call(this);
|
|
4151
|
+
}
|
|
4152
|
+
},
|
|
4153
|
+
{
|
|
4154
|
+
key: "fetchAddressUTxOs",
|
|
4155
|
+
value: /**
|
|
4156
|
+
* Get the list of unspent transaction outputs associated with the address.
|
|
4157
|
+
* @param address - The address.
|
|
4158
|
+
* @returns UTxO[]
|
|
4159
|
+
*/ function fetchAddressUTxOs(address) {
|
|
4160
|
+
return _async_to_generator(function() {
|
|
4161
|
+
var _ref, data, status, error;
|
|
4162
|
+
return _ts_generator(this, function(_state) {
|
|
4163
|
+
switch(_state.label){
|
|
4164
|
+
case 0:
|
|
4165
|
+
_state.trys.push([
|
|
4166
|
+
0,
|
|
4167
|
+
2,
|
|
4168
|
+
,
|
|
4169
|
+
3
|
|
4170
|
+
]);
|
|
4171
|
+
return [
|
|
4172
|
+
4,
|
|
4173
|
+
this._axiosInstance.get("/esplora/address/".concat(address, "/utxo"))
|
|
4174
|
+
];
|
|
4175
|
+
case 1:
|
|
4176
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4177
|
+
if (status === 200) return [
|
|
4178
|
+
2,
|
|
4179
|
+
data
|
|
4180
|
+
];
|
|
4181
|
+
throw parseHttpError(data);
|
|
4182
|
+
case 2:
|
|
4183
|
+
error = _state.sent();
|
|
4184
|
+
throw parseHttpError(error);
|
|
4185
|
+
case 3:
|
|
4186
|
+
return [
|
|
4187
|
+
2
|
|
4188
|
+
];
|
|
4189
|
+
}
|
|
4190
|
+
});
|
|
4191
|
+
}).call(this);
|
|
4192
|
+
}
|
|
4193
|
+
},
|
|
4194
|
+
{
|
|
4195
|
+
key: "fetchTransactionStatus",
|
|
4196
|
+
value: /**
|
|
4197
|
+
* Get the spending status of a transaction output.
|
|
4198
|
+
* @param txid - The transaction ID.
|
|
4199
|
+
* @returns TransactionsStatus
|
|
4200
|
+
*/ function fetchTransactionStatus(txid) {
|
|
4201
|
+
return _async_to_generator(function() {
|
|
4202
|
+
var _ref, data, status, error;
|
|
4203
|
+
return _ts_generator(this, function(_state) {
|
|
4204
|
+
switch(_state.label){
|
|
4205
|
+
case 0:
|
|
4206
|
+
_state.trys.push([
|
|
4207
|
+
0,
|
|
4208
|
+
2,
|
|
4209
|
+
,
|
|
4210
|
+
3
|
|
4211
|
+
]);
|
|
4212
|
+
return [
|
|
4213
|
+
4,
|
|
4214
|
+
this._axiosInstance.get("/esplora/tx/".concat(txid, "/status"))
|
|
4215
|
+
];
|
|
4216
|
+
case 1:
|
|
4217
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4218
|
+
if (status === 200) return [
|
|
4219
|
+
2,
|
|
4220
|
+
data
|
|
4221
|
+
];
|
|
4222
|
+
throw parseHttpError(data);
|
|
4223
|
+
case 2:
|
|
4224
|
+
error = _state.sent();
|
|
4225
|
+
throw parseHttpError(error);
|
|
4226
|
+
case 3:
|
|
4227
|
+
return [
|
|
4228
|
+
2
|
|
4229
|
+
];
|
|
4230
|
+
}
|
|
4231
|
+
});
|
|
4232
|
+
}).call(this);
|
|
4233
|
+
}
|
|
4234
|
+
},
|
|
4235
|
+
{
|
|
4236
|
+
key: "submitTx",
|
|
4237
|
+
value: /**
|
|
4238
|
+
* Broadcast a raw transaction to the network.
|
|
4239
|
+
* @param txHex - The raw transaction in hexadecimal format.
|
|
4240
|
+
* @returns The transaction ID.
|
|
4241
|
+
*/ function submitTx(txHex) {
|
|
4242
|
+
return _async_to_generator(function() {
|
|
4243
|
+
var _ref, data, status, error;
|
|
4244
|
+
return _ts_generator(this, function(_state) {
|
|
4245
|
+
switch(_state.label){
|
|
4246
|
+
case 0:
|
|
4247
|
+
_state.trys.push([
|
|
4248
|
+
0,
|
|
4249
|
+
2,
|
|
4250
|
+
,
|
|
4251
|
+
3
|
|
4252
|
+
]);
|
|
4253
|
+
return [
|
|
4254
|
+
4,
|
|
4255
|
+
this._axiosInstance.post("/esplora/tx", txHex, {
|
|
4256
|
+
headers: {
|
|
4257
|
+
"Content-Type": "application/json"
|
|
4258
|
+
}
|
|
4259
|
+
})
|
|
4260
|
+
];
|
|
4261
|
+
case 1:
|
|
4262
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4263
|
+
if (status === 200) return [
|
|
4264
|
+
2,
|
|
4265
|
+
data.txid || data
|
|
4266
|
+
];
|
|
4267
|
+
throw parseHttpError(data);
|
|
4268
|
+
case 2:
|
|
4269
|
+
error = _state.sent();
|
|
4270
|
+
throw parseHttpError(error);
|
|
4271
|
+
case 3:
|
|
4272
|
+
return [
|
|
4273
|
+
2
|
|
4274
|
+
];
|
|
4275
|
+
}
|
|
4276
|
+
});
|
|
4277
|
+
}).call(this);
|
|
4278
|
+
}
|
|
4279
|
+
},
|
|
4280
|
+
{
|
|
4281
|
+
key: "fetchFeeEstimates",
|
|
4282
|
+
value: // Additional Bitcoin-specific methods (beyond IBitcoinProvider)
|
|
4283
|
+
/**
|
|
4284
|
+
* Get fee estimates for Bitcoin transactions.
|
|
4285
|
+
* @param blocks - The number of blocks to estimate fees for (default: 6).
|
|
4286
|
+
* @returns FeeEstimateResponse containing the estimated fee rate.
|
|
4287
|
+
*/ function fetchFeeEstimates() {
|
|
4288
|
+
var blocks = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 6;
|
|
4289
|
+
return _async_to_generator(function() {
|
|
4290
|
+
var _ref, data, status, error;
|
|
4291
|
+
return _ts_generator(this, function(_state) {
|
|
4292
|
+
switch(_state.label){
|
|
4293
|
+
case 0:
|
|
4294
|
+
_state.trys.push([
|
|
4295
|
+
0,
|
|
4296
|
+
2,
|
|
4297
|
+
,
|
|
4298
|
+
3
|
|
4299
|
+
]);
|
|
4300
|
+
return [
|
|
4301
|
+
4,
|
|
4302
|
+
this._axiosInstance.get("/rpc/transaction/estimatefee/".concat(blocks))
|
|
4303
|
+
];
|
|
4304
|
+
case 1:
|
|
4305
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4306
|
+
if (status === 200) return [
|
|
4307
|
+
2,
|
|
4308
|
+
data
|
|
4309
|
+
];
|
|
4310
|
+
throw parseHttpError(data);
|
|
4311
|
+
case 2:
|
|
4312
|
+
error = _state.sent();
|
|
4313
|
+
throw parseHttpError(error);
|
|
4314
|
+
case 3:
|
|
4315
|
+
return [
|
|
4316
|
+
2
|
|
4317
|
+
];
|
|
4318
|
+
}
|
|
4319
|
+
});
|
|
4320
|
+
}).call(this);
|
|
4321
|
+
}
|
|
4322
|
+
},
|
|
4323
|
+
{
|
|
4324
|
+
key: "fetchSatoshiActivity",
|
|
4325
|
+
value: /**
|
|
4326
|
+
* Fetch satoshi activity for a Bitcoin address (transaction history).
|
|
4327
|
+
* @param address - The Bitcoin address.
|
|
4328
|
+
* @param options - Optional parameters for filtering and pagination.
|
|
4329
|
+
* @param options.order - Sort order ('asc' or 'desc').
|
|
4330
|
+
* @param options.count - Maximum number of results to return.
|
|
4331
|
+
* @param options.from - Start block height.
|
|
4332
|
+
* @param options.to - End block height.
|
|
4333
|
+
* @param options.cursor - Pagination cursor.
|
|
4334
|
+
* @returns SatoshiActivityResponse containing transaction activity data.
|
|
4335
|
+
*/ function fetchSatoshiActivity(_0) {
|
|
4336
|
+
return _async_to_generator(function(address) {
|
|
4337
|
+
var options, params, queryString, url, _ref, data, status, error;
|
|
4338
|
+
var _arguments = arguments;
|
|
4339
|
+
return _ts_generator(this, function(_state) {
|
|
4340
|
+
switch(_state.label){
|
|
4341
|
+
case 0:
|
|
4342
|
+
options = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
4343
|
+
params = new URLSearchParams();
|
|
4344
|
+
Object.entries(options).forEach(function(param) {
|
|
4345
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
4346
|
+
if (value !== void 0 && value !== null) {
|
|
4347
|
+
params.append(key, value.toString());
|
|
4348
|
+
}
|
|
4349
|
+
});
|
|
4350
|
+
queryString = params.toString();
|
|
4351
|
+
url = "/addresses/".concat(address, "/activity").concat(queryString ? "?".concat(queryString) : "");
|
|
4352
|
+
_state.label = 1;
|
|
4353
|
+
case 1:
|
|
4354
|
+
_state.trys.push([
|
|
4355
|
+
1,
|
|
4356
|
+
3,
|
|
4357
|
+
,
|
|
4358
|
+
4
|
|
4359
|
+
]);
|
|
4360
|
+
return [
|
|
4361
|
+
4,
|
|
4362
|
+
this._axiosInstance.get(url)
|
|
4363
|
+
];
|
|
4364
|
+
case 2:
|
|
4365
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4366
|
+
if (status === 200) return [
|
|
4367
|
+
2,
|
|
4368
|
+
data
|
|
4369
|
+
];
|
|
4370
|
+
throw parseHttpError(data);
|
|
4371
|
+
case 3:
|
|
4372
|
+
error = _state.sent();
|
|
4373
|
+
throw parseHttpError(error);
|
|
4374
|
+
case 4:
|
|
4375
|
+
return [
|
|
4376
|
+
2
|
|
4377
|
+
];
|
|
4378
|
+
}
|
|
4379
|
+
});
|
|
4380
|
+
}).apply(this, arguments);
|
|
4381
|
+
}
|
|
4382
|
+
},
|
|
4383
|
+
{
|
|
4384
|
+
key: "fetchTxInfo",
|
|
4385
|
+
value: /**
|
|
4386
|
+
* Get transaction details by hash.
|
|
4387
|
+
* @param hash - The transaction hash.
|
|
4388
|
+
* @returns TransactionsInfo containing transaction details.
|
|
4389
|
+
*/ function fetchTxInfo(hash) {
|
|
4390
|
+
return _async_to_generator(function() {
|
|
4391
|
+
var _ref, data, status, error;
|
|
4392
|
+
return _ts_generator(this, function(_state) {
|
|
4393
|
+
switch(_state.label){
|
|
4394
|
+
case 0:
|
|
4395
|
+
_state.trys.push([
|
|
4396
|
+
0,
|
|
4397
|
+
2,
|
|
4398
|
+
,
|
|
4399
|
+
3
|
|
4400
|
+
]);
|
|
4401
|
+
return [
|
|
4402
|
+
4,
|
|
4403
|
+
this._axiosInstance.get("/esplora/tx/".concat(hash))
|
|
4404
|
+
];
|
|
4405
|
+
case 1:
|
|
4406
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4407
|
+
if (status === 200) return [
|
|
4408
|
+
2,
|
|
4409
|
+
data
|
|
4410
|
+
];
|
|
4411
|
+
throw parseHttpError(data);
|
|
4412
|
+
case 2:
|
|
4413
|
+
error = _state.sent();
|
|
4414
|
+
throw parseHttpError(error);
|
|
4415
|
+
case 3:
|
|
4416
|
+
return [
|
|
4417
|
+
2
|
|
4418
|
+
];
|
|
4419
|
+
}
|
|
4420
|
+
});
|
|
4421
|
+
}).call(this);
|
|
4422
|
+
}
|
|
4423
|
+
},
|
|
4424
|
+
{
|
|
4425
|
+
key: "fetchAddressBalance",
|
|
4426
|
+
value: /**
|
|
4427
|
+
* Get address balance (raw response).
|
|
4428
|
+
* @param address - The Bitcoin address.
|
|
4429
|
+
* @returns BalanceResponse containing the raw balance data.
|
|
4430
|
+
*/ function fetchAddressBalance(address) {
|
|
4431
|
+
return _async_to_generator(function() {
|
|
4432
|
+
var _ref, data, status, error;
|
|
4433
|
+
return _ts_generator(this, function(_state) {
|
|
4434
|
+
switch(_state.label){
|
|
4435
|
+
case 0:
|
|
4436
|
+
_state.trys.push([
|
|
4437
|
+
0,
|
|
4438
|
+
2,
|
|
4439
|
+
,
|
|
4440
|
+
3
|
|
4441
|
+
]);
|
|
4442
|
+
return [
|
|
4443
|
+
4,
|
|
4444
|
+
this._axiosInstance.get("/addresses/".concat(address, "/balance"))
|
|
4445
|
+
];
|
|
4446
|
+
case 1:
|
|
4447
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4448
|
+
if (status === 200) return [
|
|
4449
|
+
2,
|
|
4450
|
+
data
|
|
4451
|
+
];
|
|
4452
|
+
throw parseHttpError(data);
|
|
4453
|
+
case 2:
|
|
4454
|
+
error = _state.sent();
|
|
4455
|
+
throw parseHttpError(error);
|
|
4456
|
+
case 3:
|
|
4457
|
+
return [
|
|
4458
|
+
2
|
|
4459
|
+
];
|
|
4460
|
+
}
|
|
4461
|
+
});
|
|
4462
|
+
}).call(this);
|
|
4463
|
+
}
|
|
4464
|
+
},
|
|
4465
|
+
{
|
|
4466
|
+
key: "getBalance",
|
|
4467
|
+
value: /**
|
|
4468
|
+
* Get balance for a Bitcoin address (convenience method).
|
|
4469
|
+
* @param address - The Bitcoin address.
|
|
4470
|
+
* @returns The balance as a bigint in satoshis.
|
|
4471
|
+
*/ function getBalance(address) {
|
|
4472
|
+
return _async_to_generator(function() {
|
|
4473
|
+
var balanceResponse;
|
|
4474
|
+
return _ts_generator(this, function(_state) {
|
|
4475
|
+
switch(_state.label){
|
|
4476
|
+
case 0:
|
|
4477
|
+
return [
|
|
4478
|
+
4,
|
|
4479
|
+
this.fetchAddressBalance(address)
|
|
4480
|
+
];
|
|
4481
|
+
case 1:
|
|
4482
|
+
balanceResponse = _state.sent();
|
|
4483
|
+
return [
|
|
4484
|
+
2,
|
|
4485
|
+
BigInt(balanceResponse.data)
|
|
4486
|
+
];
|
|
4487
|
+
}
|
|
4488
|
+
});
|
|
4489
|
+
}).call(this);
|
|
4490
|
+
}
|
|
4491
|
+
},
|
|
4492
|
+
{
|
|
4493
|
+
key: "get",
|
|
4494
|
+
value: /**
|
|
4495
|
+
* Generic GET request for Bitcoin API endpoints.
|
|
4496
|
+
* @param url - The API endpoint URL.
|
|
4497
|
+
* @returns The response data.
|
|
4498
|
+
*/ function get(url) {
|
|
4499
|
+
return _async_to_generator(function() {
|
|
4500
|
+
var _ref, data, status, error;
|
|
4501
|
+
return _ts_generator(this, function(_state) {
|
|
4502
|
+
switch(_state.label){
|
|
4503
|
+
case 0:
|
|
4504
|
+
_state.trys.push([
|
|
4505
|
+
0,
|
|
4506
|
+
2,
|
|
4507
|
+
,
|
|
4508
|
+
3
|
|
4509
|
+
]);
|
|
4510
|
+
return [
|
|
4511
|
+
4,
|
|
4512
|
+
this._axiosInstance.get(url)
|
|
4513
|
+
];
|
|
4514
|
+
case 1:
|
|
4515
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4516
|
+
if (status === 200) return [
|
|
4517
|
+
2,
|
|
4518
|
+
data
|
|
4519
|
+
];
|
|
4520
|
+
throw parseHttpError(data);
|
|
4521
|
+
case 2:
|
|
4522
|
+
error = _state.sent();
|
|
4523
|
+
throw parseHttpError(error);
|
|
4524
|
+
case 3:
|
|
4525
|
+
return [
|
|
4526
|
+
2
|
|
4527
|
+
];
|
|
4528
|
+
}
|
|
4529
|
+
});
|
|
4530
|
+
}).call(this);
|
|
4531
|
+
}
|
|
4532
|
+
},
|
|
4533
|
+
{
|
|
4534
|
+
key: "post",
|
|
4535
|
+
value: /**
|
|
4536
|
+
* Generic POST request for Bitcoin API endpoints.
|
|
4537
|
+
* @param url - The API endpoint URL.
|
|
4538
|
+
* @param body - The request body data.
|
|
4539
|
+
* @returns The response data.
|
|
4540
|
+
*/ function post(url, body) {
|
|
4541
|
+
return _async_to_generator(function() {
|
|
4542
|
+
var _ref, data, status, error;
|
|
4543
|
+
return _ts_generator(this, function(_state) {
|
|
4544
|
+
switch(_state.label){
|
|
4545
|
+
case 0:
|
|
4546
|
+
_state.trys.push([
|
|
4547
|
+
0,
|
|
4548
|
+
2,
|
|
4549
|
+
,
|
|
4550
|
+
3
|
|
4551
|
+
]);
|
|
4552
|
+
return [
|
|
4553
|
+
4,
|
|
4554
|
+
this._axiosInstance.post(url, body, {
|
|
4555
|
+
headers: {
|
|
4556
|
+
"Content-Type": "application/json"
|
|
4557
|
+
}
|
|
4558
|
+
})
|
|
4559
|
+
];
|
|
4560
|
+
case 1:
|
|
4561
|
+
_ref = _state.sent(), data = _ref.data, status = _ref.status;
|
|
4562
|
+
if (status === 200) return [
|
|
4563
|
+
2,
|
|
4564
|
+
data
|
|
4565
|
+
];
|
|
4566
|
+
throw parseHttpError(data);
|
|
4567
|
+
case 2:
|
|
4568
|
+
error = _state.sent();
|
|
4569
|
+
throw parseHttpError(error);
|
|
4570
|
+
case 3:
|
|
4571
|
+
return [
|
|
4572
|
+
2
|
|
4573
|
+
];
|
|
4574
|
+
}
|
|
4575
|
+
});
|
|
4576
|
+
}).call(this);
|
|
4577
|
+
}
|
|
4578
|
+
},
|
|
4579
|
+
{
|
|
4580
|
+
/**
|
|
4581
|
+
* Get the network this provider is configured for.
|
|
4582
|
+
* @returns The network configuration (mainnet or testnet).
|
|
4583
|
+
*/ key: "getNetwork",
|
|
4584
|
+
value: function getNetwork() {
|
|
4585
|
+
return this._network;
|
|
4586
|
+
}
|
|
4587
|
+
}
|
|
4588
|
+
]);
|
|
4589
|
+
return MaestroProvider;
|
|
4590
|
+
}();
|
|
4005
4591
|
// src/utils/address.ts
|
|
4006
4592
|
function resolveAddress(publicKey, network) {
|
|
4007
4593
|
var p2wpkh = bitcoin.payments.p2wpkh({
|