@bithive/bitcoin-sdk
Version:
BitHive SDK
76 lines (75 loc) • 2.19 kB
TypeScript
import * as bitcoin from 'bitcoinjs-lib';
import { Buffer } from 'buffer';
import { PublicKey } from './crypto';
import { DepositUtxo, DepositUtxoSelectionStrategy, DepositUtxoWithScript } from './utxo';
import { DepositMetadata, DepositPosition } from './deposit';
export type BuildUnsignedWithdrawPsbtParams = {
/**
* Deposit UTXOs that are used to do withdrawal
*/
utxos: DepositUtxo[];
/**
* Withdrawal amount. This amount includes the fee, so the actual withdrawal amount may be less.
* If specified, will automatically match enough deposit UTXOs
*/
amount?: number;
/**
* Strategy to select deposit UTXOs
*/
strategy?: DepositUtxoSelectionStrategy;
/**
* Recipient output script
*/
recipientScript: Buffer;
/**
* Fee limit of withdrawal transaction
*/
feeLimit?: number;
/**
* Fee rate of withdrawal transaction. Note that the actual fee rate is always less than specified
* because it is only used for fee estimation
*/
feeRate?: number;
/**
* Fee of withdrawal transaction
*/
fee?: number;
/**
* Dust limit for change value. If change value is less than or equal to this limit, the change
* will be considered as part of withdrawal (not fee)
*/
dustLimit?: number;
/**
* Redeposit metadata. Change can be used to do redeposit
*/
redepositMetadata?: DepositMetadata;
/**
* Network
*/
network: bitcoin.Network;
};
export type BuildUnsignedWithdrawPsbtResult = {
psbt: bitcoin.Psbt;
metadata: WithdrawPsbtMetadata;
};
export type FinalizeWithdrawPsbtParams = {
psbt: bitcoin.Psbt;
inputs: FinalizeWithdrawPsbtInput[];
network: bitcoin.Network;
};
export type FinalizeWithdrawPsbtInput = {
vin: number;
partialSignature: PartialSignature;
chainPartialSignature?: PartialSignature;
};
export type PartialSignature = {
publicKey: PublicKey;
signature?: Buffer;
};
export type WithdrawPsbtMetadata = {
utxos: DepositUtxoWithScript[];
amount: number;
fee: number;
redepositAmount: number;
redepositPosition?: DepositPosition;
};