Skip to content

Latest commit

 

History

History
561 lines (330 loc) · 13.7 KB

Transaction.md

File metadata and controls

561 lines (330 loc) · 13.7 KB

beignet / Transaction

Class: Transaction

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

• new Transaction(«destructured»)

Parameters

Name Type
«destructured» Object
› wallet Wallet

Defined in

transaction/index.ts:49

Properties

_data

• Private _data: ISendTransaction

Defined in

transaction/index.ts:46


_wallet

• Private Readonly _wallet: Wallet

Defined in

transaction/index.ts:47

Accessors

data

• get data(): ISendTransaction

Returns

ISendTransaction

Defined in

transaction/index.ts:54

Methods

addExternalInputs

▸ addExternalInputs(«destructured»): Result<IUtxo[]>

Adds external inputs to the current transaction.

Parameters

Name Type
«destructured» Object
› inputs IUtxo[]
› keyPair BIP32Interface | ECPairInterface

Returns

Result<IUtxo[]>

Defined in

transaction/index.ts:772


addInput

▸ addInput(«destructured»): Promise<Result<string>>

Parameters

Name Type
«destructured» IAddInput

Returns

Promise<Result<string>>

Defined in

transaction/index.ts:659


addOutput

▸ addOutput(«destructured»): Promise<Result<string>>

Adds an output at the specified index to the current transaction.

Parameters

Name Type
«destructured» IOutput

Returns

Promise<Result<string>>

Defined in

transaction/index.ts:821


createPsbtFromTransactionData

▸ createPsbtFromTransactionData(«destructured»): Promise<Result<Psbt>>

Returns a PSBT that includes unsigned funding inputs.

Parameters

Name Type
«destructured» Object
› bip32Interface? BIP32Interface
› shuffleTargets? boolean
› transactionData ISendTransaction

Returns

Promise<Result<Psbt>>

Defined in

transaction/index.ts:520


createTransaction

▸ createTransaction(«destructured»?): Promise<Result<{ hex: string ; id: string }>>

Creates complete signed transaction using the transaction data store

Parameters

Name Type
«destructured» ICreateTransaction

Returns

Promise<Result<{ hex: string ; id: string }>>

Defined in

transaction/index.ts:379


estimateTransactionCosts

▸ estimateTransactionCosts(«destructured»?): Result<{ amount: number ; fee: number ; satsPerByte: number }>

Calculates the max amount able to send for onchain/lightning

Parameters

Name Type
«destructured» Object
› customFeeRate? number
› transaction? ISendTransaction

Returns

Result<{ amount: number ; fee: number ; satsPerByte: number }>

Defined in

transaction/index.ts:1047


getMaxSatsPerByte

▸ getMaxSatsPerByte(«destructured»): number

Returns the maximum sats per byte that can be used for a given transaction.

Parameters

Name Type
«destructured» Object
› balance? number
› transactionByteCount number

Returns

number

Defined in

transaction/index.ts:363


getMaxSendAmount

▸ getMaxSendAmount(«destructured»): Result<{ amount: number ; fee: number }>

Calculates the max amount able to send for the provided/current onchain transaction.

Parameters

Name Type
«destructured» Object
› satsPerByte number
› selectedFeeId? EFeeId
› transaction? ISendTransaction

Returns

Result<{ amount: number ; fee: number }>

Defined in

transaction/index.ts:1114


getTotalFee

▸ getTotalFee(«destructured»?): number

Attempt to estimate the current fee for a given transaction and its UTXO's

Parameters

Name Type
«destructured» Object
› fundingLightning? boolean
› message? string
› satsPerByte number
› transaction? Partial<ISendTransaction>

Returns

number

Defined in

transaction/index.ts:215


getTotalFeeObj

▸ getTotalFeeObj(«destructured»?): Result<TGetTotalFeeObj>

Attempt to estimate the current fee for a given transaction and its UTXO's

Parameters

Name Type
«destructured» Object
› fundingLightning? boolean
› message? string
› satsPerByte? number
› transaction? Partial<ISendTransaction>

Returns

Result<TGetTotalFeeObj>

Defined in

transaction/index.ts:270


getTransactionInputValue

▸ getTransactionInputValue(inputs?): number

Returns total value of all utxos.

Parameters

Name Type
inputs? Object
inputs.inputs? IUtxo[]

Returns

number

Defined in

transaction/index.ts:448


getTransactionOutputValue

▸ getTransactionOutputValue(outputs?): number

Returns total value of all outputs. Excludes any value that would be sent to the change address.

Parameters

Name Type
outputs? Object
outputs.outputs? IOutput[]

Returns

number

Defined in

transaction/index.ts:845


removeBlackListedUtxos

▸ removeBlackListedUtxos(utxos?): IUtxo[]

Removes blacklisted UTXO's from the UTXO array.

Parameters

Name Type
utxos? IUtxo[]

Returns

IUtxo[]

Defined in

transaction/index.ts:191


resetSendTransaction

▸ resetSendTransaction(): Promise<Result<string>>

This completely resets the send transaction state.

Returns

Promise<Result<string>>

Defined in

transaction/index.ts:181


sendMax

▸ sendMax(«destructured»?): Promise<Result<string>>

Toggles the max amount to the provided output index.

Parameters

Name Type
«destructured» Object
› address? string
› index? number
› rbf? boolean
› satsPerByte? number
› transaction? ISendTransaction

Returns

Promise<Result<string>>

Defined in

transaction/index.ts:982


setupCpfp

▸ setupCpfp(«destructured»?): Promise<Result<ISendTransaction>>

Sets up a CPFP transaction.

Parameters

Name Type
«destructured» Object
› satsPerByte? number
› txid? string

Returns

Promise<Result<ISendTransaction>>

Defined in

transaction/index.ts:1165


setupTransaction

▸ setupTransaction(«destructured»?): Promise<TSetupTransactionResponse>

Sets up a transaction for a given wallet by gathering inputs, setting the next available change address as an output and sets up the baseline fee structure. This function will not override previously set transaction data. To do that you'll need to call resetSendTransaction.

Parameters

Name Type
«destructured» ISetupTransaction

Returns

Promise<TSetupTransactionResponse>

Defined in

transaction/index.ts:68


signPsbt

▸ signPsbt(«destructured»): Promise<Result<Psbt>>

Loops through inputs and signs them

Parameters

Name Type
«destructured» Object
› bip32Interface BIP32Interface
› psbt Psbt

Returns

Promise<Result<Psbt>>

Defined in

transaction/index.ts:472


updateFee

▸ updateFee(«destructured»?): Result<{ fee: number }>

Updates the fee for the current transaction by the specified amount.

Parameters

Name Type
«destructured» Object
› index? number
› satsPerByte number
› selectedFeeId? EFeeId
› transaction? ISendTransaction

Returns

Result<{ fee: number }>

Defined in

transaction/index.ts:908


updateSendTransaction

▸ updateSendTransaction(transaction): Result<string>

This updates the transaction state used for sending.

Parameters

Name Type
transaction Object
transaction.transaction Partial<ISendTransaction>

Returns

Result<string>

Defined in

transaction/index.ts:870