bitcoin

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package bitcoin provides Bitcoin wallet functionality for the bridge chain

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetUTXOs(ctx context.Context, address string) ([]*utxo.UTXO, error)
	BroadcastTransaction(ctx context.Context, txHex string) (string, error)
	GetTransaction(ctx context.Context, txID string) (*Transaction, error)
}

Client defines the interface for interacting with a Bitcoin node

type Input

type Input struct {
	PreviousTxID ids.ID
	OutputIndex  uint32
	ScriptSig    []byte
	Sequence     uint32
}

Input represents a transaction input

type Output

type Output struct {
	Value        int64
	ScriptPubKey []byte
}

Output represents a transaction output

type SignedTransaction

type SignedTransaction struct {
	Transaction
	Witnesses [][]byte
}

SignedTransaction represents a signed Bitcoin transaction

type Transaction

type Transaction struct {
	Version  int32
	Inputs   []Input
	Outputs  []Output
	Locktime uint32
}

Transaction represents an unsigned Bitcoin transaction

type Wallet

type Wallet interface {
	// GetAddress returns the Bitcoin address for this wallet
	GetAddress() string

	// GetBalance returns the balance for a specific asset (BTC)
	GetBalance(ctx context.Context) (*big.Int, error)

	// CreateTransaction creates a new Bitcoin transaction
	CreateTransaction(ctx context.Context, to string, amount *big.Int) (*Transaction, error)

	// SignTransaction signs a transaction
	SignTransaction(ctx context.Context, tx *Transaction) (*SignedTransaction, error)

	// BroadcastTransaction broadcasts a signed transaction
	BroadcastTransaction(ctx context.Context, tx *SignedTransaction) (ids.ID, error)
}

Wallet provides Bitcoin wallet functionality

func NewWallet

func NewWallet(privateKey *ecdsa.PrivateKey, client Client) (Wallet, error)

NewWallet creates a new Bitcoin wallet

Jump to

Keyboard shortcuts

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