"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchUTXOs = exports.fetchMattercloudKey = void 0;
const node_fetch_1 = __importDefault(require("node-fetch"));
async function fetchMattercloudKey() {
    const response = await (0, node_fetch_1.default)("https://api.bitindex.network/api/v2/registration/account?secret=secretkey", {
        method: "POST"
    });
    const json = (await response.json());
    if (!json.apiKey)
        throw new Error("Failed to request MatterCloud API key.");
    return json.apiKey;
}
exports.fetchMattercloudKey = fetchMattercloudKey;
async function fetchUTXOs(address, apiKey) {
    const response = await (0, node_fetch_1.default)("https://api.mattercloud.net/api/v3/main/addrs/utxo", {
        method: "POST",
        body: JSON.stringify({ addrs: address }),
        headers: { api_key: apiKey }
    });
    const utxos = (await response.json());
    return utxos;
}
exports.fetchUTXOs = fetchUTXOs;
// export async function fetchOracleDetails(): Promise<oracleDetail[]> {
//   // TODO: Implement
// }
//# sourceMappingURL=mattercloud.js.map