@bithive/bitcoin-sdk
Version:
BitHive SDK
81 lines (80 loc) • 2.2 kB
TypeScript
import * as bitcoin from 'bitcoinjs-lib';
import { Buffer } from 'buffer';
import { CommonUtxo, CommonUtxoSelectionStrategy } from './utxo';
import { PublicKey } from './crypto';
export type ValidateDepositInTransactionParams = {
transaction: bitcoin.Transaction;
amount: number;
position: DepositPosition;
metadata: DepositMetadata;
network: bitcoin.Network;
};
export type ValidateDepositInTransactionResult = {
redeemScript: Buffer;
};
export type BuildUnsignedDepositPsbtParams = {
/**
* UTXOs that are used to do deposit
*/
utxos: CommonUtxo[];
/**
* Deposit amount. If specified, will automatically match enough UTXOs
*/
amount?: number;
/**
* Strategy to select UTXOs
*/
strategy?: CommonUtxoSelectionStrategy;
/**
* Fee limit of deposit transaction
*/
feeLimit?: number;
/**
* Fee rate of deposit transaction. Note that the actual fee rate is always less than specified
* because it is only used for fee estimation
*/
feeRate?: number;
/**
* Fee of deposit transaction. Note that the actual fee will be greater than specified if change
* is considered as dust
*/
fee?: number;
/**
* Change output script. If not specified, potential change will be considered as dust
*/
changeScript?: Buffer;
/**
* Dust limit for change value. If change value is less than or equal to this limit, the change
* will be considered as dust
*/
dustLimit?: number;
/**
* Deposit metadata
*/
metadata: DepositMetadata;
/**
* Network
*/
network: bitcoin.Network;
};
export type BuildUnsignedDepositPsbtResult = {
psbt: bitcoin.Psbt;
metadata: DepositPsbtMetadata;
};
export type DepositPsbtMetadata = {
utxos: CommonUtxo[];
amount: number;
changeAmount: number;
fee: number;
position: DepositPosition;
};
export type DepositPosition = {
vout: number;
messageVout: number;
};
export type DepositMetadata = {
publicKey: PublicKey;
chainSignaturesPublicKey: PublicKey;
soloWithdrawSequenceHeight: number;
earliestDepositBlockHeight: number;
};