txmodels

package
v1.0.0-beta.41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const EstimatedInputSizeForP2PKH = 148

EstimatedInputSizeForP2PKH is the estimated size increase when adding and unlocking P2PKH input to transaction. 32 bytes txID + 4 bytes vout index + 1 byte script length + 107 bytes script pub key + 4 bytes nSequence

Variables

This section is empty.

Functions

This section is empty.

Types

type NewOperation

type NewOperation struct {
	UserID string

	Counterparty string
	Type         string
	Value        int64

	Transaction *NewTransaction
}

NewOperation is a data for creating a new operation.

func (*NewOperation) Add

func (o *NewOperation) Add(satoshi bsv.Satoshis)

Add adds satoshis to the operation.

func (*NewOperation) Subtract

func (o *NewOperation) Subtract(satoshi bsv.Satoshis)

Subtract subtracts satoshis from the operation.

type NewOutput

type NewOutput struct {
	UserID   string
	TxID     string
	Vout     uint32
	Satoshis bsv.Satoshis
	Bucket   string

	UTXO *SpendableUTXO

	Data []byte
}

NewOutput holds the data for creating a new output.

func NewOutputForData

func NewOutputForData(outpoint bsv.Outpoint, userID string, data []byte) NewOutput

NewOutputForData creates a new output for data.

func NewOutputForP2PKH

func NewOutputForP2PKH(outpoint bsv.Outpoint, userID string, satoshis bsv.Satoshis, customInstructions bsv.CustomInstructions) NewOutput

NewOutputForP2PKH creates a new output for P2PKH address.

type NewTransaction

type NewTransaction struct {
	ID       string
	TxStatus TxStatus

	Inputs  []TrackedOutput
	Outputs []NewOutput
}

NewTransaction is a data for creating a new transaction.

func (*NewTransaction) AddInputs

func (t *NewTransaction) AddInputs(tracked ...TrackedOutput)

AddInputs adds outpoints to spend in the transaction.

func (*NewTransaction) AddOutputs

func (t *NewTransaction) AddOutputs(output ...NewOutput)

AddOutputs adds list of NewOutput types to the transaction.

type RecordedOutline

type RecordedOutline struct {
	TxID string
}

RecordedOutline is a result of a transaction recording.

type SpendableUTXO

type SpendableUTXO struct {
	// EstimatedInputSize is the estimated size increase when adding and unlocking this UTXO to a transaction.
	EstimatedInputSize uint64

	// CustomInstructions is the list of instructions for unlocking given UTXO (it should be understood by client).
	CustomInstructions bsv.CustomInstructions
}

SpendableUTXO holds the data for spendable outputs.

type TrackedOutput

type TrackedOutput struct {
	TxID       string
	Vout       uint32
	SpendingTX string

	UserID string

	Satoshis bsv.Satoshis

	CreatedAt time.Time
	UpdatedAt time.Time
}

TrackedOutput represents an output of a transaction.

func (*TrackedOutput) IsSpent

func (o *TrackedOutput) IsSpent() bool

IsSpent returns true if the output is spent.

func (*TrackedOutput) Outpoint

func (o *TrackedOutput) Outpoint() *bsv.Outpoint

Outpoint returns bsv.Outpoint object which identifies the output.

type TxStatus

type TxStatus string

TxStatus represents possible statuses of stored transaction model

const (
	TxStatusCreated     TxStatus = "CREATED"
	TxStatusBroadcasted TxStatus = "BROADCASTED"
	TxStatusMined       TxStatus = "MINED"
	TxStatusReverted    TxStatus = "REVERTED"
	TxStatusProblematic TxStatus = "PROBLEMATIC"
)

List of transaction statuses

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL