bitcoin

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTxVersion      = 2
	DefaultSequenceNum    = 0xfffffffd
	DefaultRevealOutValue = int64(546)
	DefaultMinChangeValue = int64(546)

	MaxStandardTxWeight = 4000000 / 10
	WitnessScaleFactor  = 4
)
View Source
const ErInsufficientBalance = "Insufficient Balance"
View Source
const SellerSignatureIndex = 1

Variables

View Source
var (
	TAG_BODY         = big.NewInt(0)
	TAG_Flags        = big.NewInt(2)
	TAG_Rune         = big.NewInt(4)
	TAG_Premine      = big.NewInt(6)
	TAG_Cap          = big.NewInt(8)
	TAG_Amount       = big.NewInt(10)
	TAG_HeightStart  = big.NewInt(12)
	TAG_HeightEnd    = big.NewInt(14)
	TAG_OffsetStart  = big.NewInt(16)
	TAG_OffsetEnd    = big.NewInt(118)
	TAG_Mint         = big.NewInt(20)
	TAG_Pointer      = big.NewInt(22)
	TAG_Cenotaph     = big.NewInt(126)
	TAG_Divisibility = big.NewInt(1)
	TAG_Spacers      = big.NewInt(3)
	TAG_Symbol       = big.NewInt(5)
	TAG_Nop          = big.NewInt(127)
)
View Source
var (
	ErrInvalidEdict = errors.New("ErrInvalidEdict")
)

Functions

func AddrToPkScript

func AddrToPkScript(addr string, network *chaincfg.Params) ([]byte, error)

func BuildMintL2Tx

func BuildMintL2Tx(txid string, vout uint32, amount int64, receiver, addr string, mintScript string, privateKey string, netParams *chaincfg.Params, feePerB int64, value int64) (*wire.MsgTx, error)

func BuildOpReturnData

func BuildOpReturnData(edicts Edicts, isDefaultOutput, mint bool, defaultOutput int64) ([]byte, error)

func BuildOpReturnDataJson

func BuildOpReturnDataJson(a []byte) ([]byte, error)

func BuildOpReturnScriptForEdict

func BuildOpReturnScriptForEdict(edicts []*Edict, isMainnet bool) ([]byte, error)

func BuildOpReturnScriptForRuneMainEdict

func BuildOpReturnScriptForRuneMainEdict(
	edicts []*Edict, isMainnet bool, isDefaultOutput bool, defaultOutput int64) ([]byte, error)

func CalculateMintTxFee

func CalculateMintTxFee(receiver string, addr string, mintScript string, privateKey string, netParams *chaincfg.Params, feePerB int64, value int64) (int64, int64, error)

func CheckOpReturnData

func CheckOpReturnData(data *OpReturnData) bool

todo

func EncodeToVec

func EncodeToVec(n *big.Int) []int64

func EncodeToVecV2

func EncodeToVecV2(n *big.Int, buf *bytes.Buffer)

func GenerateRunesSignedBuyingTx

func GenerateRunesSignedBuyingTx(ins []*TxInput, outs []*TxOutput, dustSize, feePerB int64, sellerPsbt []string, network *chaincfg.Params) (int64, string, error)

func GenerateRunesSignedListingPSBTBase64

func GenerateRunesSignedListingPSBTBase64(in *TxInput, out *TxOutput, network *chaincfg.Params) (string, error)

func Int64ToBytes

func Int64ToBytes(i int64) []byte

func PayToPubKeyHashScript

func PayToPubKeyHashScript(pubKeyHash []byte) ([]byte, error)

func PayToWitnessPubKeyHashScript

func PayToWitnessPubKeyHashScript(pubKeyHash []byte) ([]byte, error)

func Sign

func Sign(tx *wire.MsgTx, privateKeys []*btcec.PrivateKey, prevOutFetcher *txscript.MultiPrevOutFetcher) error

Types

type Edict

type Edict struct {
	Block  string `json:"block"`
	Id     string `json:"id"`
	Amount string `json:"amount"`
	Output uint   `json:"output"`
}

func (*Edict) Fix

func (v *Edict) Fix()

func (*Edict) RealEdict

func (v *Edict) RealEdict(mint bool) (*RealEdict, error)

type Edicts

type Edicts []*Edict

func (Edicts) Fix

func (v Edicts) Fix()

func (Edicts) RealEdicts

func (s Edicts) RealEdicts(mint bool) (RealEdicts, error)

type Etching

type Etching struct {
	Divisibility int64  `json:"divisibility"`
	Limit        string `json:"limit"`
	Rune         string `json:"rune"`
	Symbol       string `json:"symbol"`
	Term         int64  `json:"term"`
}

type InscribeTxs

type InscribeTxs struct {
	CommitTx     string   `json:"commitTx"`
	RevealTxs    []string `json:"revealTxs,omitempty"`
	CommitTxFee  int64    `json:"commitTxFee"`
	RevealTxFees []int64  `json:"revealTxFees,omitempty"`
	CommitAddrs  []string `json:"commitAddrs,omitempty"`
}

type InscriptionData

type InscriptionData struct {
	ContentType string `json:"contentType,omitempty"`
	Body        []byte `json:"body"`
	RevealAddr  string `json:"revealAddr,omitempty"`
	Vout        uint   `json:"vout"` // default 1
}

type InscriptionRequest

type InscriptionRequest struct {
	CommitTxPrevOutputList []*PrevOutput     `json:"commitTxPrevOutputList"`
	Outputs                []*Output         `json:"outputs"`
	CommitFeeRate          int64             `json:"commitFeeRate"`
	RevealFeeRate          int64             `json:"revealFeeRate"`
	InscriptionDataList    []InscriptionData `json:"inscriptionDataList"`
	RevealOutValue         int64             `json:"revealOutValue"`
	ChangeAddress          string            `json:"changeAddress"`
	MinChangeValue         int64             `json:"minChangeValue"`
	// contains filtered or unexported fields
}

type OpReturnData

type OpReturnData struct {
	Edicts          Edicts   `json:"edicts"`
	Etching         *Etching `json:"etching"`
	Burn            bool     `json:"burn"`
	IsDefaultOutput bool     `json:"isDefaultOutput"`
	DefaultOutput   int64    `json:"defaultOutput"`
	Mint            bool     `json:"mint"`
	MintNum         uint     `json:"mintNum"`
}

type Output

type Output struct {
	Address string `json:"address"`
	Amount  int64  `json:"amount"`
}

type PrevOutput

type PrevOutput struct {
	TxId       string `json:"txId"`
	VOut       uint32 `json:"vOut"`
	Amount     int64  `json:"amount"`
	Address    string `json:"address"`
	PrivateKey string `json:"privateKey"`
}

type PrevOutputs

type PrevOutputs []*PrevOutput

func (PrevOutputs) UtxoViewpoint

func (s PrevOutputs) UtxoViewpoint(net *chaincfg.Params) (bitcoin.UtxoViewpoint, error)

type RealEdict

type RealEdict struct {
	Block  *big.Int `json:"block"`
	Id     *big.Int `json:"id"`
	Amount *big.Int `json:"amount"`
	Output uint     `json:"output"`
}

type RealEdicts

type RealEdicts []*RealEdict

func (RealEdicts) Len

func (s RealEdicts) Len() int

func (RealEdicts) Less

func (s RealEdicts) Less(i, j int) bool

func (RealEdicts) Swap

func (s RealEdicts) Swap(i, j int)

type TxInput

type TxInput struct {
	TxId              string
	VOut              uint32
	Sequence          uint32
	Amount            int64
	Address           string
	PrivateKey        string
	NonWitnessUtxo    string
	MasterFingerprint uint32
	DerivationPath    string
	PublicKey         string
}

type TxOutput

type TxOutput struct {
	Address           string
	PkScript          string
	Amount            int64
	IsChange          bool
	MasterFingerprint uint32
	DerivationPath    string
	PublicKey         string
}

Jump to

Keyboard shortcuts

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