txmodels

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 6 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
	// contains filtered or unexported fields
}

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.

func (*NewTransaction) BEEFHex

func (t *NewTransaction) BEEFHex() string

BEEFHex returns the BEEF-encoded hexadecimal representation of the transaction.

func (*NewTransaction) RawHex

func (t *NewTransaction) RawHex() string

RawHex returns the raw hexadecimal representation of the transaction.

func (*NewTransaction) SetBEEFHex

func (t *NewTransaction) SetBEEFHex(hex string)

SetBEEFHex sets the BEEF-encoded hexadecimal representation of the transaction.

func (*NewTransaction) SetRawHex

func (t *NewTransaction) SetRawHex(hex string, sourceTXIDs ...string)

SetRawHex sets the raw hexadecimal representation of the transaction and source transaction IDs.

func (*NewTransaction) TransactionInputSources

func (t *NewTransaction) TransactionInputSources() []TransactionInputSource

TransactionInputSources returns the list of input sources associated with 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 TrackedTransaction

type TrackedTransaction struct {
	ID       string
	TxStatus TxStatus

	CreatedAt time.Time
	UpdatedAt time.Time

	BlockHeight *int64
	BlockHash   *string

	BeefHex *string
	RawHex  *string
}

TrackedTransaction represents a transaction that is being tracked by the wallet.

func (*TrackedTransaction) Mined

func (tt *TrackedTransaction) Mined(blockHash string, bump *trx.MerklePath) error

Mined marks the transaction as mined with the given block hash and height, and the given bump.

func (*TrackedTransaction) TX

func (tt *TrackedTransaction) TX() (*trx.Transaction, error)

TX returns the transaction object for the tracked transaction based on the hex representation (either BEEF or raw).

type TransactionInputSource

type TransactionInputSource struct {
	// SourceTxID is the ID of the transaction that provided the input.
	SourceTxID string

	// TxID is the ID of the transaction that consumes the input.
	TxID string
}

TransactionInputSource represents a link between a transaction and its source transaction. It is used to track which transaction inputs originate from which previous transactions.

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