@otskit/client 0.6.0 → 0.6.1
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 +11 -8
- package/dist/index.js +11 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -885,10 +885,18 @@ var EsploraClient = class {
|
|
|
885
885
|
this.#logger?.debug(`Esplora raw header ${hash}`);
|
|
886
886
|
const response = await this.#networkLayer.request(
|
|
887
887
|
this.#url,
|
|
888
|
-
{ url: `${this.#url}/block/${hash}/header`, method: "GET", headers: { Accept: "
|
|
888
|
+
{ url: `${this.#url}/block/${hash}/header`, method: "GET", headers: { Accept: "text/plain" } },
|
|
889
889
|
signal
|
|
890
890
|
);
|
|
891
|
-
const
|
|
891
|
+
const hex = this.#decode(response.data).trim();
|
|
892
|
+
let data;
|
|
893
|
+
try {
|
|
894
|
+
data = hexToBytes(hex);
|
|
895
|
+
} catch (cause) {
|
|
896
|
+
throw new EsploraResponseError("esplora returned a non-hex raw block header", {
|
|
897
|
+
...cause instanceof Error ? { cause } : {}
|
|
898
|
+
});
|
|
899
|
+
}
|
|
892
900
|
if (data.length !== RAW_HEADER_SIZE) {
|
|
893
901
|
throw new EsploraResponseError(
|
|
894
902
|
`raw block header must be ${RAW_HEADER_SIZE} bytes; got ${data.length}`
|
|
@@ -997,12 +1005,7 @@ async function orchestrateVerify(proof, networkLayer, originalDataHash, logger,
|
|
|
997
1005
|
for (const { msg, attestation } of bitcoinAtts) {
|
|
998
1006
|
if (attestation.kind !== "bitcoin") continue;
|
|
999
1007
|
try {
|
|
1000
|
-
const blockTime = await verifyTimestampAttestation(
|
|
1001
|
-
Uint8Array.from(msg).reverse(),
|
|
1002
|
-
attestation,
|
|
1003
|
-
explorer,
|
|
1004
|
-
signal
|
|
1005
|
-
);
|
|
1008
|
+
const blockTime = await verifyTimestampAttestation(msg, attestation, explorer, signal);
|
|
1006
1009
|
logger?.info(`Verified against Bitcoin block ${attestation.height}`);
|
|
1007
1010
|
return { status: "verified", blockHeight: attestation.height, blockTime };
|
|
1008
1011
|
} catch (err) {
|
package/dist/index.js
CHANGED
|
@@ -835,10 +835,18 @@ var EsploraClient = class {
|
|
|
835
835
|
this.#logger?.debug(`Esplora raw header ${hash}`);
|
|
836
836
|
const response = await this.#networkLayer.request(
|
|
837
837
|
this.#url,
|
|
838
|
-
{ url: `${this.#url}/block/${hash}/header`, method: "GET", headers: { Accept: "
|
|
838
|
+
{ url: `${this.#url}/block/${hash}/header`, method: "GET", headers: { Accept: "text/plain" } },
|
|
839
839
|
signal
|
|
840
840
|
);
|
|
841
|
-
const
|
|
841
|
+
const hex = this.#decode(response.data).trim();
|
|
842
|
+
let data;
|
|
843
|
+
try {
|
|
844
|
+
data = hexToBytes(hex);
|
|
845
|
+
} catch (cause) {
|
|
846
|
+
throw new EsploraResponseError("esplora returned a non-hex raw block header", {
|
|
847
|
+
...cause instanceof Error ? { cause } : {}
|
|
848
|
+
});
|
|
849
|
+
}
|
|
842
850
|
if (data.length !== RAW_HEADER_SIZE) {
|
|
843
851
|
throw new EsploraResponseError(
|
|
844
852
|
`raw block header must be ${RAW_HEADER_SIZE} bytes; got ${data.length}`
|
|
@@ -947,12 +955,7 @@ async function orchestrateVerify(proof, networkLayer, originalDataHash, logger,
|
|
|
947
955
|
for (const { msg, attestation } of bitcoinAtts) {
|
|
948
956
|
if (attestation.kind !== "bitcoin") continue;
|
|
949
957
|
try {
|
|
950
|
-
const blockTime = await verifyTimestampAttestation(
|
|
951
|
-
Uint8Array.from(msg).reverse(),
|
|
952
|
-
attestation,
|
|
953
|
-
explorer,
|
|
954
|
-
signal
|
|
955
|
-
);
|
|
958
|
+
const blockTime = await verifyTimestampAttestation(msg, attestation, explorer, signal);
|
|
956
959
|
logger?.info(`Verified against Bitcoin block ${attestation.height}`);
|
|
957
960
|
return { status: "verified", blockHeight: attestation.height, blockTime };
|
|
958
961
|
} catch (err) {
|