Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateTxFee(tx *wire.MsgTx, feeRate int64) int64
- func InscriptionToScript(internalKey *btcec.PublicKey, header Header, body util.Protocol) ([]byte, error)
- func RevealScriptAddress(internalKey *btcec.PublicKey, revealScript []byte) (controlBlock *txscript2.ControlBlock, taprootAddress *btcutil.AddressTaproot, ...)
- func WithCInsDescription(cInsDescription *tables.CInsDescription) func(*options)
- func WithCborMetadata(cborMetadata string) func(*options)
- func WithIndexer(indexer indexer.IndexerInterface) func(*options)
- func WithJsonMetadata(jsonMetadata string) func(*options)
- func WithPostage(postage uint64) func(*options)
- func WithWalletClient(cli *rpcclient.Client) func(*options)
- func WithWalletPass(pass string) func(*options)
- type Header
- type Inscription
- func (i *Inscription) BuildCommitTx() error
- func (i *Inscription) BuildRevealTx() error
- func (i *Inscription) CommitTxId() string
- func (i *Inscription) CreateInscriptionTx() error
- func (i *Inscription) Data() []byte
- func (i *Inscription) RevealTxId() string
- func (i *Inscription) SignCommitTx() error
- func (i *Inscription) SignRevealTx() error
- func (i *Inscription) Wallet() *rpcclient.Client
- type Option
- type Output
Constants ¶
const ( DefaultTestNet3IndexerUrl = "http://localhost:18335" DefaultMainNetIndexerUrl = "http://localhost:8335" )
Variables ¶
var Cmd = &cobra.Command{ Use: "inscribe", Short: "inscription casting", Run: func(cmd *cobra.Command, args []string) { if err := inscribe(); err != nil { fmt.Println(err) os.Exit(1) } signal.SimulateInterrupt() <-signal.InterruptHandlersDone }, }
Cmd is a cobra command that runs the inscribe function when executed. It also handles any errors returned by the inscribe function.
var InsufficientBalanceError = errors.New("InsufficientBalanceError")
InsufficientBalanceError is an error that represents an insufficient balance.
Functions ¶
func CalculateTxFee ¶
CalculateTxFee is a function that calculates the transaction fee for a given transaction and fee rate. It first calculates the weight of the transaction, then calculates the fee based on the weight and fee rate. If the calculated fee is less than the dust limit, it sets the fee to the dust limit. It returns the calculated fee.
func InscriptionToScript ¶
func InscriptionToScript( internalKey *btcec.PublicKey, header Header, body util.Protocol, ) ([]byte, error)
InscriptionToScript is a method of the Inscription struct. It is responsible for appending the reveal script to the script builder. It adds the protocol ID, content type, metadata, content encoding, and body to the script builder. It returns an error if there is an error in any of the steps.
func RevealScriptAddress ¶
func RevealScriptAddress(internalKey *btcec.PublicKey, revealScript []byte) ( controlBlock *txscript2.ControlBlock, taprootAddress *btcutil.AddressTaproot, err error)
RevealScriptAddress is a method of the Inscription struct. It is responsible for generating the reveal script address. It creates a control block, a leaf node, a tap script, and an output key. It then generates the taproot address from the output key. It returns an error if there is an error in any of the steps.
func WithCInsDescription ¶
func WithCInsDescription(cInsDescription *tables.CInsDescription) func(*options)
WithCInsDescription is a function that sets the destination chain option for an Inscription. It takes a string representing the destination chain and returns a function that sets the destination chain in the options of an Inscription.
func WithCborMetadata ¶
func WithCborMetadata(cborMetadata string) func(*options)
WithCborMetadata is a function that sets the CBOR metadata option for an Inscription. It takes a string representing the CBOR metadata and returns a function that sets the CBOR metadata in the options of an Inscription.
func WithIndexer ¶
func WithIndexer(indexer indexer.IndexerInterface) func(*options)
func WithJsonMetadata ¶
func WithJsonMetadata(jsonMetadata string) func(*options)
WithJsonMetadata is a function that sets the JSON metadata option for an Inscription. It takes a string representing the JSON metadata and returns a function that sets the JSON metadata in the options of an Inscription.
func WithPostage ¶
func WithPostage(postage uint64) func(*options)
WithPostage is a function that sets the postage option for an Inscription. It takes an uint64 value representing the postage and returns a function that sets the postage in the options of an Inscription.
func WithWalletClient ¶
WithWalletClient is a function that sets the wallet client option for an Inscription. It takes a pointer to a rpcclient.Client representing the wallet client and returns a function that sets the wallet client in the options of an Inscription.
func WithWalletPass ¶
func WithWalletPass(pass string) func(*options)
WithWalletPass is a function that sets the wallet password option for an Inscription. It takes a string representing the wallet password and returns a function that sets the wallet password in the options of an Inscription.
Types ¶
type Header ¶
type Header struct { // CInsDescription is the destination chain for the inscription. CInsDescription *tables.CInsDescription `json:"c_ins_description"` // ContentType is the content type of the inscription. ContentType constants.ContentType `json:"content_type"` // ContentEncoding is the encoding of the content of the inscription. ContentEncoding string `json:"content_encoding"` // Pointer is the pointer to the content of the inscription. Pointer string `json:"pointer"` // Metadata is the metadata of the inscription. Metadata *util.Reader `json:"metadata"` }
Header is a struct that represents the header of an inscription. It contains the destination chain, the content type, the content encoding, the pointer, and the metadata.
type Inscription ¶
type Inscription struct { // Header is the header of the inscription. Header Header // Body is the protocol of the body of the inscription. Body util.Protocol // contains filtered or unexported fields }
Inscription is a struct that represents an inscription in the blockchain. It contains the body of the inscription, the header, the body protocol, the options for the inscription, the transaction outputs, the commit and reveal transactions, the private and internal keys, the reveal script, the tap leaf node, the control block, the script builder, and the reveal transaction address.
func NewFromData ¶
func NewFromPath ¶
func NewFromPath(path string, inputOpts ...Option) (*Inscription, error)
NewFromPath is a function that creates a new Inscription from a given path. It takes a string representing the path and a variadic number of Option functions to set the options for the Inscription. It validates the options, sets the options in the Inscription, parses the CBOR and JSON metadata, sets the content type and content encoding, and sets the body of the Inscription. It returns a pointer to the created Inscription and any error that occurred during the process.
func (*Inscription) BuildCommitTx ¶
func (i *Inscription) BuildCommitTx() error
BuildCommitTx is a method of the Inscription struct. It is responsible for building the commit transaction of the Inscription. It initializes the total input and output amounts, creates the transaction inputs and outputs, calculates the change, creates the change output, and clears the input scripts for the transaction. It returns an error if there is an error in any of the steps.
func (*Inscription) BuildRevealTx ¶
func (i *Inscription) BuildRevealTx() error
BuildRevealTx is a method of the Inscription struct. It is responsible for building the reveal transaction of the Inscription. It generates a temporary key, builds the reveal script, creates the reveal transaction, and clears the input scripts for the transaction. It returns an error if there is an error in any of the steps.
func (*Inscription) CommitTxId ¶
func (i *Inscription) CommitTxId() string
CommitTxId is a method of the Inscription struct. It returns the transaction ID of the commit transaction of the Inscription.
func (*Inscription) CreateInscriptionTx ¶
func (i *Inscription) CreateInscriptionTx() error
CreateInscriptionTx is a method of the Inscription struct. It is responsible for creating the inscription transaction of the Inscription. It estimates the fee rate, generates a temporary private key, builds the reveal transaction, and builds the commit transaction. It returns an error if there is an error in any of the steps.
func (*Inscription) Data ¶
func (i *Inscription) Data() []byte
Data is a method of the Inscription struct. It returns the body of the inscription.
func (*Inscription) RevealTxId ¶
func (i *Inscription) RevealTxId() string
RevealTxId is a method of the Inscription struct. It returns the transaction ID of the reveal transaction of the Inscription.
func (*Inscription) SignCommitTx ¶
func (i *Inscription) SignCommitTx() error
SignCommitTx is a method of the Inscription struct. It is responsible for signing the commit transaction of the Inscription. It unlocks the wallet, fetches the private keys for the transaction inputs, calculates the signature hashes, and signs the transaction inputs. It returns an error if there is an error in any of the steps.
func (*Inscription) SignRevealTx ¶
func (i *Inscription) SignRevealTx() error
SignRevealTx is a method of the Inscription struct. It is responsible for signing the reveal transaction of the Inscription. It sets the previous outpoint of the reveal transaction input, calculates the signature hash, and signs the reveal transaction input. It returns an error if there is an error in any of the steps.
func (*Inscription) Wallet ¶
func (i *Inscription) Wallet() *rpcclient.Client
Wallet is a method of the Inscription struct. It returns the wallet client of the Inscription.