@gardenfi/core 0.2.0-beta.75 → 0.2.0-beta.77
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 +31 -1
- package/dist/index.js +7813 -28
- package/package.json +1 -1
- package/dist/index10.cjs +0 -1
- package/dist/index10.js +0 -112
- package/dist/index100.cjs +0 -1
- package/dist/index100.js +0 -23
- package/dist/index101.cjs +0 -1
- package/dist/index101.js +0 -9
- package/dist/index102.cjs +0 -1
- package/dist/index102.js +0 -35
- package/dist/index103.cjs +0 -1
- package/dist/index103.js +0 -4
- package/dist/index104.cjs +0 -1
- package/dist/index104.js +0 -40
- package/dist/index105.cjs +0 -1
- package/dist/index105.js +0 -31
- package/dist/index106.cjs +0 -1
- package/dist/index106.js +0 -9
- package/dist/index107.cjs +0 -1
- package/dist/index107.js +0 -7
- package/dist/index108.cjs +0 -1
- package/dist/index108.js +0 -13
- package/dist/index109.cjs +0 -1
- package/dist/index109.js +0 -4
- package/dist/index11.cjs +0 -20
- package/dist/index11.js +0 -380
- package/dist/index110.cjs +0 -1
- package/dist/index110.js +0 -60
- package/dist/index111.cjs +0 -1
- package/dist/index111.js +0 -4
- package/dist/index112.cjs +0 -1
- package/dist/index112.js +0 -42
- package/dist/index113.cjs +0 -1
- package/dist/index113.js +0 -45
- package/dist/index114.cjs +0 -1
- package/dist/index114.js +0 -20
- package/dist/index115.cjs +0 -1
- package/dist/index115.js +0 -111
- package/dist/index116.cjs +0 -1
- package/dist/index116.js +0 -23
- package/dist/index117.cjs +0 -1
- package/dist/index117.js +0 -228
- package/dist/index118.cjs +0 -1
- package/dist/index118.js +0 -6
- package/dist/index119.cjs +0 -1
- package/dist/index119.js +0 -160
- package/dist/index12.cjs +0 -1
- package/dist/index12.js +0 -22
- package/dist/index120.cjs +0 -1
- package/dist/index120.js +0 -4
- package/dist/index121.cjs +0 -1
- package/dist/index121.js +0 -75
- package/dist/index122.cjs +0 -1
- package/dist/index122.js +0 -64
- package/dist/index123.cjs +0 -1
- package/dist/index123.js +0 -37
- package/dist/index124.cjs +0 -1
- package/dist/index124.js +0 -7
- package/dist/index125.cjs +0 -1
- package/dist/index125.js +0 -107
- package/dist/index126.cjs +0 -1
- package/dist/index126.js +0 -15
- package/dist/index127.cjs +0 -1
- package/dist/index127.js +0 -35
- package/dist/index128.cjs +0 -1
- package/dist/index128.js +0 -4
- package/dist/index129.cjs +0 -1
- package/dist/index129.js +0 -32
- package/dist/index13.cjs +0 -1
- package/dist/index13.js +0 -396
- package/dist/index130.cjs +0 -1
- package/dist/index130.js +0 -4
- package/dist/index131.cjs +0 -1
- package/dist/index131.js +0 -358
- package/dist/index132.cjs +0 -1
- package/dist/index132.js +0 -241
- package/dist/index133.cjs +0 -1
- package/dist/index133.js +0 -70
- package/dist/index134.cjs +0 -1
- package/dist/index134.js +0 -64
- package/dist/index135.cjs +0 -1
- package/dist/index135.js +0 -14
- package/dist/index136.cjs +0 -1
- package/dist/index136.js +0 -47
- package/dist/index137.cjs +0 -1
- package/dist/index137.js +0 -65
- package/dist/index138.cjs +0 -1
- package/dist/index138.js +0 -21
- package/dist/index139.cjs +0 -1
- package/dist/index139.js +0 -228
- package/dist/index14.cjs +0 -1
- package/dist/index14.js +0 -28
- package/dist/index140.cjs +0 -1
- package/dist/index140.js +0 -5
- package/dist/index141.cjs +0 -1
- package/dist/index141.js +0 -171
- package/dist/index142.cjs +0 -1
- package/dist/index142.js +0 -30
- package/dist/index143.cjs +0 -1
- package/dist/index143.js +0 -23
- package/dist/index144.cjs +0 -1
- package/dist/index144.js +0 -72
- package/dist/index145.cjs +0 -1
- package/dist/index145.js +0 -130
- package/dist/index146.cjs +0 -1
- package/dist/index146.js +0 -9
- package/dist/index147.cjs +0 -1
- package/dist/index147.js +0 -4
- package/dist/index148.cjs +0 -1
- package/dist/index148.js +0 -28
- package/dist/index149.cjs +0 -1
- package/dist/index149.js +0 -4
- package/dist/index15.cjs +0 -1
- package/dist/index15.js +0 -34
- package/dist/index16.cjs +0 -1
- package/dist/index16.js +0 -27
- package/dist/index17.cjs +0 -1
- package/dist/index17.js +0 -33
- package/dist/index18.cjs +0 -1
- package/dist/index18.js +0 -32
- package/dist/index19.cjs +0 -1
- package/dist/index19.js +0 -55
- package/dist/index2.cjs +0 -1
- package/dist/index2.js +0 -412
- package/dist/index20.cjs +0 -1
- package/dist/index20.js +0 -28
- package/dist/index21.cjs +0 -1
- package/dist/index21.js +0 -4
- package/dist/index22.cjs +0 -1
- package/dist/index22.js +0 -140
- package/dist/index23.cjs +0 -1
- package/dist/index23.js +0 -4
- package/dist/index24.cjs +0 -1
- package/dist/index24.js +0 -11
- package/dist/index25.cjs +0 -1
- package/dist/index25.js +0 -11
- package/dist/index26.cjs +0 -3
- package/dist/index26.js +0 -30
- package/dist/index27.cjs +0 -1
- package/dist/index27.js +0 -17
- package/dist/index28.cjs +0 -2
- package/dist/index28.js +0 -27
- package/dist/index29.cjs +0 -1
- package/dist/index29.js +0 -43
- package/dist/index3.cjs +0 -1
- package/dist/index3.js +0 -5
- package/dist/index30.cjs +0 -1
- package/dist/index30.js +0 -201
- package/dist/index31.cjs +0 -1
- package/dist/index31.js +0 -4
- package/dist/index32.cjs +0 -1
- package/dist/index32.js +0 -4
- package/dist/index33.cjs +0 -1
- package/dist/index33.js +0 -4
- package/dist/index34.cjs +0 -1
- package/dist/index34.js +0 -15
- package/dist/index35.cjs +0 -1
- package/dist/index35.js +0 -39
- package/dist/index36.cjs +0 -1
- package/dist/index36.js +0 -44
- package/dist/index37.cjs +0 -1
- package/dist/index37.js +0 -30
- package/dist/index38.cjs +0 -1
- package/dist/index38.js +0 -17
- package/dist/index39.cjs +0 -1
- package/dist/index39.js +0 -26
- package/dist/index4.cjs +0 -1
- package/dist/index4.js +0 -18
- package/dist/index40.cjs +0 -1
- package/dist/index40.js +0 -28
- package/dist/index41.cjs +0 -1
- package/dist/index41.js +0 -57
- package/dist/index42.cjs +0 -1
- package/dist/index42.js +0 -30
- package/dist/index43.cjs +0 -1
- package/dist/index43.js +0 -177
- package/dist/index44.cjs +0 -1
- package/dist/index44.js +0 -4
- package/dist/index45.cjs +0 -1
- package/dist/index45.js +0 -37
- package/dist/index46.cjs +0 -1
- package/dist/index46.js +0 -11
- package/dist/index47.cjs +0 -1
- package/dist/index47.js +0 -15
- package/dist/index48.cjs +0 -1
- package/dist/index48.js +0 -14
- package/dist/index49.cjs +0 -1
- package/dist/index49.js +0 -6
- package/dist/index5.cjs +0 -1
- package/dist/index5.js +0 -99
- package/dist/index50.cjs +0 -1
- package/dist/index50.js +0 -48
- package/dist/index51.cjs +0 -1
- package/dist/index51.js +0 -45
- package/dist/index52.cjs +0 -1
- package/dist/index52.js +0 -174
- package/dist/index53.cjs +0 -1
- package/dist/index53.js +0 -15
- package/dist/index54.cjs +0 -1
- package/dist/index54.js +0 -7
- package/dist/index55.cjs +0 -1
- package/dist/index55.js +0 -19
- package/dist/index56.cjs +0 -1
- package/dist/index56.js +0 -14
- package/dist/index57.cjs +0 -1
- package/dist/index57.js +0 -22
- package/dist/index58.cjs +0 -1
- package/dist/index58.js +0 -34
- package/dist/index59.cjs +0 -1
- package/dist/index59.js +0 -4
- package/dist/index6.cjs +0 -1
- package/dist/index6.js +0 -5
- package/dist/index60.cjs +0 -6
- package/dist/index60.js +0 -949
- package/dist/index61.cjs +0 -1
- package/dist/index61.js +0 -4
- package/dist/index62.cjs +0 -1
- package/dist/index62.js +0 -64
- package/dist/index63.cjs +0 -1
- package/dist/index63.js +0 -35
- package/dist/index64.cjs +0 -1
- package/dist/index64.js +0 -89
- package/dist/index65.cjs +0 -1
- package/dist/index65.js +0 -58
- package/dist/index66.cjs +0 -2
- package/dist/index66.js +0 -62
- package/dist/index67.cjs +0 -1
- package/dist/index67.js +0 -6
- package/dist/index68.cjs +0 -1
- package/dist/index68.js +0 -37
- package/dist/index69.cjs +0 -1
- package/dist/index69.js +0 -130
- package/dist/index7.cjs +0 -1
- package/dist/index7.js +0 -76
- package/dist/index70.cjs +0 -2
- package/dist/index70.js +0 -45
- package/dist/index71.cjs +0 -1
- package/dist/index71.js +0 -11
- package/dist/index72.cjs +0 -1
- package/dist/index72.js +0 -13
- package/dist/index73.cjs +0 -1
- package/dist/index73.js +0 -14
- package/dist/index74.cjs +0 -1
- package/dist/index74.js +0 -16
- package/dist/index75.cjs +0 -1
- package/dist/index75.js +0 -9
- package/dist/index76.cjs +0 -1
- package/dist/index76.js +0 -20
- package/dist/index77.cjs +0 -1
- package/dist/index77.js +0 -81
- package/dist/index78.cjs +0 -1
- package/dist/index78.js +0 -17
- package/dist/index79.cjs +0 -1
- package/dist/index79.js +0 -21
- package/dist/index8.cjs +0 -1
- package/dist/index8.js +0 -61
- package/dist/index80.cjs +0 -1
- package/dist/index80.js +0 -24
- package/dist/index81.cjs +0 -1
- package/dist/index81.js +0 -16
- package/dist/index82.cjs +0 -1
- package/dist/index82.js +0 -9
- package/dist/index83.cjs +0 -1
- package/dist/index83.js +0 -4
- package/dist/index84.cjs +0 -1
- package/dist/index84.js +0 -4
- package/dist/index85.cjs +0 -2
- package/dist/index85.js +0 -37
- package/dist/index86.cjs +0 -1
- package/dist/index86.js +0 -8
- package/dist/index87.cjs +0 -1
- package/dist/index87.js +0 -22
- package/dist/index88.cjs +0 -1
- package/dist/index88.js +0 -37
- package/dist/index89.cjs +0 -1
- package/dist/index89.js +0 -369
- package/dist/index9.cjs +0 -1
- package/dist/index9.js +0 -63
- package/dist/index90.cjs +0 -1
- package/dist/index90.js +0 -23
- package/dist/index91.cjs +0 -1
- package/dist/index91.js +0 -58
- package/dist/index92.cjs +0 -1
- package/dist/index92.js +0 -5
- package/dist/index93.cjs +0 -1
- package/dist/index93.js +0 -51
- package/dist/index94.cjs +0 -1
- package/dist/index94.js +0 -28
- package/dist/index95.cjs +0 -1
- package/dist/index95.js +0 -4
- package/dist/index96.cjs +0 -1
- package/dist/index96.js +0 -4
- package/dist/index97.cjs +0 -1
- package/dist/index97.js +0 -15
- package/dist/index98.cjs +0 -1
- package/dist/index98.js +0 -9
- package/dist/index99.cjs +0 -1
- package/dist/index99.js +0 -115
package/dist/index11.js
DELETED
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
import { Urgency as y } from "@catalogfi/wallets";
|
|
2
|
-
import * as h from "bitcoinjs-lib";
|
|
3
|
-
import * as k from "tiny-secp256k1";
|
|
4
|
-
import { generateInternalkey as b } from "./index37.js";
|
|
5
|
-
import { assert as g, xOnlyPubkey as L, serializeScript as P, sortLeaves as O } from "./index10.js";
|
|
6
|
-
import { htlcErrors as u } from "./index38.js";
|
|
7
|
-
const m = 192;
|
|
8
|
-
h.initEccLib(k);
|
|
9
|
-
class H {
|
|
10
|
-
/**
|
|
11
|
-
* Note: redeemerAddress and initiatorAddress should be x-only public key without 02 or 03 prefix
|
|
12
|
-
*/
|
|
13
|
-
constructor(e, r, t, s, i, a, d, o) {
|
|
14
|
-
this.secretHash = t, this.redeemerPubkey = s, this.initiatorPubkey = i, this.expiry = a, this.signer = e, this.network = d, this.internalPubkey = b(), this.initiateAmount = r, this.utxoHashes = o;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Creates a GardenHTLC instance
|
|
18
|
-
* @param signer Bitcoin wallet of the initiator or redeemer
|
|
19
|
-
* @param secretHash 32 bytes secret hash
|
|
20
|
-
* @param initiatorPubkey initiator's x-only public key without 02 or 03 prefix
|
|
21
|
-
* @param redeemerPubkey redeemer's x-only public key without 02 or 03 prefix
|
|
22
|
-
* @param expiry block height after which the funds can be refunded
|
|
23
|
-
* @returns GardenHTLC instance
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Note: When the signer is the initiator, only refund and instant refund can be done
|
|
27
|
-
* When the signer is the redeemer, only redeem can be done
|
|
28
|
-
*/
|
|
29
|
-
static async from(e, r, t, s, i, a, d) {
|
|
30
|
-
t = t.startsWith("0x") ? t.slice(2) : t, g(t.length === 64, u.secretHashLenMismatch), g(
|
|
31
|
-
s.length === 64 || s.length === 66,
|
|
32
|
-
`initiator ${u.pubkeyLenMismatch}`
|
|
33
|
-
), g(
|
|
34
|
-
i.length === 64 || i.length === 66,
|
|
35
|
-
`redeemer ${u.pubkeyLenMismatch}`
|
|
36
|
-
), g(a > 0, u.zeroOrNegativeExpiry);
|
|
37
|
-
const o = await e.getNetwork();
|
|
38
|
-
return new H(
|
|
39
|
-
e,
|
|
40
|
-
r,
|
|
41
|
-
t,
|
|
42
|
-
L(i).toString("hex"),
|
|
43
|
-
L(s).toString("hex"),
|
|
44
|
-
a,
|
|
45
|
-
o,
|
|
46
|
-
d
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Generates a taproot address for receiving the funds
|
|
51
|
-
*/
|
|
52
|
-
address() {
|
|
53
|
-
const { address: e } = h.payments.p2tr({
|
|
54
|
-
internalPubkey: this.internalPubkey,
|
|
55
|
-
network: this.network,
|
|
56
|
-
scriptTree: this.leaves()
|
|
57
|
-
});
|
|
58
|
-
if (!e) throw new Error(u.htlcAddressGenerationFailed);
|
|
59
|
-
return e;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* returns the address of the HTLC
|
|
63
|
-
*/
|
|
64
|
-
id() {
|
|
65
|
-
return this.address();
|
|
66
|
-
}
|
|
67
|
-
async _buildRawTx(e, r) {
|
|
68
|
-
const t = new h.Transaction();
|
|
69
|
-
t.version = 2;
|
|
70
|
-
const s = this.address(), i = await this.signer.getProvider();
|
|
71
|
-
let a = [];
|
|
72
|
-
if (this.utxoHashes && this.utxoHashes.length > 0)
|
|
73
|
-
for (const o of this.utxoHashes) {
|
|
74
|
-
const f = await i.getTransaction(o);
|
|
75
|
-
for (let l = 0; l < f.vout.length; l++) {
|
|
76
|
-
const n = f.vout[l];
|
|
77
|
-
n.scriptpubkey_address === s && a.push({
|
|
78
|
-
txid: f.txid,
|
|
79
|
-
vout: l,
|
|
80
|
-
value: n.value,
|
|
81
|
-
status: { confirmed: !1 }
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else
|
|
86
|
-
a = await i.getUTXOs(s);
|
|
87
|
-
const d = a.reduce((o, f) => o + f.value, 0);
|
|
88
|
-
if (d === 0) throw new Error(`${s} ${u.notFunded}`);
|
|
89
|
-
for (let o = 0; o < a.length; o++)
|
|
90
|
-
t.addInput(Buffer.from(a[o].txid, "hex").reverse(), a[o].vout);
|
|
91
|
-
return r ?? (r = await i.suggestFee(s, d, y.MEDIUM)), t.addOutput(
|
|
92
|
-
h.address.toOutputScript(e, this.network),
|
|
93
|
-
d - r
|
|
94
|
-
), { tx: t, usedUtxos: a };
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Builds a raw unsigned transaction with utxos from gardenHTLC address
|
|
98
|
-
* and uses signer's address as the output address
|
|
99
|
-
*/
|
|
100
|
-
async buildRawTx(e) {
|
|
101
|
-
return await this._buildRawTx(await this.signer.getAddress(), e);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* prevout script for the gardenHTLC address
|
|
105
|
-
*/
|
|
106
|
-
getOutputScript() {
|
|
107
|
-
return h.address.toOutputScript(this.address(), this.network);
|
|
108
|
-
}
|
|
109
|
-
async init(e) {
|
|
110
|
-
return e ?? (e = await (await this.signer.getProvider()).suggestFee(
|
|
111
|
-
await this.signer.getAddress(),
|
|
112
|
-
this.initiateAmount,
|
|
113
|
-
y.MEDIUM
|
|
114
|
-
)), await this.signer.send(this.address(), this.initiateAmount, e);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Instantly refunds the funds to the initiator given the counterparty's signatures and pubkey
|
|
118
|
-
*
|
|
119
|
-
* Note: If there are multiple UTXOs being spend, there should be a signature for each UTXO in counterPartySigs
|
|
120
|
-
*/
|
|
121
|
-
async instantRefund(e, r) {
|
|
122
|
-
g(e.length > 0, u.noCounterpartySigs);
|
|
123
|
-
const { tx: t, usedUtxos: s } = await this.buildRawTx(r);
|
|
124
|
-
for (const n of s)
|
|
125
|
-
if (!e.find((c) => c.utxo === n.txid))
|
|
126
|
-
throw new Error(u.counterPartySigNotFound(n.txid));
|
|
127
|
-
const i = this.getOutputScript(), a = h.Transaction.SIGHASH_DEFAULT, d = this.leafHash(
|
|
128
|
-
2
|
|
129
|
-
/* INSTANT_REFUND */
|
|
130
|
-
), o = s.map((n) => n.value), f = x(i, s.length);
|
|
131
|
-
for (let n = 0; n < t.ins.length; n++) {
|
|
132
|
-
const c = t.hashForWitnessV1(
|
|
133
|
-
n,
|
|
134
|
-
f,
|
|
135
|
-
o,
|
|
136
|
-
a,
|
|
137
|
-
d
|
|
138
|
-
);
|
|
139
|
-
if (!k.verifySchnorr(
|
|
140
|
-
c,
|
|
141
|
-
Buffer.from(this.redeemerPubkey, "hex"),
|
|
142
|
-
Buffer.from(e[n].sig, "hex")
|
|
143
|
-
))
|
|
144
|
-
throw new Error(
|
|
145
|
-
u.invalidCounterpartySigForUTXO(e[n].utxo)
|
|
146
|
-
);
|
|
147
|
-
const p = await this.signer.signSchnorr(c), w = Buffer.from(t.ins[n].hash).reverse().toString("hex"), v = e.find((E) => E.utxo === w);
|
|
148
|
-
if (!v)
|
|
149
|
-
throw new Error(u.counterPartySigNotFound(w));
|
|
150
|
-
t.setWitness(n, [
|
|
151
|
-
Buffer.from(v.sig, "hex"),
|
|
152
|
-
p,
|
|
153
|
-
this.instantRefundLeaf(),
|
|
154
|
-
this.generateControlBlockFor(
|
|
155
|
-
2
|
|
156
|
-
/* INSTANT_REFUND */
|
|
157
|
-
)
|
|
158
|
-
]);
|
|
159
|
-
}
|
|
160
|
-
return await (await this.signer.getProvider()).broadcast(t.toHex());
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Reveals the secret and redeems the HTLC
|
|
164
|
-
*/
|
|
165
|
-
async redeem(e, r, t) {
|
|
166
|
-
g(
|
|
167
|
-
h.crypto.sha256(Buffer.from(e, "hex")).toString("hex") === this.secretHash,
|
|
168
|
-
u.secretMismatch
|
|
169
|
-
);
|
|
170
|
-
const { tx: s, usedUtxos: i } = await this._buildRawTx(
|
|
171
|
-
r ?? await this.signer.getAddress(),
|
|
172
|
-
t
|
|
173
|
-
), a = this.leafHash(
|
|
174
|
-
1
|
|
175
|
-
/* REDEEM */
|
|
176
|
-
), d = i.map((n) => n.value), o = x(this.getOutputScript(), i.length), f = h.Transaction.SIGHASH_DEFAULT;
|
|
177
|
-
for (let n = 0; n < s.ins.length; n++) {
|
|
178
|
-
const c = s.hashForWitnessV1(
|
|
179
|
-
n,
|
|
180
|
-
o,
|
|
181
|
-
d,
|
|
182
|
-
f,
|
|
183
|
-
a
|
|
184
|
-
), p = await this.signer.signSchnorr(c);
|
|
185
|
-
s.setWitness(n, [
|
|
186
|
-
p,
|
|
187
|
-
Buffer.from(e, "hex"),
|
|
188
|
-
this.redeemLeaf(),
|
|
189
|
-
this.generateControlBlockFor(
|
|
190
|
-
1
|
|
191
|
-
/* REDEEM */
|
|
192
|
-
)
|
|
193
|
-
]);
|
|
194
|
-
}
|
|
195
|
-
return await (await this.signer.getProvider()).broadcast(s.toHex());
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Refunds the funds back to the initiator if the expiry block height + 1 is reached
|
|
199
|
-
*/
|
|
200
|
-
async refund(e, r) {
|
|
201
|
-
const { tx: t, usedUtxos: s } = await this._buildRawTx(
|
|
202
|
-
e ?? await this.signer.getAddress(),
|
|
203
|
-
r
|
|
204
|
-
), [i, a] = await this.canRefund(s);
|
|
205
|
-
if (!i)
|
|
206
|
-
throw new Error(u.htlcNotExpired(a));
|
|
207
|
-
const d = this.leafHash(
|
|
208
|
-
0
|
|
209
|
-
/* REFUND */
|
|
210
|
-
), o = s.map((c) => c.value), f = x(this.getOutputScript(), s.length), l = h.Transaction.SIGHASH_DEFAULT;
|
|
211
|
-
for (let c = 0; c < t.ins.length; c++) {
|
|
212
|
-
t.ins[c].sequence = this.expiry;
|
|
213
|
-
const p = t.hashForWitnessV1(
|
|
214
|
-
c,
|
|
215
|
-
f,
|
|
216
|
-
o,
|
|
217
|
-
l,
|
|
218
|
-
d
|
|
219
|
-
), w = await this.signer.signSchnorr(p);
|
|
220
|
-
t.setWitness(c, [
|
|
221
|
-
w,
|
|
222
|
-
this.refundLeaf(),
|
|
223
|
-
this.generateControlBlockFor(
|
|
224
|
-
0
|
|
225
|
-
/* REFUND */
|
|
226
|
-
)
|
|
227
|
-
]);
|
|
228
|
-
}
|
|
229
|
-
return await (await this.signer.getProvider()).broadcast(t.toHex());
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Given a list of UTXOs, checks if the HTLC can be refunded
|
|
233
|
-
*/
|
|
234
|
-
async canRefund(e) {
|
|
235
|
-
const t = await (await this.signer.getProvider()).getLatestTip();
|
|
236
|
-
for (const s of e) {
|
|
237
|
-
let i = 0;
|
|
238
|
-
if (s.status.confirmed && s.status.block_height + this.expiry > t ? i = s.status.block_height + this.expiry - t + 1 : s.status.confirmed || (i = this.expiry + 1), i > 0)
|
|
239
|
-
return [!1, i];
|
|
240
|
-
}
|
|
241
|
-
return [!0, 0];
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Given a leaf, generates the control block necessary for spending the leaf
|
|
245
|
-
*/
|
|
246
|
-
generateControlBlockFor(e) {
|
|
247
|
-
let r;
|
|
248
|
-
switch (e) {
|
|
249
|
-
case 1:
|
|
250
|
-
r = this.redeemLeaf();
|
|
251
|
-
break;
|
|
252
|
-
case 0:
|
|
253
|
-
r = this.refundLeaf();
|
|
254
|
-
break;
|
|
255
|
-
case 2:
|
|
256
|
-
r = this.instantRefundLeaf();
|
|
257
|
-
break;
|
|
258
|
-
default:
|
|
259
|
-
throw new Error(u.invalidLeaf);
|
|
260
|
-
}
|
|
261
|
-
const t = h.payments.p2tr({
|
|
262
|
-
internalPubkey: this.internalPubkey,
|
|
263
|
-
network: this.network,
|
|
264
|
-
scriptTree: this.leaves(),
|
|
265
|
-
redeem: {
|
|
266
|
-
output: r,
|
|
267
|
-
redeemVersion: m
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
if (!t.witness)
|
|
271
|
-
throw new Error(u.controlBlockGenerationFailed);
|
|
272
|
-
return t.witness[t.witness.length - 1];
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Generates the hash of the leaf script
|
|
276
|
-
* @param leaf Use leaf enum or pass 0 for refund, 1 for redeem, 2 for instant refund
|
|
277
|
-
* @returns hash of the leaf script
|
|
278
|
-
*/
|
|
279
|
-
leafHash(e) {
|
|
280
|
-
let r = this.redeemLeaf();
|
|
281
|
-
return e === 0 && (r = this.refundLeaf()), e === 2 && (r = this.instantRefundLeaf()), h.crypto.taggedHash("TapLeaf", P(r));
|
|
282
|
-
}
|
|
283
|
-
refundLeaf() {
|
|
284
|
-
return h.script.fromASM(
|
|
285
|
-
`
|
|
286
|
-
${h.script.number.encode(this.expiry).toString("hex")}
|
|
287
|
-
OP_CHECKSEQUENCEVERIFY
|
|
288
|
-
OP_DROP
|
|
289
|
-
${this.initiatorPubkey}
|
|
290
|
-
OP_CHECKSIG
|
|
291
|
-
`.trim().replace(/\s+/g, " ")
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
redeemLeaf() {
|
|
295
|
-
return h.script.fromASM(
|
|
296
|
-
`
|
|
297
|
-
OP_SHA256
|
|
298
|
-
${this.secretHash}
|
|
299
|
-
OP_EQUALVERIFY
|
|
300
|
-
${this.redeemerPubkey}
|
|
301
|
-
OP_CHECKSIG
|
|
302
|
-
`.trim().replace(/\s+/g, " ")
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
instantRefundLeaf() {
|
|
306
|
-
return h.script.fromASM(
|
|
307
|
-
`
|
|
308
|
-
${this.initiatorPubkey}
|
|
309
|
-
OP_CHECKSIG
|
|
310
|
-
${this.redeemerPubkey}
|
|
311
|
-
OP_CHECKSIGADD
|
|
312
|
-
OP_2
|
|
313
|
-
OP_NUMEQUAL
|
|
314
|
-
`.trim().replace(/\s+/g, " ")
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
leaves() {
|
|
318
|
-
return [
|
|
319
|
-
// most probable leaf (redeem)
|
|
320
|
-
{
|
|
321
|
-
version: m,
|
|
322
|
-
output: this.redeemLeaf()
|
|
323
|
-
},
|
|
324
|
-
[
|
|
325
|
-
{
|
|
326
|
-
version: m,
|
|
327
|
-
output: this.refundLeaf()
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
version: m,
|
|
331
|
-
output: this.instantRefundLeaf()
|
|
332
|
-
}
|
|
333
|
-
]
|
|
334
|
-
];
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Generates the merkle proof for the leaf script
|
|
338
|
-
*/
|
|
339
|
-
generateMerkleProofFor(e) {
|
|
340
|
-
const r = this.leafHash(
|
|
341
|
-
1
|
|
342
|
-
/* REDEEM */
|
|
343
|
-
), t = this.leafHash(
|
|
344
|
-
2
|
|
345
|
-
/* INSTANT_REFUND */
|
|
346
|
-
), s = this.leafHash(
|
|
347
|
-
0
|
|
348
|
-
/* REFUND */
|
|
349
|
-
);
|
|
350
|
-
switch (e) {
|
|
351
|
-
case 1: {
|
|
352
|
-
const i = O(
|
|
353
|
-
s,
|
|
354
|
-
t
|
|
355
|
-
);
|
|
356
|
-
return [
|
|
357
|
-
h.crypto.taggedHash(
|
|
358
|
-
"TapBranch",
|
|
359
|
-
Buffer.concat(i)
|
|
360
|
-
)
|
|
361
|
-
];
|
|
362
|
-
}
|
|
363
|
-
case 0:
|
|
364
|
-
return [t, r];
|
|
365
|
-
case 2:
|
|
366
|
-
return [s, r];
|
|
367
|
-
default:
|
|
368
|
-
throw new Error(u.invalidLeaf);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
function x(S, e) {
|
|
373
|
-
const r = [];
|
|
374
|
-
for (let t = 0; t < e; t++)
|
|
375
|
-
r.push(S);
|
|
376
|
-
return r;
|
|
377
|
-
}
|
|
378
|
-
export {
|
|
379
|
-
H as GardenHTLC
|
|
380
|
-
};
|
package/dist/index110.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index45.cjs"),a=require("./index126.cjs"),_=require("./index87.cjs");var h=u.safeBufferExports.Buffer,l=a.readableBrowserExports.Transform,c=_.inherits_browserExports;function p(t,e){if(!h.isBuffer(t)&&typeof t!="string")throw new TypeError(e+" must be a string or a buffer")}function i(t){l.call(this),this._block=h.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}c(i,l);i.prototype._transform=function(t,e,r){var s=null;try{this.update(t,e)}catch(f){s=f}r(s)};i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(r){e=r}t(e)};i.prototype.update=function(t,e){if(p(t,"Data"),this._finalized)throw new Error("Digest already called");h.isBuffer(t)||(t=h.from(t,e));for(var r=this._block,s=0;this._blockOffset+t.length-s>=this._blockSize;){for(var f=this._blockOffset;f<this._blockSize;)r[f++]=t[s++];this._update(),this._blockOffset=0}for(;s<t.length;)r[this._blockOffset++]=t[s++];for(var n=0,o=t.length*8;o>0;++n)this._length[n]+=o,o=this._length[n]/4294967296|0,o>0&&(this._length[n]-=4294967296*o);return this};i.prototype._update=function(){throw new Error("_update is not implemented")};i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();t!==void 0&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e};i.prototype._digest=function(){throw new Error("_digest is not implemented")};var g=i;exports.hashBase=g;
|
package/dist/index110.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { s as a } from "./index45.js";
|
|
2
|
-
import { r as _ } from "./index126.js";
|
|
3
|
-
import { i as p } from "./index87.js";
|
|
4
|
-
var n = a.Buffer, l = _.Transform, u = p;
|
|
5
|
-
function c(t, r) {
|
|
6
|
-
if (!n.isBuffer(t) && typeof t != "string")
|
|
7
|
-
throw new TypeError(r + " must be a string or a buffer");
|
|
8
|
-
}
|
|
9
|
-
function i(t) {
|
|
10
|
-
l.call(this), this._block = n.allocUnsafe(t), this._blockSize = t, this._blockOffset = 0, this._length = [0, 0, 0, 0], this._finalized = !1;
|
|
11
|
-
}
|
|
12
|
-
u(i, l);
|
|
13
|
-
i.prototype._transform = function(t, r, e) {
|
|
14
|
-
var s = null;
|
|
15
|
-
try {
|
|
16
|
-
this.update(t, r);
|
|
17
|
-
} catch (f) {
|
|
18
|
-
s = f;
|
|
19
|
-
}
|
|
20
|
-
e(s);
|
|
21
|
-
};
|
|
22
|
-
i.prototype._flush = function(t) {
|
|
23
|
-
var r = null;
|
|
24
|
-
try {
|
|
25
|
-
this.push(this.digest());
|
|
26
|
-
} catch (e) {
|
|
27
|
-
r = e;
|
|
28
|
-
}
|
|
29
|
-
t(r);
|
|
30
|
-
};
|
|
31
|
-
i.prototype.update = function(t, r) {
|
|
32
|
-
if (c(t, "Data"), this._finalized) throw new Error("Digest already called");
|
|
33
|
-
n.isBuffer(t) || (t = n.from(t, r));
|
|
34
|
-
for (var e = this._block, s = 0; this._blockOffset + t.length - s >= this._blockSize; ) {
|
|
35
|
-
for (var f = this._blockOffset; f < this._blockSize; ) e[f++] = t[s++];
|
|
36
|
-
this._update(), this._blockOffset = 0;
|
|
37
|
-
}
|
|
38
|
-
for (; s < t.length; ) e[this._blockOffset++] = t[s++];
|
|
39
|
-
for (var h = 0, o = t.length * 8; o > 0; ++h)
|
|
40
|
-
this._length[h] += o, o = this._length[h] / 4294967296 | 0, o > 0 && (this._length[h] -= 4294967296 * o);
|
|
41
|
-
return this;
|
|
42
|
-
};
|
|
43
|
-
i.prototype._update = function() {
|
|
44
|
-
throw new Error("_update is not implemented");
|
|
45
|
-
};
|
|
46
|
-
i.prototype.digest = function(t) {
|
|
47
|
-
if (this._finalized) throw new Error("Digest already called");
|
|
48
|
-
this._finalized = !0;
|
|
49
|
-
var r = this._digest();
|
|
50
|
-
t !== void 0 && (r = r.toString(t)), this._block.fill(0), this._blockOffset = 0;
|
|
51
|
-
for (var e = 0; e < 4; ++e) this._length[e] = 0;
|
|
52
|
-
return r;
|
|
53
|
-
};
|
|
54
|
-
i.prototype._digest = function() {
|
|
55
|
-
throw new Error("_digest is not implemented");
|
|
56
|
-
};
|
|
57
|
-
var m = i;
|
|
58
|
-
export {
|
|
59
|
-
m as h
|
|
60
|
-
};
|
package/dist/index111.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
|
package/dist/index111.js
DELETED
package/dist/index112.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index87.cjs"),d=require("./index127.cjs"),x=require("./index45.cjs");var b=v.inherits_browserExports,c=d.hash,p=x.safeBufferExports.Buffer,w=[1518500249,1859775393,-1894007588,-899497514],l=new Array(80);function a(){this.init(),this._w=l,c.call(this,64,56)}b(a,c);a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function B(t){return t<<5|t>>>27}function E(t){return t<<30|t>>>2}function y(t,r,i,s){return t===0?r&i|~r&s:t===2?r&i|r&s|i&s:r^i^s}a.prototype._update=function(t){for(var r=this._w,i=this._a|0,s=this._b|0,h=this._c|0,n=this._d|0,o=this._e|0,e=0;e<16;++e)r[e]=t.readInt32BE(e*4);for(;e<80;++e)r[e]=r[e-3]^r[e-8]^r[e-14]^r[e-16];for(var _=0;_<80;++_){var f=~~(_/20),u=B(i)+y(f,s,h,n)+o+r[_]+w[f]|0;o=n,n=h,h=E(s),s=i,i=u}this._a=i+this._a|0,this._b=s+this._b|0,this._c=h+this._c|0,this._d=n+this._d|0,this._e=o+this._e|0};a.prototype._hash=function(){var t=p.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};var I=a;exports.sha=I;
|
package/dist/index112.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { i as u } from "./index87.js";
|
|
2
|
-
import { h as p } from "./index127.js";
|
|
3
|
-
import { s as x } from "./index45.js";
|
|
4
|
-
var d = u, c = p, w = x.Buffer, B = [
|
|
5
|
-
1518500249,
|
|
6
|
-
1859775393,
|
|
7
|
-
-1894007588,
|
|
8
|
-
-899497514
|
|
9
|
-
], b = new Array(80);
|
|
10
|
-
function h() {
|
|
11
|
-
this.init(), this._w = b, c.call(this, 64, 56);
|
|
12
|
-
}
|
|
13
|
-
d(h, c);
|
|
14
|
-
h.prototype.init = function() {
|
|
15
|
-
return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this;
|
|
16
|
-
};
|
|
17
|
-
function E(t) {
|
|
18
|
-
return t << 5 | t >>> 27;
|
|
19
|
-
}
|
|
20
|
-
function l(t) {
|
|
21
|
-
return t << 30 | t >>> 2;
|
|
22
|
-
}
|
|
23
|
-
function I(t, r, s, a) {
|
|
24
|
-
return t === 0 ? r & s | ~r & a : t === 2 ? r & s | r & a | s & a : r ^ s ^ a;
|
|
25
|
-
}
|
|
26
|
-
h.prototype._update = function(t) {
|
|
27
|
-
for (var r = this._w, s = this._a | 0, a = this._b | 0, e = this._c | 0, n = this._d | 0, o = this._e | 0, i = 0; i < 16; ++i) r[i] = t.readInt32BE(i * 4);
|
|
28
|
-
for (; i < 80; ++i) r[i] = r[i - 3] ^ r[i - 8] ^ r[i - 14] ^ r[i - 16];
|
|
29
|
-
for (var _ = 0; _ < 80; ++_) {
|
|
30
|
-
var f = ~~(_ / 20), v = E(s) + I(f, a, e, n) + o + r[_] + B[f] | 0;
|
|
31
|
-
o = n, n = e, e = l(a), a = s, s = v;
|
|
32
|
-
}
|
|
33
|
-
this._a = s + this._a | 0, this._b = a + this._b | 0, this._c = e + this._c | 0, this._d = n + this._d | 0, this._e = o + this._e | 0;
|
|
34
|
-
};
|
|
35
|
-
h.prototype._hash = function() {
|
|
36
|
-
var t = w.allocUnsafe(20);
|
|
37
|
-
return t.writeInt32BE(this._a | 0, 0), t.writeInt32BE(this._b | 0, 4), t.writeInt32BE(this._c | 0, 8), t.writeInt32BE(this._d | 0, 12), t.writeInt32BE(this._e | 0, 16), t;
|
|
38
|
-
};
|
|
39
|
-
var W = h;
|
|
40
|
-
export {
|
|
41
|
-
W as s
|
|
42
|
-
};
|
package/dist/index113.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index87.cjs"),d=require("./index127.cjs"),x=require("./index45.cjs");var b=v.inherits_browserExports,c=d.hash,l=x.safeBufferExports.Buffer,p=[1518500249,1859775393,-1894007588,-899497514],w=new Array(80);function a(){this.init(),this._w=w,c.call(this,64,56)}b(a,c);a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function B(t){return t<<1|t>>>31}function E(t){return t<<5|t>>>27}function y(t){return t<<30|t>>>2}function I(t,r,i,s){return t===0?r&i|~r&s:t===2?r&i|r&s|i&s:r^i^s}a.prototype._update=function(t){for(var r=this._w,i=this._a|0,s=this._b|0,h=this._c|0,n=this._d|0,_=this._e|0,e=0;e<16;++e)r[e]=t.readInt32BE(e*4);for(;e<80;++e)r[e]=B(r[e-3]^r[e-8]^r[e-14]^r[e-16]);for(var o=0;o<80;++o){var f=~~(o/20),u=E(i)+I(f,s,h,n)+_+r[o]+p[f]|0;_=n,n=h,h=y(s),s=i,i=u}this._a=i+this._a|0,this._b=s+this._b|0,this._c=h+this._c|0,this._d=n+this._d|0,this._e=_+this._e|0};a.prototype._hash=function(){var t=l.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};var q=a;exports.sha1=q;
|
package/dist/index113.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { i as v } from "./index87.js";
|
|
2
|
-
import { h as p } from "./index127.js";
|
|
3
|
-
import { s as x } from "./index45.js";
|
|
4
|
-
var d = v, c = p, w = x.Buffer, B = [
|
|
5
|
-
1518500249,
|
|
6
|
-
1859775393,
|
|
7
|
-
-1894007588,
|
|
8
|
-
-899497514
|
|
9
|
-
], b = new Array(80);
|
|
10
|
-
function h() {
|
|
11
|
-
this.init(), this._w = b, c.call(this, 64, 56);
|
|
12
|
-
}
|
|
13
|
-
d(h, c);
|
|
14
|
-
h.prototype.init = function() {
|
|
15
|
-
return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this;
|
|
16
|
-
};
|
|
17
|
-
function E(t) {
|
|
18
|
-
return t << 1 | t >>> 31;
|
|
19
|
-
}
|
|
20
|
-
function l(t) {
|
|
21
|
-
return t << 5 | t >>> 27;
|
|
22
|
-
}
|
|
23
|
-
function I(t) {
|
|
24
|
-
return t << 30 | t >>> 2;
|
|
25
|
-
}
|
|
26
|
-
function y(t, r, s, a) {
|
|
27
|
-
return t === 0 ? r & s | ~r & a : t === 2 ? r & s | r & a | s & a : r ^ s ^ a;
|
|
28
|
-
}
|
|
29
|
-
h.prototype._update = function(t) {
|
|
30
|
-
for (var r = this._w, s = this._a | 0, a = this._b | 0, e = this._c | 0, n = this._d | 0, _ = this._e | 0, i = 0; i < 16; ++i) r[i] = t.readInt32BE(i * 4);
|
|
31
|
-
for (; i < 80; ++i) r[i] = E(r[i - 3] ^ r[i - 8] ^ r[i - 14] ^ r[i - 16]);
|
|
32
|
-
for (var o = 0; o < 80; ++o) {
|
|
33
|
-
var f = ~~(o / 20), u = l(s) + y(f, a, e, n) + _ + r[o] + B[f] | 0;
|
|
34
|
-
_ = n, n = e, e = I(a), a = s, s = u;
|
|
35
|
-
}
|
|
36
|
-
this._a = s + this._a | 0, this._b = a + this._b | 0, this._c = e + this._c | 0, this._d = n + this._d | 0, this._e = _ + this._e | 0;
|
|
37
|
-
};
|
|
38
|
-
h.prototype._hash = function() {
|
|
39
|
-
var t = w.allocUnsafe(20);
|
|
40
|
-
return t.writeInt32BE(this._a | 0, 0), t.writeInt32BE(this._b | 0, 4), t.writeInt32BE(this._c | 0, 8), t.writeInt32BE(this._d | 0, 12), t.writeInt32BE(this._e | 0, 16), t;
|
|
41
|
-
};
|
|
42
|
-
var A = h;
|
|
43
|
-
export {
|
|
44
|
-
A as s
|
|
45
|
-
};
|
package/dist/index114.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index87.cjs"),e=require("./index115.cjs"),s=require("./index127.cjs"),h=require("./index45.cjs");var a=r.inherits_browserExports,n=e.sha256,f=s.hash,o=h.safeBufferExports.Buffer,_=new Array(64);function i(){this.init(),this._w=_,f.call(this,64,56)}a(i,n);i.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};i.prototype._hash=function(){var t=o.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t};var c=i;exports.sha224=c;
|
package/dist/index114.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { i as r } from "./index87.js";
|
|
2
|
-
import { s } from "./index115.js";
|
|
3
|
-
import { h } from "./index127.js";
|
|
4
|
-
import { s as a } from "./index45.js";
|
|
5
|
-
var e = r, f = s, n = h, o = a.Buffer, _ = new Array(64);
|
|
6
|
-
function i() {
|
|
7
|
-
this.init(), this._w = _, n.call(this, 64, 56);
|
|
8
|
-
}
|
|
9
|
-
e(i, f);
|
|
10
|
-
i.prototype.init = function() {
|
|
11
|
-
return this._a = 3238371032, this._b = 914150663, this._c = 812702999, this._d = 4144912697, this._e = 4290775857, this._f = 1750603025, this._g = 1694076839, this._h = 3204075428, this;
|
|
12
|
-
};
|
|
13
|
-
i.prototype._hash = function() {
|
|
14
|
-
var t = o.allocUnsafe(28);
|
|
15
|
-
return t.writeInt32BE(this._a, 0), t.writeInt32BE(this._b, 4), t.writeInt32BE(this._c, 8), t.writeInt32BE(this._d, 12), t.writeInt32BE(this._e, 16), t.writeInt32BE(this._f, 20), t.writeInt32BE(this._g, 24), t;
|
|
16
|
-
};
|
|
17
|
-
var B = i;
|
|
18
|
-
export {
|
|
19
|
-
B as s
|
|
20
|
-
};
|
package/dist/index115.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./index87.cjs"),u=require("./index127.cjs"),c=require("./index45.cjs");var v=F.inherits_browserExports,f=u.hash,D=c.safeBufferExports.Buffer,b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],d=new Array(64);function e(){this.init(),this._w=d,f.call(this,64,56)}v(e,f);e.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function w(t,r,s){return s^t&(r^s)}function g(t,r,s){return t&r|s&(t|r)}function p(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function I(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function m(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function l(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}e.prototype._update=function(t){for(var r=this._w,s=this._a|0,x=this._b|0,a=this._c|0,C=this._d|0,h=this._e|0,n=this._f|0,B=this._g|0,A=this._h|0,i=0;i<16;++i)r[i]=t.readInt32BE(i*4);for(;i<64;++i)r[i]=l(r[i-2])+r[i-7]+m(r[i-15])+r[i-16]|0;for(var _=0;_<64;++_){var E=A+I(h)+w(h,n,B)+b[_]+r[_]|0,o=p(s)+g(s,x,a)|0;A=B,B=n,n=h,h=C+E|0,C=a,a=x,x=s,s=E+o|0}this._a=s+this._a|0,this._b=x+this._b|0,this._c=a+this._c|0,this._d=C+this._d|0,this._e=h+this._e|0,this._f=n+this._f|0,this._g=B+this._g|0,this._h=A+this._h|0};e.prototype._hash=function(){var t=D.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t};var y=e;exports.sha256=y;
|
package/dist/index115.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { i as F } from "./index87.js";
|
|
2
|
-
import { h as c } from "./index127.js";
|
|
3
|
-
import { s as u } from "./index45.js";
|
|
4
|
-
var v = F, f = c, D = u.Buffer, m = [
|
|
5
|
-
1116352408,
|
|
6
|
-
1899447441,
|
|
7
|
-
3049323471,
|
|
8
|
-
3921009573,
|
|
9
|
-
961987163,
|
|
10
|
-
1508970993,
|
|
11
|
-
2453635748,
|
|
12
|
-
2870763221,
|
|
13
|
-
3624381080,
|
|
14
|
-
310598401,
|
|
15
|
-
607225278,
|
|
16
|
-
1426881987,
|
|
17
|
-
1925078388,
|
|
18
|
-
2162078206,
|
|
19
|
-
2614888103,
|
|
20
|
-
3248222580,
|
|
21
|
-
3835390401,
|
|
22
|
-
4022224774,
|
|
23
|
-
264347078,
|
|
24
|
-
604807628,
|
|
25
|
-
770255983,
|
|
26
|
-
1249150122,
|
|
27
|
-
1555081692,
|
|
28
|
-
1996064986,
|
|
29
|
-
2554220882,
|
|
30
|
-
2821834349,
|
|
31
|
-
2952996808,
|
|
32
|
-
3210313671,
|
|
33
|
-
3336571891,
|
|
34
|
-
3584528711,
|
|
35
|
-
113926993,
|
|
36
|
-
338241895,
|
|
37
|
-
666307205,
|
|
38
|
-
773529912,
|
|
39
|
-
1294757372,
|
|
40
|
-
1396182291,
|
|
41
|
-
1695183700,
|
|
42
|
-
1986661051,
|
|
43
|
-
2177026350,
|
|
44
|
-
2456956037,
|
|
45
|
-
2730485921,
|
|
46
|
-
2820302411,
|
|
47
|
-
3259730800,
|
|
48
|
-
3345764771,
|
|
49
|
-
3516065817,
|
|
50
|
-
3600352804,
|
|
51
|
-
4094571909,
|
|
52
|
-
275423344,
|
|
53
|
-
430227734,
|
|
54
|
-
506948616,
|
|
55
|
-
659060556,
|
|
56
|
-
883997877,
|
|
57
|
-
958139571,
|
|
58
|
-
1322822218,
|
|
59
|
-
1537002063,
|
|
60
|
-
1747873779,
|
|
61
|
-
1955562222,
|
|
62
|
-
2024104815,
|
|
63
|
-
2227730452,
|
|
64
|
-
2361852424,
|
|
65
|
-
2428436474,
|
|
66
|
-
2756734187,
|
|
67
|
-
3204031479,
|
|
68
|
-
3329325298
|
|
69
|
-
], p = new Array(64);
|
|
70
|
-
function x() {
|
|
71
|
-
this.init(), this._w = p, f.call(this, 64, 56);
|
|
72
|
-
}
|
|
73
|
-
v(x, f);
|
|
74
|
-
x.prototype.init = function() {
|
|
75
|
-
return this._a = 1779033703, this._b = 3144134277, this._c = 1013904242, this._d = 2773480762, this._e = 1359893119, this._f = 2600822924, this._g = 528734635, this._h = 1541459225, this;
|
|
76
|
-
};
|
|
77
|
-
function b(t, r, s) {
|
|
78
|
-
return s ^ t & (r ^ s);
|
|
79
|
-
}
|
|
80
|
-
function w(t, r, s) {
|
|
81
|
-
return t & r | s & (t | r);
|
|
82
|
-
}
|
|
83
|
-
function d(t) {
|
|
84
|
-
return (t >>> 2 | t << 30) ^ (t >>> 13 | t << 19) ^ (t >>> 22 | t << 10);
|
|
85
|
-
}
|
|
86
|
-
function g(t) {
|
|
87
|
-
return (t >>> 6 | t << 26) ^ (t >>> 11 | t << 21) ^ (t >>> 25 | t << 7);
|
|
88
|
-
}
|
|
89
|
-
function I(t) {
|
|
90
|
-
return (t >>> 7 | t << 25) ^ (t >>> 18 | t << 14) ^ t >>> 3;
|
|
91
|
-
}
|
|
92
|
-
function l(t) {
|
|
93
|
-
return (t >>> 17 | t << 15) ^ (t >>> 19 | t << 13) ^ t >>> 10;
|
|
94
|
-
}
|
|
95
|
-
x.prototype._update = function(t) {
|
|
96
|
-
for (var r = this._w, s = this._a | 0, a = this._b | 0, B = this._c | 0, e = this._d | 0, h = this._e | 0, _ = this._f | 0, n = this._g | 0, A = this._h | 0, i = 0; i < 16; ++i) r[i] = t.readInt32BE(i * 4);
|
|
97
|
-
for (; i < 64; ++i) r[i] = l(r[i - 2]) + r[i - 7] + I(r[i - 15]) + r[i - 16] | 0;
|
|
98
|
-
for (var C = 0; C < 64; ++C) {
|
|
99
|
-
var E = A + g(h) + b(h, _, n) + m[C] + r[C] | 0, o = d(s) + w(s, a, B) | 0;
|
|
100
|
-
A = n, n = _, _ = h, h = e + E | 0, e = B, B = a, a = s, s = E + o | 0;
|
|
101
|
-
}
|
|
102
|
-
this._a = s + this._a | 0, this._b = a + this._b | 0, this._c = B + this._c | 0, this._d = e + this._d | 0, this._e = h + this._e | 0, this._f = _ + this._f | 0, this._g = n + this._g | 0, this._h = A + this._h | 0;
|
|
103
|
-
};
|
|
104
|
-
x.prototype._hash = function() {
|
|
105
|
-
var t = D.allocUnsafe(32);
|
|
106
|
-
return t.writeInt32BE(this._a, 0), t.writeInt32BE(this._b, 4), t.writeInt32BE(this._c, 8), t.writeInt32BE(this._d, 12), t.writeInt32BE(this._e, 16), t.writeInt32BE(this._f, 20), t.writeInt32BE(this._g, 24), t.writeInt32BE(this._h, 28), t;
|
|
107
|
-
};
|
|
108
|
-
var K = x;
|
|
109
|
-
export {
|
|
110
|
-
K as s
|
|
111
|
-
};
|