Documentation
¶
Index ¶
Constants ¶
const ( M3CommitmentHeader = 0xD45AA943 // M3 magic bytes (Propose Withdrawal) M4CommitmentHeader = 0xD77D1776 // M4 magic bytes (ACK Withdrawal) MinWorkScore = 13150 // Minimum ACKs for approval WithdrawalMaxAge = 26300 // ~6 months in blocks // Special vote values VoteAbstain = 0xFFFF VoteAlarm = 0xFFFE )
Constants from BIP300
Variables ¶
This section is empty.
Functions ¶
func EncodeVotePreferences ¶
func EncodeVotePreferences(prefs []VotePreference) []byte
EncodeVotePreferences creates M4 bytes from user's vote preferences
func IsM3Commitment ¶
IsM3Commitment checks if the script is an M3 commitment
func IsM4Commitment ¶
IsM4Commitment checks if the script is an M4 commitment
Types ¶
type BundleStatus ¶
type BundleStatus string
const ( BundleStatusPending BundleStatus = "pending" BundleStatusApproved BundleStatus = "approved" // >= 13,150 ACKs BundleStatusFailed BundleStatus = "failed" // < 13,150 and expired BundleStatusExpired BundleStatus = "expired" )
type M3Message ¶
type M3Message struct {
ID int64
BlockHeight uint32
BlockHash string
BlockTime time.Time
SidechainSlot uint8
BundleHash string // hex encoded
CreatedAt time.Time
}
M3Message represents a withdrawal bundle proposal
func ParseM3Bytes ¶
ParseM3Bytes parses raw M3 bytes from a coinbase OP_RETURN Format: OP_RETURN | 0xD45AA943 (4 bytes) | Bundle Hash (32 bytes) | Sidechain Slot (1 byte) Total: 38 bytes
type M4Message ¶
type M4Message struct {
ID int64
BlockHeight uint32
BlockHash string
BlockTime time.Time
RawBytes []byte
Version uint8
Votes []M4Vote
CreatedAt time.Time
}
M4Message represents a parsed M4 message from a block
func ParseM4Bytes ¶
ParseM4Bytes parses raw M4 bytes from a coinbase OP_RETURN Format: OP_RETURN | 0xD77D1776 (4 bytes) | Version (1 byte) | Upvote Vector (n bytes)
type M4Vote ¶
type M4Vote struct {
ID int64
M4MessageID int64
SidechainSlot uint8
VoteType VoteType
BundleHash *string // nil for abstain/alarm
BundleIndex *uint16 // nil for abstain/alarm
}
M4Vote represents a single sidechain vote within an M4
type Sidechain ¶
type Sidechain struct {
Slot uint8
Name string
Description string
Version string
ActivatedHeight *uint32
CreatedAt time.Time
}
Sidechain represents an active sidechain
type VotePreference ¶
type VotePreference struct {
SidechainSlot uint8
VoteType VoteType
BundleHash *string
UpdatedAt time.Time
}
VotePreference represents user's desired vote
type WithdrawalBundle ¶
type WithdrawalBundle struct {
ID int64
SidechainSlot uint8
BundleHash string // hex encoded
WorkScore uint16 // Current ACK count
BlocksLeft uint32 // Until expiration
MaxAge uint32 // Total blocks allowed
FirstSeenHeight uint32
LastUpdatedHeight uint32
Status BundleStatus
CreatedAt time.Time
UpdatedAt time.Time
}
WithdrawalBundle represents a pending withdrawal from a sidechain