@argonprotocol/bitcoin 1.4.12-dev.9e9b31a9 → 1.4.12-dev.a0735a19
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/browser/index.d.ts +16 -15
- package/browser/index.js +57 -15
- package/browser/index.js.map +1 -1
- package/lib/{bitcoin_bindings_bg-G57R5LDM.wasm → bitcoin_bindings_bg-CMIKLQTW.wasm} +0 -0
- package/lib/index.d.ts +16 -15
- package/lib/index.js +57 -15
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
// wasm-module:/home/runner/work/mainchain/mainchain/bitcoin/nodejs/ts/wasm/bitcoin_bindings_bg.wasm
|
|
19
19
|
var bitcoin_bindings_bg_exports = {};
|
|
20
20
|
__export(bitcoin_bindings_bg_exports, {
|
|
21
|
+
__externref_table_alloc: () => __externref_table_alloc,
|
|
21
22
|
__externref_table_dealloc: () => __externref_table_dealloc,
|
|
22
23
|
__wbindgen_externrefs: () => __wbindgen_externrefs,
|
|
23
24
|
__wbindgen_free: () => __wbindgen_free,
|
|
@@ -39,7 +40,7 @@ __export(bitcoin_bindings_bg_exports, {
|
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
// wasm-deferred:/home/runner/work/mainchain/mainchain/bitcoin/nodejs/ts/wasm/bitcoin_bindings_bg.wasm
|
|
42
|
-
var bitcoin_bindings_bg_default = "./bitcoin_bindings_bg-
|
|
43
|
+
var bitcoin_bindings_bg_default = "./bitcoin_bindings_bg-CMIKLQTW.wasm";
|
|
43
44
|
|
|
44
45
|
// ts/wasm/bitcoin_bindings_bg.js
|
|
45
46
|
var BitcoinNetwork = Object.freeze({
|
|
@@ -64,7 +65,7 @@ var BitcoinNetwork = Object.freeze({
|
|
|
64
65
|
Regtest: 3,
|
|
65
66
|
"3": "Regtest"
|
|
66
67
|
});
|
|
67
|
-
function calculateFee(vault_pubkey_hex, vault_claim_pubkey_hex, owner_pubkey_hex, vault_claim_height, open_claim_height, created_at_height, bitcoin_network, fee_rate_sats_per_vb, to_script_pubkey) {
|
|
68
|
+
function calculateFee(vault_pubkey_hex, vault_claim_pubkey_hex, owner_pubkey_hex, vault_claim_height, open_claim_height, created_at_height, bitcoin_network, fee_rate_sats_per_vb, input_count, to_script_pubkey) {
|
|
68
69
|
const ptr0 = passStringToWasm0(vault_pubkey_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
69
70
|
const len0 = WASM_VECTOR_LEN;
|
|
70
71
|
const ptr1 = passStringToWasm0(vault_claim_pubkey_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -73,7 +74,7 @@ function calculateFee(vault_pubkey_hex, vault_claim_pubkey_hex, owner_pubkey_hex
|
|
|
73
74
|
const len2 = WASM_VECTOR_LEN;
|
|
74
75
|
const ptr3 = passStringToWasm0(to_script_pubkey, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
75
76
|
const len3 = WASM_VECTOR_LEN;
|
|
76
|
-
const ret = wasm.calculateFee(ptr0, len0, ptr1, len1, ptr2, len2, vault_claim_height, open_claim_height, created_at_height, bitcoin_network, fee_rate_sats_per_vb, ptr3, len3);
|
|
77
|
+
const ret = wasm.calculateFee(ptr0, len0, ptr1, len1, ptr2, len2, vault_claim_height, open_claim_height, created_at_height, bitcoin_network, fee_rate_sats_per_vb, input_count, ptr3, len3);
|
|
77
78
|
if (ret[2]) {
|
|
78
79
|
throw takeFromExternrefTable0(ret[1]);
|
|
79
80
|
}
|
|
@@ -104,11 +105,11 @@ function createCosignPubkey(vault_pubkey_hex, vault_claim_pubkey_hex, owner_pubk
|
|
|
104
105
|
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
function getCosignPsbt(
|
|
108
|
+
function getCosignPsbt(utxos, vault_pubkey_hex, vault_claim_pubkey_hex, owner_pubkey_hex, vault_claim_height, open_claim_height, created_at_height, bitcoin_network, to_script_pubkey_hex, bitcoin_network_fee) {
|
|
108
109
|
let deferred7_0;
|
|
109
110
|
let deferred7_1;
|
|
110
111
|
try {
|
|
111
|
-
const ptr0 =
|
|
112
|
+
const ptr0 = passArrayJsValueToWasm0(utxos, wasm.__wbindgen_malloc);
|
|
112
113
|
const len0 = WASM_VECTOR_LEN;
|
|
113
114
|
const ptr1 = passStringToWasm0(vault_pubkey_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
114
115
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -118,7 +119,7 @@ function getCosignPsbt(txid, vout, satoshis, vault_pubkey_hex, vault_claim_pubke
|
|
|
118
119
|
const len3 = WASM_VECTOR_LEN;
|
|
119
120
|
const ptr4 = passStringToWasm0(to_script_pubkey_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
120
121
|
const len4 = WASM_VECTOR_LEN;
|
|
121
|
-
const ret = wasm.getCosignPsbt(ptr0, len0,
|
|
122
|
+
const ret = wasm.getCosignPsbt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, vault_claim_height, open_claim_height, created_at_height, bitcoin_network, ptr4, len4, bitcoin_network_fee);
|
|
122
123
|
var ptr6 = ret[0];
|
|
123
124
|
var len6 = ret[1];
|
|
124
125
|
if (ret[3]) {
|
|
@@ -199,6 +200,10 @@ function __wbg_new_8a6f238a6ece86ea() {
|
|
|
199
200
|
const ret = new Error();
|
|
200
201
|
return ret;
|
|
201
202
|
}
|
|
203
|
+
function __wbg_satoshis_359c1a2982fe9d47(arg0) {
|
|
204
|
+
const ret = arg0.satoshis;
|
|
205
|
+
return ret;
|
|
206
|
+
}
|
|
202
207
|
function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
|
|
203
208
|
const ret = arg1.stack;
|
|
204
209
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -206,6 +211,17 @@ function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
|
|
|
206
211
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
207
212
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
208
213
|
}
|
|
214
|
+
function __wbg_txid_d8b43d7217475933(arg0, arg1) {
|
|
215
|
+
const ret = arg1.txid;
|
|
216
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
217
|
+
const len1 = WASM_VECTOR_LEN;
|
|
218
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
219
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
220
|
+
}
|
|
221
|
+
function __wbg_vout_fcbf9a76c2d9b520(arg0) {
|
|
222
|
+
const ret = arg0.vout;
|
|
223
|
+
return ret;
|
|
224
|
+
}
|
|
209
225
|
function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
210
226
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
211
227
|
return ret;
|
|
@@ -219,6 +235,11 @@ function __wbindgen_init_externref_table() {
|
|
|
219
235
|
table.set(offset + 2, true);
|
|
220
236
|
table.set(offset + 3, false);
|
|
221
237
|
}
|
|
238
|
+
function addToExternrefTable0(obj) {
|
|
239
|
+
const idx = wasm.__externref_table_alloc();
|
|
240
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
241
|
+
return idx;
|
|
242
|
+
}
|
|
222
243
|
var cachedDataViewMemory0 = null;
|
|
223
244
|
function getDataViewMemory0() {
|
|
224
245
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
@@ -237,6 +258,15 @@ function getUint8ArrayMemory0() {
|
|
|
237
258
|
}
|
|
238
259
|
return cachedUint8ArrayMemory0;
|
|
239
260
|
}
|
|
261
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
262
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
263
|
+
for (let i = 0; i < array.length; i++) {
|
|
264
|
+
const add = addToExternrefTable0(array[i]);
|
|
265
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
266
|
+
}
|
|
267
|
+
WASM_VECTOR_LEN = array.length;
|
|
268
|
+
return ptr;
|
|
269
|
+
}
|
|
240
270
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
241
271
|
if (realloc === void 0) {
|
|
242
272
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -305,6 +335,9 @@ function __wbg_set_wasm(val) {
|
|
|
305
335
|
// wasm-module:/home/runner/work/mainchain/mainchain/bitcoin/nodejs/ts/wasm/bitcoin_bindings_bg.wasm
|
|
306
336
|
var imports = {
|
|
307
337
|
["./bitcoin_bindings_bg.js"]: {
|
|
338
|
+
__wbg_txid_d8b43d7217475933,
|
|
339
|
+
__wbg_vout_fcbf9a76c2d9b520,
|
|
340
|
+
__wbg_satoshis_359c1a2982fe9d47,
|
|
308
341
|
__wbg_new_8a6f238a6ece86ea,
|
|
309
342
|
__wbg_stack_0ed75d68575b0f3c,
|
|
310
343
|
__wbg_error_7534b8e9a36f1ab4,
|
|
@@ -355,6 +388,7 @@ var __wbindgen_malloc = instance.exports.__wbindgen_malloc;
|
|
|
355
388
|
var __wbindgen_realloc = instance.exports.__wbindgen_realloc;
|
|
356
389
|
var __wbindgen_externrefs = instance.exports.__wbindgen_externrefs;
|
|
357
390
|
var __externref_table_dealloc = instance.exports.__externref_table_dealloc;
|
|
391
|
+
var __externref_table_alloc = instance.exports.__externref_table_alloc;
|
|
358
392
|
var __wbindgen_start = instance.exports.__wbindgen_start;
|
|
359
393
|
|
|
360
394
|
// ts/wasm/bitcoin_bindings.js
|
|
@@ -471,7 +505,7 @@ var CosignScript = class {
|
|
|
471
505
|
});
|
|
472
506
|
return tx.toPSBT(0);
|
|
473
507
|
}
|
|
474
|
-
calculateFee(feeRatePerSatVb, toScriptPubkey) {
|
|
508
|
+
calculateFee(feeRatePerSatVb, inputCount, toScriptPubkey) {
|
|
475
509
|
toScriptPubkey = addressBytesHex(toScriptPubkey, this.network);
|
|
476
510
|
const { lock, network } = this;
|
|
477
511
|
return calculateFee(
|
|
@@ -483,6 +517,7 @@ var CosignScript = class {
|
|
|
483
517
|
BigInt(lock.createdAtHeight),
|
|
484
518
|
network,
|
|
485
519
|
feeRatePerSatVb,
|
|
520
|
+
inputCount,
|
|
486
521
|
toScriptPubkey
|
|
487
522
|
);
|
|
488
523
|
}
|
|
@@ -500,12 +535,14 @@ var CosignScript = class {
|
|
|
500
535
|
}
|
|
501
536
|
getCosignPsbt(args) {
|
|
502
537
|
const { lock, network } = this;
|
|
503
|
-
const { releaseRequest,
|
|
538
|
+
const { releaseRequest, utxos } = args;
|
|
504
539
|
const toScriptPubkey = addressBytesHex(releaseRequest.toScriptPubkey, network);
|
|
505
540
|
const psbtStr = getCosignPsbt(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
541
|
+
utxos.map((x) => ({
|
|
542
|
+
txid: x.utxoRef.txid,
|
|
543
|
+
vout: x.utxoRef.vout,
|
|
544
|
+
satoshis: x.satoshis
|
|
545
|
+
})),
|
|
509
546
|
lock.vaultPubkey,
|
|
510
547
|
lock.vaultClaimPubkey,
|
|
511
548
|
lock.ownerPubkey,
|
|
@@ -572,10 +609,15 @@ var CosignScript = class {
|
|
|
572
609
|
cosignAndGenerateTx(args) {
|
|
573
610
|
const { lock } = this;
|
|
574
611
|
const psbt = this.getCosignPsbt(args);
|
|
575
|
-
const { addTx,
|
|
576
|
-
psbt.
|
|
577
|
-
|
|
578
|
-
}
|
|
612
|
+
const { addTx, vaultCosignatures, ownerXpriv, ownerXprivChildHdPath } = args;
|
|
613
|
+
if (vaultCosignatures.length !== psbt.inputsLength) {
|
|
614
|
+
throw new Error("Vault signature count does not match the Bitcoin lock input count");
|
|
615
|
+
}
|
|
616
|
+
for (let i = 0; i < vaultCosignatures.length; i++) {
|
|
617
|
+
psbt.updateInput(i, {
|
|
618
|
+
partialSig: [[keyToU8a(lock.vaultPubkey), vaultCosignatures[i]]]
|
|
619
|
+
});
|
|
620
|
+
}
|
|
579
621
|
const derivePubkey = ownerXprivChildHdPath ? ownerXpriv.derive(ownerXprivChildHdPath).publicKey : ownerXpriv.publicKey;
|
|
580
622
|
if (!derivePubkey) {
|
|
581
623
|
throw new Error("Failed to derive owner public key");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argonprotocol/bitcoin",
|
|
3
|
-
"version": "1.4.12-dev.
|
|
3
|
+
"version": "1.4.12-dev.a0735a19",
|
|
4
4
|
"description": "A client for interop with bitcoin in nodejs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"./browser/index.js"
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@argonprotocol/mainchain": "1.4.12-dev.
|
|
54
|
+
"@argonprotocol/mainchain": "1.4.12-dev.a0735a19",
|
|
55
55
|
"@noble/secp256k1": "^2.3.0",
|
|
56
56
|
"@scure/bip32": "^1.7.0",
|
|
57
57
|
"@scure/bip39": "^1.6.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"bs58check": "^4.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@argonprotocol/testing": "1.4.12-dev.
|
|
63
|
+
"@argonprotocol/testing": "1.4.12-dev.a0735a19",
|
|
64
64
|
"@types/node": "22.17.1",
|
|
65
65
|
"esbuild-plugin-wasm": "^1.1.0",
|
|
66
66
|
"tsup": "^8.5.0",
|