Documentation ¶
Overview ¶
Package mapi provides the API structures for the mAPI service
Index ¶
Constants ¶
const ( // FeeTypeData is the key corresponding to the data rate FeeTypeData = "data" // FeeTypeStandard is the key corresponding to the standard rate FeeTypeStandard = "standard" // FeeCategoryMining is the category corresponding to the mining rate FeeCategoryMining = "mining" // FeeCategoryRelay is the category corresponding to the relay rate FeeCategoryRelay = "relay" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct { APIVersion string `json:"apiVersion"` BlockHash string `json:"blockHash"` BlockHeight uint64 `json:"blockHeight"` CallbackPayload string `json:"callbackPayload"` CallbackReason string `json:"callbackReason"` CallbackTxID string `json:"callbackTxId"` MinerID string `json:"minerId"` Timestamp string `json:"timestamp"` }
Callback is the body contents posted to the provided callback url from Merchant API
type ConflictedWith ¶
type ConflictedWith struct { Hex string `json:"hex"` Size int `json:"size"` TxID string `json:"txid"` }
ConflictedWith contains the information about the transactions that conflict with the transaction submitted to mAPI. A conflict could arise if multiple transactions attempt to spend the same UTXO (double spend).
type FeeObj ¶
type FeeObj struct { FeeType string `json:"feeType"` // standard || data MiningFee FeeUnit `json:"miningFee"` RelayFee FeeUnit `json:"relayFee"` // Fee for retaining Tx in secondary mempool }
FeeObj displays the MiningFee as well as the RelayFee for a specific FeeType, for example 'standard' or 'data' see https://github.com/bitcoin-sv-specs/brfc-merchantapi#expanded-payload-1
type FeePayload ¶
type FeePayload struct { FeePayloadFields Fees []*bt.Fee `json:"fees"` }
FeePayload is the unmarshalled version of the payload envelope
func (*FeePayload) CalculateFee ¶
func (f *FeePayload) CalculateFee(feeCategory, feeType string, txBytes uint64) (uint64, error)
CalculateFee will return the fee for the given txBytes Type: "FeeTypeData" or "FeeTypeStandard" Category: "FeeCategoryMining" or "FeeCategoryRelay"
If no fee is found or fee is 0, returns 1 & error
func (*FeePayload) GetFee ¶
func (f *FeePayload) GetFee(feeType string) *bt.Fee
GetFee will return the fee associated to the type (standard, data)
type FeePayloadFields ¶
type FeePayloadFields struct { APIVersion string `json:"apiVersion"` Timestamp string `json:"timestamp"` ExpirationTime string `json:"expiryTime"` MinerID string `json:"minerId"` CurrentHighestBlockHash string `json:"currentHighestBlockHash"` CurrentHighestBlockHeight uint64 `json:"currentHighestBlockHeight"` MinerReputation interface{} `json:"minerReputation"` // Not sure what this value is }
FeePayloadFields are the same fields in both payloads
type FeeUnit ¶
type FeeUnit struct { Satoshis int `json:"satoshis"` // Fee in satoshis of the amount of Bytes Bytes int `json:"bytes"` // Number of bytes that the Fee covers }
FeeUnit displays the amount of Satoshis needed for a specific amount of Bytes in a transaction see https://github.com/bitcoin-sv-specs/brfc-merchantapi#expanded-payload-1
type Policy ¶
type Policy struct { AcceptNonStdOutputs bool `json:"acceptnonstdoutputs"` DataCarrier bool `json:"datacarrier"` DataCarrierSize uint32 `json:"datacarriersize"` LimitAncestorCount uint32 `json:"limitancestorcount"` LimitCpfpGroupMembersCount uint32 `json:"limitcpfpgroupmemberscount"` MaxNonStdTxValidationDuration uint32 `json:"maxnonstdtxvalidationduration"` MaxScriptNumLengthPolicy uint32 `json:"maxscriptnumlengthpolicy"` MaxScriptSizePolicy uint32 `json:"maxscriptsizepolicy"` MaxStackMemoryUsagePolicy uint64 `json:"maxstackmemoryusagepolicy"` MaxStdTxValidationDuration uint32 `json:"maxstdtxvalidationduration"` MaxTxSizePolicy uint32 `json:"maxtxsizepolicy"` SkipScriptFlags []ScriptFlag `json:"skipscriptflags"` MaxConsolidationFactor uint32 `json:"minconsolidationfactor"` MaxConsolidationInputScriptSize uint32 `json:"maxconsolidationinputscriptsize"` MinConfConsolidationInput uint32 `json:"minconfconsolidationinput"` AcceptNonStdConsolidationInput bool `json:"acceptnonstdconsolidationinput"` }
Policy is the unmarshalled version of the payload envelope
type PolicyCallback ¶
type PolicyCallback struct {
IPAddress string `json:"ipAddress"`
}
PolicyCallback is the callback address
type PolicyQuoteModel ¶
type PolicyQuoteModel struct { APIVersion string `json:"apiVersion"` Timestamp string `json:"timestamp"` ExpiryTime string `json:"expiryTime"` MinerID string `json:"minerId"` CurrentHighestBlockHash string `json:"currentHighestBlockHash"` CurrentHighestBlockHeight uint64 `json:"currentHighestBlockHeight"` Fees []FeeObj `json:"fees"` Callbacks []PolicyCallback `json:"callbacks"` Policies Policy `json:"policies"` }
PolicyQuoteModel is the unmarshalled version of the payload envelope
type QueryTxModel ¶
type QueryTxModel struct { APIVersion string `json:"apiVersion"` Timestamp string `json:"timestamp"` TxID string `json:"txid"` ReturnResult string `json:"returnResult"` ResultDescription string `json:"resultDescription"` BlockHash string `json:"blockHash"` BlockHeight int64 `json:"blockHeight"` MinerID string `json:"minerId"` Confirmations int64 `json:"confirmations"` TxSecondMempoolExpiry int64 `json:"txSecondMempoolExpiry"` MerkleProof *bc.MerkleProof `json:"merkleProof"` }
QueryTxModel is the unmarshalled version of the payload envelope
type RawFeePayload ¶
type RawFeePayload struct { FeePayloadFields Callbacks []*PolicyCallback `json:"callbacks"` // IP addresses of double-spend notification servers such as mAPI reference implementation Fees []*FeeObj `json:"fees"` }
RawFeePayload is the unmarshalled version of the payload envelope
type ScriptFlag ¶
type ScriptFlag string
ScriptFlag is a flag used in the policy quote
const ( // FlagCleanStack is the CLEANSTACK flag FlagCleanStack ScriptFlag = "CLEANSTACK" // FlagDerSig is the DERSIG flag FlagDerSig ScriptFlag = "DERSIG" // FlagDiscourageUpgradableNops is the DISCOURAGE_UPGRADABLE_NOPS flag FlagDiscourageUpgradableNops ScriptFlag = "DISCOURAGE_UPGRADABLE_NOPS" // FlagMinimalData is the MINIMALDATA flag FlagMinimalData ScriptFlag = "MINIMALDATA" // FlagNullDummy is the NULLDUMMY flag FlagNullDummy ScriptFlag = "NULLDUMMY" )
All known script flags
type SubmitTxModel ¶
type SubmitTxModel struct { // mAPI APIVersion string `json:"apiVersion"` ConflictedWith []*ConflictedWith `json:"conflictedWith"` CurrentHighestBlockHash string `json:"currentHighestBlockHash"` CurrentHighestBlockHeight int64 `json:"currentHighestBlockHeight"` MinerID string `json:"minerId"` ResultDescription string `json:"resultDescription"` ReturnResult string `json:"returnResult"` Timestamp string `json:"timestamp"` TxID string `json:"txid"` TxSecondMempoolExpiry int64 `json:"txSecondMempoolExpiry"` // FailureRetryable if true indicates the tx can be resubmitted to mAPI. FailureRetryable bool `json:"failureRetryable"` }
SubmitTxModel is the unmarshalled version of the payload envelope