@dynamic-labs-wallet/btc-utils 1.1.70 → 1.1.71
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/index.cjs +133 -33
- package/index.esm.js +132 -34
- package/package.json +2 -2
- package/src/extractPsbtIntentOperation/extractPsbtIntentOperation.d.ts +36 -0
- package/src/extractPsbtIntentOperation/extractPsbtIntentOperation.d.ts.map +1 -0
- package/src/extractPsbtIntentOperation/index.d.ts +3 -0
- package/src/extractPsbtIntentOperation/index.d.ts.map +1 -0
- package/src/getBtcChainId/getBtcChainId.d.ts +13 -0
- package/src/getBtcChainId/getBtcChainId.d.ts.map +1 -0
- package/src/getBtcChainId/index.d.ts +2 -0
- package/src/getBtcChainId/index.d.ts.map +1 -0
- package/src/index.d.ts +3 -0
- package/src/index.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -350,30 +350,30 @@ var convertObjectToBuffer = function(actualPubkey) {
|
|
|
350
350
|
throw new Error('Unable to determine Bitcoin address type');
|
|
351
351
|
};
|
|
352
352
|
|
|
353
|
-
function _array_like_to_array$
|
|
353
|
+
function _array_like_to_array$3(arr, len) {
|
|
354
354
|
if (len == null || len > arr.length) len = arr.length;
|
|
355
355
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
356
356
|
return arr2;
|
|
357
357
|
}
|
|
358
|
-
function _array_without_holes$
|
|
359
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
358
|
+
function _array_without_holes$3(arr) {
|
|
359
|
+
if (Array.isArray(arr)) return _array_like_to_array$3(arr);
|
|
360
360
|
}
|
|
361
|
-
function _iterable_to_array$
|
|
361
|
+
function _iterable_to_array$3(iter) {
|
|
362
362
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
363
363
|
}
|
|
364
|
-
function _non_iterable_spread$
|
|
364
|
+
function _non_iterable_spread$3() {
|
|
365
365
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
366
366
|
}
|
|
367
|
-
function _to_consumable_array$
|
|
368
|
-
return _array_without_holes$
|
|
367
|
+
function _to_consumable_array$3(arr) {
|
|
368
|
+
return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread$3();
|
|
369
369
|
}
|
|
370
|
-
function _unsupported_iterable_to_array$
|
|
370
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
371
371
|
if (!o) return;
|
|
372
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
372
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
373
373
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
374
374
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
375
375
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
376
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
376
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
377
377
|
}
|
|
378
378
|
var NULL_PREVOUT_HASH = new Uint8Array(32);
|
|
379
379
|
var NULL_PREVOUT_INDEX = 0xffffffff;
|
|
@@ -393,7 +393,7 @@ var OP_0_PUSH32 = [
|
|
|
393
393
|
var tx = new bitcoin__namespace.Transaction();
|
|
394
394
|
tx.version = 0;
|
|
395
395
|
tx.locktime = 0;
|
|
396
|
-
tx.addInput(NULL_PREVOUT_HASH, NULL_PREVOUT_INDEX, 0, new Uint8Array(_to_consumable_array$
|
|
396
|
+
tx.addInput(NULL_PREVOUT_HASH, NULL_PREVOUT_INDEX, 0, new Uint8Array(_to_consumable_array$3(OP_0_PUSH32).concat(_to_consumable_array$3(bip322Js.BIP322.hashMessage(message)))));
|
|
397
397
|
tx.addOutput(scriptPubKey, BigInt(0));
|
|
398
398
|
return tx;
|
|
399
399
|
};
|
|
@@ -1102,30 +1102,30 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1102
1102
|
};
|
|
1103
1103
|
}();
|
|
1104
1104
|
|
|
1105
|
-
function _array_like_to_array$
|
|
1105
|
+
function _array_like_to_array$2(arr, len) {
|
|
1106
1106
|
if (len == null || len > arr.length) len = arr.length;
|
|
1107
1107
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1108
1108
|
return arr2;
|
|
1109
1109
|
}
|
|
1110
|
-
function _array_without_holes$
|
|
1111
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
1110
|
+
function _array_without_holes$2(arr) {
|
|
1111
|
+
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
|
|
1112
1112
|
}
|
|
1113
|
-
function _iterable_to_array$
|
|
1113
|
+
function _iterable_to_array$2(iter) {
|
|
1114
1114
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1115
1115
|
}
|
|
1116
|
-
function _non_iterable_spread$
|
|
1116
|
+
function _non_iterable_spread$2() {
|
|
1117
1117
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1118
1118
|
}
|
|
1119
|
-
function _to_consumable_array$
|
|
1120
|
-
return _array_without_holes$
|
|
1119
|
+
function _to_consumable_array$2(arr) {
|
|
1120
|
+
return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$2();
|
|
1121
1121
|
}
|
|
1122
|
-
function _unsupported_iterable_to_array$
|
|
1122
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
1123
1123
|
if (!o) return;
|
|
1124
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
1124
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
1125
1125
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1126
1126
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1127
1127
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1128
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
1128
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
1129
1129
|
}
|
|
1130
1130
|
/**
|
|
1131
1131
|
* Simple greedy coin selection
|
|
@@ -1137,7 +1137,7 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
1137
1137
|
*/ var selectUTXOs = function(param) {
|
|
1138
1138
|
var utxos = param.utxos, amount = param.amount, feeRate = param.feeRate;
|
|
1139
1139
|
// Sort by value descending
|
|
1140
|
-
var sorted = _to_consumable_array$
|
|
1140
|
+
var sorted = _to_consumable_array$2(utxos).sort(function(a, b) {
|
|
1141
1141
|
return Number(b.value - a.value);
|
|
1142
1142
|
});
|
|
1143
1143
|
var inputs = [];
|
|
@@ -1183,13 +1183,13 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
1183
1183
|
throw new Error('Insufficient funds');
|
|
1184
1184
|
};
|
|
1185
1185
|
|
|
1186
|
-
function _array_like_to_array(arr, len) {
|
|
1186
|
+
function _array_like_to_array$1(arr, len) {
|
|
1187
1187
|
if (len == null || len > arr.length) len = arr.length;
|
|
1188
1188
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1189
1189
|
return arr2;
|
|
1190
1190
|
}
|
|
1191
|
-
function _array_without_holes(arr) {
|
|
1192
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1191
|
+
function _array_without_holes$1(arr) {
|
|
1192
|
+
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
|
|
1193
1193
|
}
|
|
1194
1194
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1195
1195
|
try {
|
|
@@ -1220,26 +1220,26 @@ function _async_to_generator(fn) {
|
|
|
1220
1220
|
});
|
|
1221
1221
|
};
|
|
1222
1222
|
}
|
|
1223
|
-
function _iterable_to_array(iter) {
|
|
1223
|
+
function _iterable_to_array$1(iter) {
|
|
1224
1224
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1225
1225
|
}
|
|
1226
|
-
function _non_iterable_spread() {
|
|
1226
|
+
function _non_iterable_spread$1() {
|
|
1227
1227
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1228
1228
|
}
|
|
1229
|
-
function _to_consumable_array(arr) {
|
|
1230
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1229
|
+
function _to_consumable_array$1(arr) {
|
|
1230
|
+
return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread$1();
|
|
1231
1231
|
}
|
|
1232
1232
|
function _type_of$1(obj) {
|
|
1233
1233
|
"@swc/helpers - typeof";
|
|
1234
1234
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1235
1235
|
}
|
|
1236
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1236
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
1237
1237
|
if (!o) return;
|
|
1238
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1238
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
1239
1239
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1240
1240
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1241
1241
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1242
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1242
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
1243
1243
|
}
|
|
1244
1244
|
function _ts_generator(thisArg, body) {
|
|
1245
1245
|
var f, y, t, g, _ = {
|
|
@@ -1360,7 +1360,7 @@ var pickEstimate = function(estimates, target) {
|
|
|
1360
1360
|
}
|
|
1361
1361
|
var _reverse_find;
|
|
1362
1362
|
// Closest target not exceeding the wanted one, else the fastest available.
|
|
1363
|
-
var key = (_reverse_find = _to_consumable_array(targets).reverse().find(function(candidate) {
|
|
1363
|
+
var key = (_reverse_find = _to_consumable_array$1(targets).reverse().find(function(candidate) {
|
|
1364
1364
|
return candidate <= target;
|
|
1365
1365
|
})) !== null && _reverse_find !== void 0 ? _reverse_find : targets[0];
|
|
1366
1366
|
return Math.ceil(assertFeeRate(estimates[String(key)]));
|
|
@@ -1923,6 +1923,104 @@ function _type_of(obj) {
|
|
|
1923
1923
|
return sighashes;
|
|
1924
1924
|
};
|
|
1925
1925
|
|
|
1926
|
+
function _array_like_to_array(arr, len) {
|
|
1927
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1928
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1929
|
+
return arr2;
|
|
1930
|
+
}
|
|
1931
|
+
function _array_without_holes(arr) {
|
|
1932
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1933
|
+
}
|
|
1934
|
+
function _iterable_to_array(iter) {
|
|
1935
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1936
|
+
}
|
|
1937
|
+
function _non_iterable_spread() {
|
|
1938
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1939
|
+
}
|
|
1940
|
+
function _to_consumable_array(arr) {
|
|
1941
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1942
|
+
}
|
|
1943
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
1944
|
+
if (!o) return;
|
|
1945
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1946
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1947
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1948
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1949
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Describes a PSBT the way a BTC signing intent does: its txid, fee, outputs
|
|
1953
|
+
* and the sighashes of the inputs a wallet is about to sign.
|
|
1954
|
+
*
|
|
1955
|
+
* Every input must carry a `witnessUtxo`: the fee needs the value of every
|
|
1956
|
+
* input, and the txid of a segwit transaction does not change once its inputs
|
|
1957
|
+
* are signed. An input with only a `nonWitnessUtxo` is rejected.
|
|
1958
|
+
*
|
|
1959
|
+
* @param psbtBase64 - The PSBT in base64 format
|
|
1960
|
+
* @param network - The Bitcoin network the PSBT is for
|
|
1961
|
+
* @param inputIndexes - The PSBT input indexes the wallet signs
|
|
1962
|
+
* @returns The txid, fee, outputs and the sighashes of `inputIndexes`
|
|
1963
|
+
* @throws Error if an input lacks a `witnessUtxo`, the outputs exceed the inputs,
|
|
1964
|
+
* `inputIndexes` is empty or out of range, or a requested input has no derivable sighash
|
|
1965
|
+
*/ var extractPsbtIntentOperation = function(param) {
|
|
1966
|
+
var inputIndexes = param.inputIndexes, network = param.network, psbtBase64 = param.psbtBase64;
|
|
1967
|
+
var psbt = bitcoin__namespace.Psbt.fromBase64(psbtBase64, {
|
|
1968
|
+
network: getBitcoinNetwork(toBitcoinNetwork(network))
|
|
1969
|
+
});
|
|
1970
|
+
var values = collectPSBTInputData(psbt).values;
|
|
1971
|
+
var tx = psbt.__CACHE.__TX;
|
|
1972
|
+
var inputTotal = values.reduce(function(sum, value) {
|
|
1973
|
+
return sum + value;
|
|
1974
|
+
}, 0n);
|
|
1975
|
+
var outputTotal = tx.outs.reduce(function(sum, output) {
|
|
1976
|
+
return sum + output.value;
|
|
1977
|
+
}, 0n);
|
|
1978
|
+
if (outputTotal > inputTotal) {
|
|
1979
|
+
throw new Error('Transaction outputs exceed its inputs');
|
|
1980
|
+
}
|
|
1981
|
+
var requested = _to_consumable_array(new Set(inputIndexes)).sort(function(a, b) {
|
|
1982
|
+
return a - b;
|
|
1983
|
+
});
|
|
1984
|
+
if (requested.length === 0) {
|
|
1985
|
+
throw new Error('At least one input to sign is required');
|
|
1986
|
+
}
|
|
1987
|
+
var allSighashes = extractPsbtSighashes(psbtBase64, network);
|
|
1988
|
+
var sighashes = requested.map(function(index) {
|
|
1989
|
+
if (!Number.isInteger(index) || index < 0 || index >= allSighashes.length) {
|
|
1990
|
+
throw new Error("Input ".concat(index, " is not in the PSBT"));
|
|
1991
|
+
}
|
|
1992
|
+
var sighash = allSighashes[index];
|
|
1993
|
+
if (sighash === null) {
|
|
1994
|
+
throw new Error("Input ".concat(index, " has no derivable sighash"));
|
|
1995
|
+
}
|
|
1996
|
+
return sighash;
|
|
1997
|
+
});
|
|
1998
|
+
return {
|
|
1999
|
+
feeSats: (inputTotal - outputTotal).toString(),
|
|
2000
|
+
outputs: tx.outs.map(function(output) {
|
|
2001
|
+
return {
|
|
2002
|
+
script: Buffer.from(output.script).toString('hex'),
|
|
2003
|
+
valueSats: output.value.toString()
|
|
2004
|
+
};
|
|
2005
|
+
}),
|
|
2006
|
+
sighashes: sighashes,
|
|
2007
|
+
txid: tx.getId()
|
|
2008
|
+
};
|
|
2009
|
+
};
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* The `chainId` label that identifies a Bitcoin network to the policy layer
|
|
2013
|
+
* and in a signing intent: `'2'` for an explicit testnet, `'1'` otherwise.
|
|
2014
|
+
*
|
|
2015
|
+
* An omitted network is labelled mainnet, which matches the mainnet default
|
|
2016
|
+
* the signing clients already use for the PSBT itself.
|
|
2017
|
+
*
|
|
2018
|
+
* @param network - The Bitcoin network, if known
|
|
2019
|
+
* @returns `'2'` for testnet, `'1'` for mainnet or when no network is given
|
|
2020
|
+
*/ var getBtcChainId = function(network) {
|
|
2021
|
+
return network === 'testnet' ? '2' : '1';
|
|
2022
|
+
};
|
|
2023
|
+
|
|
1926
2024
|
/**
|
|
1927
2025
|
* Converts a string address type identifier to a BitcoinAddressType enum value.
|
|
1928
2026
|
* If the input is already a BitcoinAddressType enum, it is returned as-is.
|
|
@@ -1971,12 +2069,14 @@ exports.createSegWitAddress = createSegWitAddress;
|
|
|
1971
2069
|
exports.createTaprootAddress = createTaprootAddress;
|
|
1972
2070
|
exports.doesInputBelongToAddress = doesInputBelongToAddress;
|
|
1973
2071
|
exports.encodeBip322Signature = encodeBip322Signature;
|
|
2072
|
+
exports.extractPsbtIntentOperation = extractPsbtIntentOperation;
|
|
1974
2073
|
exports.extractPsbtSighashes = extractPsbtSighashes;
|
|
1975
2074
|
exports.extractPublicKeyHex = extractPublicKeyHex;
|
|
1976
2075
|
exports.filterInputsBySigningIndexes = filterInputsBySigningIndexes;
|
|
1977
2076
|
exports.getAddressTypeFromAddress = getAddressTypeFromAddress;
|
|
1978
2077
|
exports.getAddressTypeFromDerivationPath = getAddressTypeFromDerivationPath;
|
|
1979
2078
|
exports.getBitcoinNetwork = getBitcoinNetwork;
|
|
2079
|
+
exports.getBtcChainId = getBtcChainId;
|
|
1980
2080
|
exports.getDefaultRpcUrl = getDefaultRpcUrl;
|
|
1981
2081
|
exports.getFeeRates = getFeeRates;
|
|
1982
2082
|
exports.getPublicKeyFromPrivateKey = getPublicKeyFromPrivateKey;
|
package/index.esm.js
CHANGED
|
@@ -330,30 +330,30 @@ var convertObjectToBuffer = function(actualPubkey) {
|
|
|
330
330
|
throw new Error('Unable to determine Bitcoin address type');
|
|
331
331
|
};
|
|
332
332
|
|
|
333
|
-
function _array_like_to_array$
|
|
333
|
+
function _array_like_to_array$3(arr, len) {
|
|
334
334
|
if (len == null || len > arr.length) len = arr.length;
|
|
335
335
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
336
336
|
return arr2;
|
|
337
337
|
}
|
|
338
|
-
function _array_without_holes$
|
|
339
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
338
|
+
function _array_without_holes$3(arr) {
|
|
339
|
+
if (Array.isArray(arr)) return _array_like_to_array$3(arr);
|
|
340
340
|
}
|
|
341
|
-
function _iterable_to_array$
|
|
341
|
+
function _iterable_to_array$3(iter) {
|
|
342
342
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
343
343
|
}
|
|
344
|
-
function _non_iterable_spread$
|
|
344
|
+
function _non_iterable_spread$3() {
|
|
345
345
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
346
346
|
}
|
|
347
|
-
function _to_consumable_array$
|
|
348
|
-
return _array_without_holes$
|
|
347
|
+
function _to_consumable_array$3(arr) {
|
|
348
|
+
return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread$3();
|
|
349
349
|
}
|
|
350
|
-
function _unsupported_iterable_to_array$
|
|
350
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
351
351
|
if (!o) return;
|
|
352
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
352
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
353
353
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
354
354
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
355
355
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
356
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
356
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
357
357
|
}
|
|
358
358
|
var NULL_PREVOUT_HASH = new Uint8Array(32);
|
|
359
359
|
var NULL_PREVOUT_INDEX = 0xffffffff;
|
|
@@ -373,7 +373,7 @@ var OP_0_PUSH32 = [
|
|
|
373
373
|
var tx = new bitcoin.Transaction();
|
|
374
374
|
tx.version = 0;
|
|
375
375
|
tx.locktime = 0;
|
|
376
|
-
tx.addInput(NULL_PREVOUT_HASH, NULL_PREVOUT_INDEX, 0, new Uint8Array(_to_consumable_array$
|
|
376
|
+
tx.addInput(NULL_PREVOUT_HASH, NULL_PREVOUT_INDEX, 0, new Uint8Array(_to_consumable_array$3(OP_0_PUSH32).concat(_to_consumable_array$3(BIP322.hashMessage(message)))));
|
|
377
377
|
tx.addOutput(scriptPubKey, BigInt(0));
|
|
378
378
|
return tx;
|
|
379
379
|
};
|
|
@@ -1082,30 +1082,30 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1082
1082
|
};
|
|
1083
1083
|
}();
|
|
1084
1084
|
|
|
1085
|
-
function _array_like_to_array$
|
|
1085
|
+
function _array_like_to_array$2(arr, len) {
|
|
1086
1086
|
if (len == null || len > arr.length) len = arr.length;
|
|
1087
1087
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1088
1088
|
return arr2;
|
|
1089
1089
|
}
|
|
1090
|
-
function _array_without_holes$
|
|
1091
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
1090
|
+
function _array_without_holes$2(arr) {
|
|
1091
|
+
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
|
|
1092
1092
|
}
|
|
1093
|
-
function _iterable_to_array$
|
|
1093
|
+
function _iterable_to_array$2(iter) {
|
|
1094
1094
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1095
1095
|
}
|
|
1096
|
-
function _non_iterable_spread$
|
|
1096
|
+
function _non_iterable_spread$2() {
|
|
1097
1097
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1098
1098
|
}
|
|
1099
|
-
function _to_consumable_array$
|
|
1100
|
-
return _array_without_holes$
|
|
1099
|
+
function _to_consumable_array$2(arr) {
|
|
1100
|
+
return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$2();
|
|
1101
1101
|
}
|
|
1102
|
-
function _unsupported_iterable_to_array$
|
|
1102
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
1103
1103
|
if (!o) return;
|
|
1104
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
1104
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
1105
1105
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1106
1106
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1107
1107
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1108
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
1108
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
1109
1109
|
}
|
|
1110
1110
|
/**
|
|
1111
1111
|
* Simple greedy coin selection
|
|
@@ -1117,7 +1117,7 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
1117
1117
|
*/ var selectUTXOs = function(param) {
|
|
1118
1118
|
var utxos = param.utxos, amount = param.amount, feeRate = param.feeRate;
|
|
1119
1119
|
// Sort by value descending
|
|
1120
|
-
var sorted = _to_consumable_array$
|
|
1120
|
+
var sorted = _to_consumable_array$2(utxos).sort(function(a, b) {
|
|
1121
1121
|
return Number(b.value - a.value);
|
|
1122
1122
|
});
|
|
1123
1123
|
var inputs = [];
|
|
@@ -1163,13 +1163,13 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
1163
1163
|
throw new Error('Insufficient funds');
|
|
1164
1164
|
};
|
|
1165
1165
|
|
|
1166
|
-
function _array_like_to_array(arr, len) {
|
|
1166
|
+
function _array_like_to_array$1(arr, len) {
|
|
1167
1167
|
if (len == null || len > arr.length) len = arr.length;
|
|
1168
1168
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1169
1169
|
return arr2;
|
|
1170
1170
|
}
|
|
1171
|
-
function _array_without_holes(arr) {
|
|
1172
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1171
|
+
function _array_without_holes$1(arr) {
|
|
1172
|
+
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
|
|
1173
1173
|
}
|
|
1174
1174
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1175
1175
|
try {
|
|
@@ -1200,26 +1200,26 @@ function _async_to_generator(fn) {
|
|
|
1200
1200
|
});
|
|
1201
1201
|
};
|
|
1202
1202
|
}
|
|
1203
|
-
function _iterable_to_array(iter) {
|
|
1203
|
+
function _iterable_to_array$1(iter) {
|
|
1204
1204
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1205
1205
|
}
|
|
1206
|
-
function _non_iterable_spread() {
|
|
1206
|
+
function _non_iterable_spread$1() {
|
|
1207
1207
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1208
1208
|
}
|
|
1209
|
-
function _to_consumable_array(arr) {
|
|
1210
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1209
|
+
function _to_consumable_array$1(arr) {
|
|
1210
|
+
return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread$1();
|
|
1211
1211
|
}
|
|
1212
1212
|
function _type_of$1(obj) {
|
|
1213
1213
|
"@swc/helpers - typeof";
|
|
1214
1214
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1215
1215
|
}
|
|
1216
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1216
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
1217
1217
|
if (!o) return;
|
|
1218
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1218
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
1219
1219
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1220
1220
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1221
1221
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1222
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1222
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
1223
1223
|
}
|
|
1224
1224
|
function _ts_generator(thisArg, body) {
|
|
1225
1225
|
var f, y, t, g, _ = {
|
|
@@ -1340,7 +1340,7 @@ var pickEstimate = function(estimates, target) {
|
|
|
1340
1340
|
}
|
|
1341
1341
|
var _reverse_find;
|
|
1342
1342
|
// Closest target not exceeding the wanted one, else the fastest available.
|
|
1343
|
-
var key = (_reverse_find = _to_consumable_array(targets).reverse().find(function(candidate) {
|
|
1343
|
+
var key = (_reverse_find = _to_consumable_array$1(targets).reverse().find(function(candidate) {
|
|
1344
1344
|
return candidate <= target;
|
|
1345
1345
|
})) !== null && _reverse_find !== void 0 ? _reverse_find : targets[0];
|
|
1346
1346
|
return Math.ceil(assertFeeRate(estimates[String(key)]));
|
|
@@ -1903,6 +1903,104 @@ function _type_of(obj) {
|
|
|
1903
1903
|
return sighashes;
|
|
1904
1904
|
};
|
|
1905
1905
|
|
|
1906
|
+
function _array_like_to_array(arr, len) {
|
|
1907
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1908
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1909
|
+
return arr2;
|
|
1910
|
+
}
|
|
1911
|
+
function _array_without_holes(arr) {
|
|
1912
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1913
|
+
}
|
|
1914
|
+
function _iterable_to_array(iter) {
|
|
1915
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1916
|
+
}
|
|
1917
|
+
function _non_iterable_spread() {
|
|
1918
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1919
|
+
}
|
|
1920
|
+
function _to_consumable_array(arr) {
|
|
1921
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1922
|
+
}
|
|
1923
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
1924
|
+
if (!o) return;
|
|
1925
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1926
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1927
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1928
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1929
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1930
|
+
}
|
|
1931
|
+
/**
|
|
1932
|
+
* Describes a PSBT the way a BTC signing intent does: its txid, fee, outputs
|
|
1933
|
+
* and the sighashes of the inputs a wallet is about to sign.
|
|
1934
|
+
*
|
|
1935
|
+
* Every input must carry a `witnessUtxo`: the fee needs the value of every
|
|
1936
|
+
* input, and the txid of a segwit transaction does not change once its inputs
|
|
1937
|
+
* are signed. An input with only a `nonWitnessUtxo` is rejected.
|
|
1938
|
+
*
|
|
1939
|
+
* @param psbtBase64 - The PSBT in base64 format
|
|
1940
|
+
* @param network - The Bitcoin network the PSBT is for
|
|
1941
|
+
* @param inputIndexes - The PSBT input indexes the wallet signs
|
|
1942
|
+
* @returns The txid, fee, outputs and the sighashes of `inputIndexes`
|
|
1943
|
+
* @throws Error if an input lacks a `witnessUtxo`, the outputs exceed the inputs,
|
|
1944
|
+
* `inputIndexes` is empty or out of range, or a requested input has no derivable sighash
|
|
1945
|
+
*/ var extractPsbtIntentOperation = function(param) {
|
|
1946
|
+
var inputIndexes = param.inputIndexes, network = param.network, psbtBase64 = param.psbtBase64;
|
|
1947
|
+
var psbt = bitcoin.Psbt.fromBase64(psbtBase64, {
|
|
1948
|
+
network: getBitcoinNetwork(toBitcoinNetwork(network))
|
|
1949
|
+
});
|
|
1950
|
+
var values = collectPSBTInputData(psbt).values;
|
|
1951
|
+
var tx = psbt.__CACHE.__TX;
|
|
1952
|
+
var inputTotal = values.reduce(function(sum, value) {
|
|
1953
|
+
return sum + value;
|
|
1954
|
+
}, 0n);
|
|
1955
|
+
var outputTotal = tx.outs.reduce(function(sum, output) {
|
|
1956
|
+
return sum + output.value;
|
|
1957
|
+
}, 0n);
|
|
1958
|
+
if (outputTotal > inputTotal) {
|
|
1959
|
+
throw new Error('Transaction outputs exceed its inputs');
|
|
1960
|
+
}
|
|
1961
|
+
var requested = _to_consumable_array(new Set(inputIndexes)).sort(function(a, b) {
|
|
1962
|
+
return a - b;
|
|
1963
|
+
});
|
|
1964
|
+
if (requested.length === 0) {
|
|
1965
|
+
throw new Error('At least one input to sign is required');
|
|
1966
|
+
}
|
|
1967
|
+
var allSighashes = extractPsbtSighashes(psbtBase64, network);
|
|
1968
|
+
var sighashes = requested.map(function(index) {
|
|
1969
|
+
if (!Number.isInteger(index) || index < 0 || index >= allSighashes.length) {
|
|
1970
|
+
throw new Error("Input ".concat(index, " is not in the PSBT"));
|
|
1971
|
+
}
|
|
1972
|
+
var sighash = allSighashes[index];
|
|
1973
|
+
if (sighash === null) {
|
|
1974
|
+
throw new Error("Input ".concat(index, " has no derivable sighash"));
|
|
1975
|
+
}
|
|
1976
|
+
return sighash;
|
|
1977
|
+
});
|
|
1978
|
+
return {
|
|
1979
|
+
feeSats: (inputTotal - outputTotal).toString(),
|
|
1980
|
+
outputs: tx.outs.map(function(output) {
|
|
1981
|
+
return {
|
|
1982
|
+
script: Buffer.from(output.script).toString('hex'),
|
|
1983
|
+
valueSats: output.value.toString()
|
|
1984
|
+
};
|
|
1985
|
+
}),
|
|
1986
|
+
sighashes: sighashes,
|
|
1987
|
+
txid: tx.getId()
|
|
1988
|
+
};
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1991
|
+
/**
|
|
1992
|
+
* The `chainId` label that identifies a Bitcoin network to the policy layer
|
|
1993
|
+
* and in a signing intent: `'2'` for an explicit testnet, `'1'` otherwise.
|
|
1994
|
+
*
|
|
1995
|
+
* An omitted network is labelled mainnet, which matches the mainnet default
|
|
1996
|
+
* the signing clients already use for the PSBT itself.
|
|
1997
|
+
*
|
|
1998
|
+
* @param network - The Bitcoin network, if known
|
|
1999
|
+
* @returns `'2'` for testnet, `'1'` for mainnet or when no network is given
|
|
2000
|
+
*/ var getBtcChainId = function(network) {
|
|
2001
|
+
return network === 'testnet' ? '2' : '1';
|
|
2002
|
+
};
|
|
2003
|
+
|
|
1906
2004
|
/**
|
|
1907
2005
|
* Converts a string address type identifier to a BitcoinAddressType enum value.
|
|
1908
2006
|
* If the input is already a BitcoinAddressType enum, it is returned as-is.
|
|
@@ -1938,4 +2036,4 @@ function _type_of(obj) {
|
|
|
1938
2036
|
return Buffer.from(formattedMessage).toString('hex');
|
|
1939
2037
|
};
|
|
1940
2038
|
|
|
1941
|
-
export { assertSighashAllowed, calculateBip322Hash, calculateTaprootTweak, collectPSBTInputData, computeBip322HashHex, convertSignatureToDER, convertSignatureToTaprootBuffer, createLegacyAddress, createNativeSegWitAddress, createSegWitAddress, createTaprootAddress, doesInputBelongToAddress, encodeBip322Signature, extractPsbtSighashes, extractPublicKeyHex, filterInputsBySigningIndexes, getAddressTypeFromAddress, getAddressTypeFromDerivationPath, getBitcoinNetwork, getDefaultRpcUrl, getFeeRates, getPublicKeyFromPrivateKey, getSegwitV0ScriptCode, getSigHashType, getUTXOs, initEccLib, isP2wshOutputScript, normalizeForCompressed, normalizeForTaproot, normalizePublicKey, privateKeyToWIF, publicKeyToBitcoinAddress, resolveBitcoinAddressType, resolveRpcUrl, rpcFetch, selectUTXOs, toBitcoinNetwork, toBuffer, wifToPrivateKey };
|
|
2039
|
+
export { assertSighashAllowed, calculateBip322Hash, calculateTaprootTweak, collectPSBTInputData, computeBip322HashHex, convertSignatureToDER, convertSignatureToTaprootBuffer, createLegacyAddress, createNativeSegWitAddress, createSegWitAddress, createTaprootAddress, doesInputBelongToAddress, encodeBip322Signature, extractPsbtIntentOperation, extractPsbtSighashes, extractPublicKeyHex, filterInputsBySigningIndexes, getAddressTypeFromAddress, getAddressTypeFromDerivationPath, getBitcoinNetwork, getBtcChainId, getDefaultRpcUrl, getFeeRates, getPublicKeyFromPrivateKey, getSegwitV0ScriptCode, getSigHashType, getUTXOs, initEccLib, isP2wshOutputScript, normalizeForCompressed, normalizeForTaproot, normalizePublicKey, privateKeyToWIF, publicKeyToBitcoinAddress, resolveBitcoinAddressType, resolveRpcUrl, rpcFetch, selectUTXOs, toBitcoinNetwork, toBuffer, wifToPrivateKey };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/btc-utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.71",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@dynamic-labs-wallet/core": "1.1.
|
|
8
|
+
"@dynamic-labs-wallet/core": "1.1.71",
|
|
9
9
|
"bitcoinjs-lib": "^7.0.2",
|
|
10
10
|
"bip322-js": "4.0.0",
|
|
11
11
|
"@noble/hashes": "1.7.1",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { BitcoinNetwork } from '@dynamic-labs-wallet/core';
|
|
2
|
+
/** The transaction fields a signing intent commits to, as the intent encodes them. */
|
|
3
|
+
export type PsbtIntentOperation = {
|
|
4
|
+
/** The fee in satoshis: the sum of the inputs minus the sum of the outputs, as a decimal string. */
|
|
5
|
+
feeSats: string;
|
|
6
|
+
/** Every output of the transaction, in transaction order. */
|
|
7
|
+
outputs: {
|
|
8
|
+
script: string;
|
|
9
|
+
valueSats: string;
|
|
10
|
+
}[];
|
|
11
|
+
/** The signature hashes of the requested inputs, in ascending input order, as lowercase hex. */
|
|
12
|
+
sighashes: string[];
|
|
13
|
+
/** The transaction id, as lowercase hex. */
|
|
14
|
+
txid: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Describes a PSBT the way a BTC signing intent does: its txid, fee, outputs
|
|
18
|
+
* and the sighashes of the inputs a wallet is about to sign.
|
|
19
|
+
*
|
|
20
|
+
* Every input must carry a `witnessUtxo`: the fee needs the value of every
|
|
21
|
+
* input, and the txid of a segwit transaction does not change once its inputs
|
|
22
|
+
* are signed. An input with only a `nonWitnessUtxo` is rejected.
|
|
23
|
+
*
|
|
24
|
+
* @param psbtBase64 - The PSBT in base64 format
|
|
25
|
+
* @param network - The Bitcoin network the PSBT is for
|
|
26
|
+
* @param inputIndexes - The PSBT input indexes the wallet signs
|
|
27
|
+
* @returns The txid, fee, outputs and the sighashes of `inputIndexes`
|
|
28
|
+
* @throws Error if an input lacks a `witnessUtxo`, the outputs exceed the inputs,
|
|
29
|
+
* `inputIndexes` is empty or out of range, or a requested input has no derivable sighash
|
|
30
|
+
*/
|
|
31
|
+
export declare const extractPsbtIntentOperation: ({ inputIndexes, network, psbtBase64, }: {
|
|
32
|
+
inputIndexes: number[];
|
|
33
|
+
network: BitcoinNetwork | "mainnet" | "testnet";
|
|
34
|
+
psbtBase64: string;
|
|
35
|
+
}) => PsbtIntentOperation;
|
|
36
|
+
//# sourceMappingURL=extractPsbtIntentOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractPsbtIntentOperation.d.ts","sourceRoot":"","sources":["../../src/extractPsbtIntentOperation/extractPsbtIntentOperation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,sFAAsF;AACtF,MAAM,MAAM,mBAAmB,GAAG;IAChC,oGAAoG;IACpG,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjD,gGAAgG;IAChG,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,0BAA0B,2CAIpC;IACD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;CACpB,KAAG,mBA+CH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extractPsbtIntentOperation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BitcoinNetwork } from '@dynamic-labs-wallet/core';
|
|
2
|
+
/**
|
|
3
|
+
* The `chainId` label that identifies a Bitcoin network to the policy layer
|
|
4
|
+
* and in a signing intent: `'2'` for an explicit testnet, `'1'` otherwise.
|
|
5
|
+
*
|
|
6
|
+
* An omitted network is labelled mainnet, which matches the mainnet default
|
|
7
|
+
* the signing clients already use for the PSBT itself.
|
|
8
|
+
*
|
|
9
|
+
* @param network - The Bitcoin network, if known
|
|
10
|
+
* @returns `'2'` for testnet, `'1'` for mainnet or when no network is given
|
|
11
|
+
*/
|
|
12
|
+
export declare const getBtcChainId: (network?: BitcoinNetwork | "mainnet" | "testnet") => "1" | "2";
|
|
13
|
+
//# sourceMappingURL=getBtcChainId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBtcChainId.d.ts","sourceRoot":"","sources":["../../src/getBtcChainId/getBtcChainId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,aAAc,cAAc,GAAG,SAAS,GAAG,SAAS,KAAG,GAAG,GAAG,GACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/getBtcChainId/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
package/src/index.d.ts
CHANGED
|
@@ -36,5 +36,8 @@ export { normalizeForCompressed } from './normalizeForCompressed/index.js';
|
|
|
36
36
|
export { normalizeForTaproot } from './normalizeForTaproot/index.js';
|
|
37
37
|
export { toBitcoinNetwork } from './toBitcoinNetwork/index.js';
|
|
38
38
|
export { extractPsbtSighashes } from './extractPsbtSighashes/index.js';
|
|
39
|
+
export { extractPsbtIntentOperation } from './extractPsbtIntentOperation/index.js';
|
|
40
|
+
export type { PsbtIntentOperation } from './extractPsbtIntentOperation/index.js';
|
|
41
|
+
export { getBtcChainId } from './getBtcChainId/index.js';
|
|
39
42
|
export { computeBip322HashHex } from './computeBip322HashHex/index.js';
|
|
40
43
|
//# sourceMappingURL=index.d.ts.map
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC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