ord

package
v0.0.0-...-73b4c3b Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxStandardTxWeight = blockchain.MaxBlockWeight / 10
)

Variables

This section is empty.

Functions

func BuildInscriptionWitness

func BuildInscriptionWitness(datas []InscriptionData, privateKey *btcec.PrivateKey, revealOutValue int64) ([]byte, error)

func DecodeTxFromHex

func DecodeTxFromHex(txHex string) (*wire.MsgTx, error)

func EncodeTxToHex

func EncodeTxToHex(tx *wire.MsgTx) (string, error)

func GetRevealOutValue

func GetRevealOutValue(revealOutValue int64) int64

func GetSatBytes

func GetSatBytes(decimalNum int64) ([]byte, error)

func GetServiceFee

func GetServiceFee(inscAmount int64) int64

func SendRawTransaction

func SendRawTransaction(client *BlockchainClient, tx *wire.MsgTx) (*chainhash.Hash, error)

func VerifySign

func VerifySign(signature []byte, hash []byte, pubKey *btcec.PublicKey) (bool, error)

Types

type BlockchainClient

type BlockchainClient struct {
	RpcClient    *rpcclient.Client
	BtcApiClient btcapi.Client
}

type Info

type Info struct {
	PayAddr       string
	PayPrivateKey string
	InscribeFee   int64
	ServiceFee    int64
	MinerFee      int64
}

type InscribeTool

type InscribeTool interface {
	GetPayAddrAndFee(request *InscriptionRequest) (payAddr, payAddrPK string, inscFee, serviceFee, minerFee int64, err error)
	Inscribe(commitTxHash string, actualMiddlePrevOutputFee int64, payAddrPK string, request *InscriptionRequest) (ctxTxData *CtxTxData, err error)
}

type InscribeTxBase

type InscribeTxBase struct {
	FeeRate        int64
	RevealOutValue int64
}

type InscribeTxDetail

type InscribeTxDetail struct {
	InscribeTxPrevOutput
	Tx                       *wire.MsgTx
	Destination              string
	InscriptionWitnessScript []byte
	CommitTxPkScript         []byte
	CommitTxAddress          btcutil.Address
	PrivateKey               *btcec.PrivateKey
	ControlBlockWitness      []byte
	RecoveryPrivateKeyWIF    string
}

type InscribeTxPrevOutput

type InscribeTxPrevOutput struct {
	RevealTxPrevOutput *wire.TxOut
	MiddleTxPrevOutput *wire.TxOut
}

type InscribeTxPreview

type InscribeTxPreview struct {
	InscribeTxPrevOutput

	Destination              string
	InscriptionWitnessScript []byte
	CommitTxPkScript         []byte
	CommitTxAddress          btcutil.Address
	PrivateKey               *btcec.PrivateKey
	ControlBlockWitness      []byte
	RecoveryPrivateKeyWIF    string
}

type InscribeTxsPreview

type InscribeTxsPreview struct {
	InscribeTxBase
	Destination string
	Previews    []InscribeTxPreview
}

type InscriptionData

type InscriptionData struct {
	ContentType string
	Body        []byte
	Destination string

	// extra data
	MetaProtocol string
}

type InscriptionRawTx

type InscriptionRawTx struct {
	TxPrevOutput   *wire.TxOut
	WitnessScript  *InscriptionWitness
	Size           int64
	Raw            *wire.MsgTx
	RevealOutValue int64
	FeeRate        int64
	PrivateKey     *btcec.PrivateKey
}

func NewInscriptionRawTx

func NewInscriptionRawTx() *InscriptionRawTx

func (*InscriptionRawTx) CalcPrevOutput

func (irt *InscriptionRawTx) CalcPrevOutput(revealOutValue, feeRate int64) int64

func (*InscriptionRawTx) SetSize

func (irt *InscriptionRawTx) SetSize(txSize int64)

func (*InscriptionRawTx) SetTxPrevOutput

func (irt *InscriptionRawTx) SetTxPrevOutput(pkScript []byte, prevOutput int64)

func (*InscriptionRawTx) SetWitnessScript

func (irt *InscriptionRawTx) SetWitnessScript(inscriptionWitnessScript []byte)

type InscriptionRequest

type InscriptionRequest struct {
	// a local signature is required for committing the commit tx.
	// Currently, CommitTxPrivateKeyList[i] sign CommitTxOutPointList[i]
	CommitFeeRate  int64 // note: 给矿工的手续费率,在构建commit tx时使用
	FeeRate        int64 // note: 交易费率,相当于gas price
	DataList       []InscriptionData
	RevealOutValue int64
	PrivateKey     string
}

type InscriptionWitness

type InscriptionWitness struct {
	SignatureWitness    []byte
	InsWitnessScript    []byte
	ControlBlockWitness []byte
}

func NewInscriptionWitness

func NewInscriptionWitness() *InscriptionWitness

type StandardInscriber

type StandardInscriber struct {
	// contains filtered or unexported fields
}

func NewInscribeTool

func NewInscribeTool(net *chaincfg.Params, rpcclient *rpcclient.Client, serviceFeeReceiveAddr string) (*StandardInscriber, error)

func NewInscribeToolWithBtcApiClient

func NewInscribeToolWithBtcApiClient(net *chaincfg.Params, rpcClient *rpcclient.Client, serviceFeeReceiveAddr string) (*StandardInscriber, error)

func (*StandardInscriber) AddInOutToTx

func (ins *StandardInscriber) AddInOutToTx(tx *wire.MsgTx, index int, destination string, revealOutValue int64) error

func (*StandardInscriber) Init

func (*StandardInscriber) InitAllRevealTx

func (ins *StandardInscriber) InitAllRevealTx(dataList []InscriptionData, revealOutValue int64) ([]*InscriptionRawTx, error)

InitAllRevealTx middle tx is a special reveal tx

func (*StandardInscriber) InitAllScript

func (ins *StandardInscriber) InitAllScript(rawTxs []*InscriptionRawTx) ([]*InscribeTxPreview, error)

func (*StandardInscriber) InitAllWitness

func (ins *StandardInscriber) InitAllWitness(dataList []InscriptionData, privateKeyList []*btcec.PrivateKey) ([]*InscriptionWitness, error)

func (*StandardInscriber) InitEmptyMiddleTx

func (ins *StandardInscriber) InitEmptyMiddleTx(txs []*InscriptionRawTx, totalRevealPrevOutput int64, revealOutValue, feeRate, inscAmount int64) (totalPrevOutput, serviceFee, minerFee int64, err error)

InitEmptyMiddleTx : 构造middleTx: 连接commit tx和(除了第一笔)reveal tx的中间tx: 包含reveal tx1 + commit tx2... + 手续费 + 找零

func (*StandardInscriber) InitPrevOutputFetcher

func (ins *StandardInscriber) InitPrevOutputFetcher()

func (*StandardInscriber) InitPrivateKeys

func (ins *StandardInscriber) InitPrivateKeys(size int, payPrivateKey string) ([]*btcec.PrivateKey, error)

func (*StandardInscriber) InitScript

func (ins *StandardInscriber) InitScript(tx *InscriptionRawTx) (*InscribeTxPreview, error)

Jump to

Keyboard shortcuts

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