UNPKG

@atomicport/bitcoin

Version:

Support Cross-Chain-Swap with HTLC on any blockchains

33 lines (32 loc) 1.33 kB
/// <reference types="node" /> import { MempoolReturn } from '@mempool/mempool.js/lib/interfaces/index'; import { networks } from 'bitcoinjs-lib'; import { HashPair, Utxo } from './Core'; import { ECPairInterface } from 'ecpair'; /** * bitcoin 系のコインのインターフェース */ export default abstract class Bitcoin { readonly mempool: MempoolReturn['bitcoin']; readonly network: networks.Network; readonly baseUrl: string; constructor(network: networks.Network); createHashPair(): HashPair; protected getCurrentBlockHeight(): Promise<number>; protected postTransaction(txhex: string): Promise<any>; protected getInputData(txid: string, contractAddress: string): Promise<{ value: number; index: number; }>; protected getUtxos(address: string): Promise<{ hash: string; index: number; value: number; }[]>; protected buildAndSignTx(sender: ECPairInterface, address: string, recipient: string, sendingSat: number, feeSat: number, utxos: Utxo[]): string; protected witnessStackToScriptWitness(witness: any): Buffer; /** * Generate HTLC Contract Script for Bitcoin */ protected generateSwapWitnessScript(receiverPublicKey: Buffer, userRefundPublicKey: Buffer, paymentHash: string, timelock: number): Buffer; }