/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { BroadcastKMS } from '../models/BroadcastKMS'; import type { BtcBasedBalance } from '../models/BtcBasedBalance'; import type { BtcBlock } from '../models/BtcBlock'; import type { BtcInfo } from '../models/BtcInfo'; import type { BtcTransactionFromAddress } from '../models/BtcTransactionFromAddress'; import type { BtcTransactionFromAddressKMS } from '../models/BtcTransactionFromAddressKMS'; import type { BtcTransactionFromUTXO } from '../models/BtcTransactionFromUTXO'; import type { BtcTransactionFromUTXOKMS } from '../models/BtcTransactionFromUTXOKMS'; import type { BtcTx } from '../models/BtcTx'; import type { BtcUTXO } from '../models/BtcUTXO'; import type { PrivKey } from '../models/PrivKey'; import type { PrivKeyRequest } from '../models/PrivKeyRequest'; import type { SignatureId } from '../models/SignatureId'; import type { TransactionHash } from '../models/TransactionHash'; import type { Wallet } from '../models/Wallet'; import type { CancelablePromise } from '../core/CancelablePromise'; import { request as __request } from '../core/request'; export class BitcoinService { /** * Generate a Bitcoin wallet *
1 credit per API call
*Tatum supports BIP44 HD wallets. Because they can generate 2^31 addresses from 1 mnemonic phrase, they are very convenient and secure. A mnemonic phrase consists of 24 special words in a defined order and can restore access to all generated addresses and private keys.
Each address is identified by 3 main values:
Tatum follows BIP44 specification and generates for Bitcoin wallet with derivation path m'/44'/0'/0'/0. More about BIP44 HD wallets can be found here - https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki. * Generate BIP44 compatible Bitcoin wallet.
* * @param mnemonic Mnemonic to use for generation of extended public and private keys. * @returns Wallet OK * @throws ApiError */ public static btcGenerateWallet( mnemonic?: string, ): CancelablePromise1 credit per API call
*Generate a Bitcoin address from the extended public key of the wallet. The address is generated for the specific index - each extended public key can generate up to 2^32 addresses with the index starting from 0 up to 2^31 - 1.
* * @param xpub Extended public key of a wallet. * @param index Derivation index of the desired address to be generated. * @returns any OK * @throws ApiError */ public static btcGenerateAddress( xpub: string, index: number, ): CancelablePromise<{ /** * Bitcoin address */ address?: string; }> { return __request({ method: 'GET', path: `/v3/bitcoin/address/${xpub}/${index}`, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server while processing the request.`, }, }); } /** * Generate the private key for a Bitcoin address *1 credit per API call
*Generates a private key for an address from a mnemonic for a given derivation path index. The private key is generated for the specific index - each mnemonic can generate up to 2^32 private keys starting from index 0 until 2^31 - 1.
* * @param requestBody * @returns PrivKey OK * @throws ApiError */ public static btcGenerateAddressPrivateKey( requestBody: PrivKeyRequest, ): CancelablePromise1 credit per API call
*Gets Bitcoin blockchain information. Obtains basic info like the testnet / mainnet version of the chain, the current block number and its hash.
* * @returns BtcInfo OK * @throws ApiError */ public static btcGetBlockChainInfo(): CancelablePromise1 credit per API call
*Gets a Bitcoin block hash. Returns the hash of the block to get the block's details.
* * @param i The number of blocks preceding a particular block on a blockchain. * @returns any OK * @throws ApiError */ public static btcGetBlockHash( i: number, ): CancelablePromise<{ /** * Block hash */ hash?: string; }> { return __request({ method: 'GET', path: `/v3/bitcoin/block/hash/${i}`, errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server while processing the request.`, }, }); } /** * Get a Bitcoin block by its hash or height *1 credit per API call
*Gets Bitcoin block detail by block hash or height.
* * @param hash Block hash or height. * @returns BtcBlock OK * @throws ApiError */ public static btcGetBlock( hash: string, ): CancelablePromise1 credit per API call
*Get the balance of a Bitcoin address.
* * @param address The blockchain address to get the balance for * @returns BtcBasedBalance OK * @throws ApiError */ public static btcGetBalanceOfAddress( address: string, ): CancelablePromise1 credit per API call
*Get all transactions for a Bitcoin address.
* * @param address Address * @param pageSize Max number of items per page is 50. * @param offset Offset to obtain the next page of data. * @returns BtcTx OK * @throws ApiError */ public static btcGetTxByAddress( address: string, pageSize: number, offset?: number, ): CancelablePromise2 credits per API call
*Send BTC to blockchain addresses. It is possible to build a blockchain transaction in 2 ways:
*In bitcoin-like blockchains, a transaction is created from the list of previously unspent UTXOs. Every UTXO contains the amount of funds that can be spent.
*When the UTXO is entered into the transaction, the whole amount is included and must be spent. For example, address A receives 2 transactions, T1 with 1 BTC and T2 with 2 BTC. The transaction, which will consume the UTXOs for T1 and T2, will have an available amount to spend of 3 BTC = 1 BTC (T1) + 2 BTC(T2).
*There can be multiple recipients of the transactions. In the to section, every recipient address has its own corresponding amount. When the amount of funds that the recipient should receive is lower than the amount of funds from the UTXOs, the difference is used as a transaction fee.
*Signing a transaction
*When sending BTC, you are charged a fee for the transaction, and you must sign the transaction with the private key of the blockchain address from which the fee will be deducted.
*Providing the private key in the API is not a secure way of signing transactions, because the private key can be stolen or exposed. Your private keys should never leave your security perimeter. You should use the private keys only for testing a solution you are building on the testnet of a blockchain.
*For signing transactions on the mainnet, we strongly recommend that you use the Tatum Key Management System (KMS) and provide the signature ID instead of the private key in the API. Alternatively, you can use the Tatum JavaScript client.
* * @param requestBody * @returns any OK * @throws ApiError */ public static btcTransferBlockchain( requestBody: (BtcTransactionFromAddress | BtcTransactionFromAddressKMS | BtcTransactionFromUTXO | BtcTransactionFromUTXOKMS), ): CancelablePromise<(TransactionHash | SignatureId)> { return __request({ method: 'POST', path: `/v3/bitcoin/transaction`, body: requestBody, mediaType: 'application/json', errors: { 400: `Bad Request. Validation failed for the given object in the HTTP Body or Request parameters.`, 401: `Unauthorized. Not valid or inactive subscription key present in the HTTP Header.`, 403: `Forbidden. The request is authenticated, but it is not possible to perform the required operation due to a logical error or invalid permissions.`, 500: `Internal server error. There was an error on the server while processing the request.`, }, }); } /** * Get a Bitcoin transaction by its hash *1 credit per API call
*Get Bitcoin Transaction detail by transaction hash.
* * @param hash Transaction hash * @returns BtcTx OK * @throws ApiError */ public static btcGetRawTransaction( hash: string, ): CancelablePromise1 credit per API call
*Get information about a transaction output in a transaction and check whether this output is a UTXO or has been spent.
*"UTXO" stands for "Unspent Transaction Output". A UTXO is the amount of BTC/satoshis that remains at a Bitcoin address after a cryptocurrency transaction involving this address has been performed. The UTXO can then be used as input for a new cryptocurrency transaction. For more information about Bitcoin transactions and UTXO, see the Bitcoin user documentation.
*404 response code.1 credit per API call
*Gets Bitcoin transaction IDs in the mempool.
* * @returns string OK * @throws ApiError */ public static btcGetMempool(): CancelablePromise2 credits per API call
*Broadcasts a signed transaction to the Bitcoin blockchain. This method is used internally from Tatum KMS, Tatum Middleware or Tatum Client Libraries. * It is possible to create a custom signing mechanism and only use this method for broadcasting data to the blockchain.
* * @param requestBody * @returns TransactionHash OK * @throws ApiError */ public static btcBroadcast( requestBody: BroadcastKMS, ): CancelablePromiseThis endpoint is deprecated. Do not use it.
* Instead, use this API.
2 credits per API call
*Use this endpoint URL as an http-based JSON RPC driver to connect directly to the node provided by Tatum. * To learn more about JSON RPC, visit the Bitcoin developers' guide.
* * @param requestBody * @returns any OK * @throws ApiError */ public static btcRpcDriver( requestBody: { /** * Version of the JSON RPC. */ jsonrpc?: string; /** * ID of the request, could be any arbitrary identifier. */ id?: string; /** * Method to invoke on the node. */ method?: string; /** * Params to the method call, if required. */ params?: any[]; }, ): CancelablePromise