bitbox-sdk
Version:
BITBOX SDK for Bitcoin Cash
28 lines (25 loc) • 689 B
text/typescript
import axios, { AxiosResponse } from "axios"
import { REST_URL } from "./BITBOX"
export class Generating {
public restURL: string
constructor(restURL: string = REST_URL) {
this.restURL = restURL
}
public async generateToAddress(
blocks: number,
address: string,
maxtries: number = 1000000
): Promise<string[]> {
try {
const response: AxiosResponse = await axios.post(
`${
this.restURL
}generating/generateToAddress/${blocks}/${address}?maxtries=${maxtries}`
)
return response.data
} catch (error) {
if (error.response && error.response.data) throw error.response.data
else throw error
}
}
}