@muirglacier/jellyfish-transaction-builder
Version:
A collection of TypeScript + JavaScript tools and libraries for DeFi Blockchain developers to build decentralized finance for Bitcoin
58 lines • 2.47 kB
TypeScript
import { OP_DEFI_TX, Script, Transaction, TransactionSegWit, Vin } from '@muirglacier/jellyfish-transaction';
import BigNumber from 'bignumber.js';
import { EllipticPairProvider, FeeRateProvider, Prevout, PrevoutProvider } from '../provider';
import { Network } from '@muirglacier/jellyfish-network';
/**
* Transaction builder for P2WPKH inputs.
*/
export declare abstract class P2WPKHTxnBuilder {
readonly feeProvider: FeeRateProvider;
readonly prevoutProvider: PrevoutProvider;
readonly ellipticPairProvider: EllipticPairProvider;
readonly network: Network;
constructor(feeProvider: FeeRateProvider, prevoutProvider: PrevoutProvider, ellipticPairProvider: EllipticPairProvider, network: Network);
/**
* @return {Promise<Prevouts>}
*/
protected allPrevouts(): Promise<Prevouts>;
/**
* @param {BigNumber} minBalance to collect, required to form a transaction
* @return {Promise<Prevouts>}
*/
protected collectPrevouts(minBalance: BigNumber): Promise<Prevouts>;
/**
* @param {Transaction} transaction to calculate P2WPKH fee for
* @return {Promise<BigNumber>} fee for transaction
*/
protected calculateFee(transaction: Transaction): Promise<BigNumber>;
/**
* Craft a transaction with OP_DEFI_TX from the output of OP_CODES.OP_DEFI_TX_.
* This is a helper method for creating custom defi transactions.
*
* As DeFi custom transaction will always require small amount of DFI,
* collectPrevouts() is set to search for at least 0.001 DFI amount of prevout.
* This will also evidently merge small prevout during the operation.
*
* Do not use this if you don't know what you are doing. You might misplace funds.
*
* @param {OP_DEFI_TX} opDeFiTx to create
* @param {Script} changeScript to send unspent to after deducting the fees
* @param {BigNumber} [outValue=0] for the opDeFiTx, usually always be 0.
*/
createDeFiTx(opDeFiTx: OP_DEFI_TX, changeScript: Script, outValue?: BigNumber): Promise<TransactionSegWit>;
/**
* @param {Transaction} transaction to sign
* @param {Prevout[]} prevouts input to sign
*/
protected sign(transaction: Transaction, prevouts: Prevout[]): Promise<TransactionSegWit>;
}
/**
* Collection of Prevout to form a transaction.
*/
interface Prevouts {
prevouts: Prevout[];
vin: Vin[];
total: BigNumber;
}
export {};
//# sourceMappingURL=txn_builder.d.ts.map