memo

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	CodePrefix = 0x6d

	CodeTest              = 0x00
	CodeSetName           = 0x01
	CodePost              = 0x02
	CodeReply             = 0x03
	CodeLike              = 0x04
	CodeSetProfile        = 0x05
	CodeFollow            = 0x06
	CodeUnfollow          = 0x07
	CodeSetImageBaseUrl   = 0x08
	CodeAttachPicture     = 0x09
	CodeSetProfilePicture = 0x0a
	CodeRepost            = 0x0b
	CodeTopicMessage      = 0x0c
	CodeTopicFollow       = 0x0d
	CodeTopicUnfollow     = 0x0e

	CodePollCreate = 0x10
	CodePollOption = 0x13
	CodePollVote   = 0x14

	CodeMute   = 0x16
	CodeUnMute = 0x17

	CodeLinkRequest = 0x20
	CodeLinkAccept  = 0x21
	CodeLinkRevoke  = 0x22

	CodeSendMoney = 0x24

	CodeSetAlias = 0x26

	CodeSellTokenMake      = 0x30
	CodeSellTokenOffer     = 0x31
	CodeSellTokenSignature = 0x32

	CodeTokenPin = 0x35
)
View Source
const (
	CodePollTypeSingle = 0x01
	CodePollTypeMulti  = 0x02
	CodePollTypeRank   = 0x03
)
View Source
const (
	RejectReasonTooLongMempoolChain             = "too-long-mempool-chain"
	RejectReasonMandatoryScriptVerifyFlagFailed = "mandatory-script-verify-flag-failed (Operation not valid with the current stack size)"
	RejectReasonBadTxnsVinEmpty                 = "bad-txns-vin-empty"
	RejectReasonScriptsigNotPushonly            = "scriptsig-not-pushonly"
)
View Source
const (
	MaxFundAmount = 10000
	MinFundAmount = 1250

	MaxFaucetTransactionsDay  = 50
	MaxFaucetTransactionsHour = 15

	DesiredFaucetUtxoCount = 15
)
View Source
const (
	MaxPostSize         = 65000
	MaxReplySize        = 65000
	MaxTagMessageSize   = 65000
	MaxPollQuestionSize = 209
	MaxPollOptionSize   = 184
	MaxVoteCommentSize  = 184
	MaxSendSize         = 65000
	MaxFileSize         = 99000

	OldMaxPostSize       = 217
	OldMaxReplySize      = 184
	OldMaxTagMessageSize = 204
	OldMaxSendSize       = 194
)
View Source
const (
	PkHashLength     = 20
	ScriptHashLength = 20
	TxHashLength     = 32
	PubKeyLength     = 64
	LockHashLength   = TxHashLength
	AddressLength    = 25

	AddressStringLength = 35
	TxStringLength      = 64

	BlockHeaderLength = 80
)
View Source
const (
	MaxTxFee          int64 = 425
	OutputFeeP2PKH    int64 = 34
	OutputFeeP2SH     int64 = 32
	OutputBaseFee     int64 = 12
	OutputFeeOpReturn int64 = 20
	OutputOpDataFee   int64 = 3
	OutputValueSize   int64 = 8
	InputFeeP2PKH     int64 = 148
	BaseTxFee         int64 = 10

	FeeOpReturnSlpSend int64 = 72
	FeeOpReturnLike    int64 = 55
	FeeOpReturnVote    int64 = 55
	FeeOpReturnTopic   int64 = 23
	FeeOpReturnReply   int64 = 55

	FeeP2pkh1In1OutTx   = BaseTxFee + InputFeeP2PKH + OutputFeeP2PKH
	FeeP2pkh1In2OutTx   = BaseTxFee + InputFeeP2PKH + OutputFeeP2PKH*2
	Fee2In3OutSlpSendTx = BaseTxFee + InputFeeP2PKH*2 + OutputFeeP2PKH*3 + FeeOpReturnSlpSend
)

https://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending-legacy-non-segwit-p2pkh-p2sh

View Source
const (
	Int2Size = 2 // int16
	Int4Size = 4 // int32
	Int8Size = 8 // int64
)
View Source
const (
	StringP2pkh             = "p2pkh"
	StringP2sh              = "p2sh"
	StringP2pk              = "p2pk"
	StringReturn            = "return"
	StringMemoMessage       = "memo-message"
	StringMemoSetName       = "memo-set-name"
	StringMemoFollow        = "memo-follow"
	StringMemoUnfollow      = "memo-unfollow"
	StringMemoLike          = "memo-like"
	StringMemoReply         = "memo-reply"
	StringMemoSetProfile    = "memo-set-profile"
	StringMemoSetProfilePic = "memo-set-profile-pic"
	StringMemoSend          = "memo-send"
	StringMemoMute          = "memo-mute"
	StringMemoUnmute        = "memo-unmute"
	StringBitcom            = "bitcom"
	StringMemoTopicMessage  = "topic-message"
	StringMemoTopicFollow   = "topic-follow"
	StringMemoTopicUnfollow = "topic-unfollow"
	StringMemoPollQuestion  = "poll-question"
	StringMemoPollOption    = "poll-option"
	StringMemoPollVote      = "poll-vote"
	StringTokenCreate       = "token-create"
	StringTokenMint         = "token-mint"
	StringTokenSend         = "token-send"
	StringTokenSell         = "token-sell"
	StringTokenOffer        = "token-offer"
	StringTokenSignature    = "token-signature"
	StringTokenPin          = "token-pin"
	StringLinkRequest       = "link-request"
	StringLinkAccept        = "link-accept"
	StringLinkRevoke        = "link-revoke"
	StringSetAlias          = "set-alias"
	StringUnknown           = "unknown"
	StringNone              = "-"
)
View Source
const (
	SlpDefaultTokenType  = 0x01
	SlpNftGroupTokenType = 0x81
	SlpNftChildTokenType = 0x41

	SlpNftChildBatonVOut = 0x4c00

	SlpType1        = "Normal"
	SlpTypeNftGroup = "NFT Group"
	SlpTypeNftChild = "NFT Child"
)
View Source
const (
	InOutTypeInput              = 0x01
	InOutTypeTokenOutputSelf    = 0x02
	InOutTypeBitcoinOutputSelf  = 0x03
	InOutTypeTokenOutputP2pkh   = 0x04
	InOutTypeBitcoinOutputP2pkh = 0x05
	InOutTypeTokenOutputP2sh    = 0x06
	InOutTypeBitcoinOutputP2sh  = 0x07
)
View Source
const BeginningOfMemoHeight = 525000
View Source
const BeginningOfSellToken = 585000
View Source
const BeginningOfSlpHeight = 543000
View Source
const BsvForkHeight = 555766
View Source
const DustMinimumOutput int64 = 546
View Source
const FaucetMaxAncestors = 20
View Source
const MaxAncestors = 2000

Variables

View Source
var (
	PrefixSetName         = []byte{CodePrefix, CodeSetName}
	PrefixPost            = []byte{CodePrefix, CodePost}
	PrefixReply           = []byte{CodePrefix, CodeReply}
	PrefixLike            = []byte{CodePrefix, CodeLike}
	PrefixSetProfile      = []byte{CodePrefix, CodeSetProfile}
	PrefixFollow          = []byte{CodePrefix, CodeFollow}
	PrefixUnfollow        = []byte{CodePrefix, CodeUnfollow}
	PrefixSetImageBaseUrl = []byte{CodePrefix, CodeSetImageBaseUrl}
	PrefixAttachPicture   = []byte{CodePrefix, CodeAttachPicture}
	PrefixSetProfilePic   = []byte{CodePrefix, CodeSetProfilePicture}
	PrefixRepost          = []byte{CodePrefix, CodeRepost}
	PrefixTopicMessage    = []byte{CodePrefix, CodeTopicMessage}
	PrefixTopicFollow     = []byte{CodePrefix, CodeTopicFollow}
	PrefixTopicUnfollow   = []byte{CodePrefix, CodeTopicUnfollow}
	PrefixPollCreate      = []byte{CodePrefix, CodePollCreate}
	PrefixPollOption      = []byte{CodePrefix, CodePollOption}
	PrefixPollVote        = []byte{CodePrefix, CodePollVote}
	PrefixSendMoney       = []byte{CodePrefix, CodeSendMoney}
	PrefixMute            = []byte{CodePrefix, CodeMute}
	PrefixUnmute          = []byte{CodePrefix, CodeUnMute}

	PrefixLinkRequest = []byte{CodePrefix, CodeLinkRequest}
	PrefixLinkAccept  = []byte{CodePrefix, CodeLinkAccept}
	PrefixLinkRevoke  = []byte{CodePrefix, CodeLinkRevoke}
	PrefixSetAlias    = []byte{CodePrefix, CodeSetAlias}

	PrefixBitcom = []byte("19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut")

	PrefixSlp = append([]byte("SLP"), 0x00)

	PrefixSellTokenMake      = []byte{CodePrefix, CodeSellTokenMake}
	PrefixSellTokenOffer     = []byte{CodePrefix, CodeSellTokenOffer}
	PrefixSellTokenSignature = []byte{CodePrefix, CodeSellTokenSignature}
	PrefixTokenPin           = []byte{CodePrefix, CodeTokenPin}
)

Functions

func FreeTxFee

func FreeTxFee(outputs []*Output) int64

func GetAllCodes

func GetAllCodes() [][]byte

func GetBaseOpReturn

func GetBaseOpReturn() *txscript.ScriptBuilder

func GetBlockFromRaw

func GetBlockFromRaw(raw []byte) (*wire.MsgBlock, error)

func GetBlockFromTxs

func GetBlockFromTxs(txs []*wire.MsgTx, header *wire.BlockHeader) *wire.MsgBlock

func GetBlockHeaderFromRaw

func GetBlockHeaderFromRaw(raw []byte) (*wire.BlockHeader, error)

func GetDecimalValue

func GetDecimalValue(val float64, decimals uint8) float64

func GetGenesisTime

func GetGenesisTime() time.Time

func GetMaxSendForUTXOs

func GetMaxSendForUTXOs(utxos []UTXO) int64

func GetMaxSendFromCount

func GetMaxSendFromCount(totalValue int64, numInputs int) int64

func GetMaxSendLikeTip

func GetMaxSendLikeTip(totalValue int64, numInputs int) int64

func GetMaxSendVoteTip

func GetMaxSendVoteTip(totalValue int64, numInputs int) int64

func GetMaxSpendBuyTokens

func GetMaxSpendBuyTokens(totalValue int64, numInputs int) int64

func GetMaxSpendReply

func GetMaxSpendReply(totalValue int64, numInputs int) int64

func GetMaxSpendTopicMessage

func GetMaxSpendTopicMessage(totalValue int64, numInputs int) int64

func GetMemoCodes

func GetMemoCodes() [][]byte

func GetMsgFromRaw

func GetMsgFromRaw(raw []byte) (*wire.MsgTx, error)

func GetOutputSize

func GetOutputSize(script Script) (int64, error)

func GetRaw

func GetRaw(msg *wire.MsgTx) []byte

func GetRawBlock

func GetRawBlock(block wire.MsgBlock) []byte

func GetRawBlockHeader

func GetRawBlockHeader(blockHeader wire.BlockHeader) []byte

func GetSlpQuantity

func GetSlpQuantity(quantity uint64, decimals uint8) float64

func GetSlpQuantityInt

func GetSlpQuantityInt(quantity float64, decimals int) uint64

func GetSlpQuantityString

func GetSlpQuantityString(quantity uint64, decimals uint8) string

func HasCoinbase

func HasCoinbase(tx *wire.MsgTx) bool

func IsCoinbase

func IsCoinbase(prevHash []byte, prevIndex uint32) bool

func IsCoinbaseInput

func IsCoinbaseInput(in *wire.TxIn) bool

func IsFreeTx

func IsFreeTx(outputs []*Output) bool

func IsMemo

func IsMemo(prefix []byte) bool

func IsOfOutputType

func IsOfOutputType(item OutputType, acceptable []OutputType) bool

func IsSpendable

func IsSpendable(balance int64) bool

func IsSpendableTokenPin

func IsSpendableTokenPin(balance int64) bool

func SetChain

func SetChain(chain string)

func SlpTypeByteString

func SlpTypeByteString(slpType byte) string

func SlpTypeString

func SlpTypeString(tokenType uint16) string

Types

type InOut

type InOut struct {
	Hash      []byte
	Index     uint32
	PrevHash  []byte
	PrevIndex uint32
}

type Out

type Out struct {
	TxHash   []byte
	Index    uint32
	Value    int64
	PkScript []byte
	LockHash []byte
}

type Output

type Output struct {
	Amount int64
	Script Script
}

func (Output) GetPkScript

func (o Output) GetPkScript() ([]byte, error)

func (Output) GetType

func (o Output) GetType() OutputType

func (Output) GetValuePlusFee

func (o Output) GetValuePlusFee() (int64, error)

type OutputType

type OutputType uint
const (
	OutputTypeP2PKH OutputType = iota
	OutputTypeP2SH
	OutputTypeP2PK
	OutputTypeReturn
	OutputTypeMemoMessage
	OutputTypeMemoSetName
	OutputTypeMemoFollow
	OutputTypeMemoUnfollow
	OutputTypeMemoLike
	OutputTypeMemoReply
	OutputTypeMemoSetProfile
	OutputTypeMemoTopicMessage
	OutputTypeMemoTopicFollow
	OutputTypeMemoTopicUnfollow
	OutputTypeMemoPollQuestionSingle
	OutputTypeMemoPollQuestionMulti
	OutputTypeMemoPollOption
	OutputTypeMemoPollVote
	OutputTypeMemoSetProfilePic
	OutputTypeMemoSend
	OutputTypeBitcom
	OutputTypeTokenCreate
	OutputTypeTokenCreateNftGroup
	OutputTypeTokenCreateNftChild
	OutputTypeTokenMint
	OutputTypeTokenMintNftGroup
	OutputTypeTokenSend
	OutputTypeTokenSendNftGroup
	OutputTypeTokenSendNftChild
	OutputTypeTokenSell
	OutputTypeTokenOffer
	OutputTypeTokenSignature
	OutputTypeMemoMute
	OutputTypeMemoUnMute
	OutputTypeTokenPin
	OutputTypeLinkRequest
	OutputTypeLinkAccept
	OutputTypeLinkRevoke
	OutputTypeSetAlias
	OutputTypeUnknown
	OutputTypeNone
)

func GetOutputType

func GetOutputType(pkScript []byte) OutputType

func GetOutputTypeNew

func GetOutputTypeNew(pkScript []byte) OutputType

func (OutputType) String

func (s OutputType) String() string

type PollType

type PollType string
const (
	PollTypeOne  PollType = "one"
	PollTypeAny  PollType = "any"
	PollTypeRank PollType = "rank"
)

type Script

type Script interface {
	Get() ([]byte, error)
	Type() OutputType
}

type ScriptHasher

type ScriptHasher struct {
	Tx wire.MsgTx

	SigHashes []*SigHash
	// contains filtered or unexported fields
}

func NewScriptHasher

func NewScriptHasher(tx *wire.MsgTx) *ScriptHasher

func (*ScriptHasher) Add

func (h *ScriptHasher) Add(pkScript []byte, hashType txscript.SigHashType, idx int, amt int64) error

type SigHash

type SigHash struct {
	BVersion       [4]byte
	HashPrevOuts   []byte
	HashSequence   []byte
	OutPointHash   []byte
	OutPointIndex  [4]byte
	InputSubScript []byte
	BAmount        [8]byte
	BSequence      [4]byte
	HashOutputs    []byte
	BLockTime      [4]byte
	BHashType      [4]byte
}

func (SigHash) Get

func (h SigHash) Get() []byte

func (SigHash) GetCombined

func (h SigHash) GetCombined() []byte

func (SigHash) GetPrefix

func (h SigHash) GetPrefix() []byte

func (SigHash) GetSuffix

func (h SigHash) GetSuffix() []byte

func (SigHash) OutputEach

func (h SigHash) OutputEach()

type SlpOut

type SlpOut struct {
	Out
	Token    []byte
	Quantity uint64
	PkHash   []byte
}

type SlpType

type SlpType string
const (
	SlpTxTypeGenesis SlpType = "GENESIS"
	SlpTxTypeMint    SlpType = "MINT"
	SlpTxTypeSend    SlpType = "SEND"
	SlpTxTypeCommit  SlpType = "COMMIT"

	SlpMintTokenIndex = 1
)

type Tx

type Tx struct {
	SelfPkHash  []byte
	MsgTx       *wire.MsgTx
	Inputs      []*TxInput
	Outputs     []*Output
	OpReturn    *Output
	AncestorsNC uint
}

func (Tx) GetHash

func (tx Tx) GetHash() []byte

func (Tx) GetType

func (tx Tx) GetType() OutputType

type TxInput

type TxInput struct {
	PkScript     []byte
	PkHash       []byte
	Value        int64
	PrevOutHash  []byte
	PrevOutIndex uint32
}

func (TxInput) GetDisasmString

func (t TxInput) GetDisasmString() string

func (TxInput) GetHashIndexString

func (t TxInput) GetHashIndexString() string

type UTXO

type UTXO struct {
	Input       TxInput
	SlpToken    []byte
	SlpQuantity uint64
	SlpType     SlpType
	SellTxHash  []byte
	AncestorsNC uint // Ancestors not confirmed
}

func GetNonPointerUtxos

func GetNonPointerUtxos(utxos []*UTXO) []UTXO

func (UTXO) AtAncestorLimit

func (u UTXO) AtAncestorLimit() bool

func (UTXO) IsEqual

func (u UTXO) IsEqual(u2 UTXO) bool

func (UTXO) IsPrevOutSet

func (u UTXO) IsPrevOutSet() bool

func (UTXO) IsSellTokenInput

func (u UTXO) IsSellTokenInput() bool

func (UTXO) IsSlp

func (u UTXO) IsSlp() bool

type UTXORequest

type UTXORequest struct {
	TokenHash []byte
	Baton     bool
}

func (UTXORequest) GetHashString

func (r UTXORequest) GetHashString() string

Jump to

Keyboard shortcuts

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