ledger

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 4 Imported by: 4

README

go-cardano-ledger

Go library for the Cardano Ledger

Documentation

Index

Constants

View Source
const (
	BLOCK_TYPE_ALLEGRA = 3

	BLOCK_HEADER_TYPE_ALLEGRA = 2

	TX_TYPE_ALLEGRA = 2
)
View Source
const (
	BLOCK_TYPE_ALONZO = 5

	BLOCK_HEADER_TYPE_ALONZO = 4

	TX_TYPE_ALONZO = 4
)
View Source
const (
	BLOCK_TYPE_BABBAGE = 6

	BLOCK_HEADER_TYPE_BABBAGE = 5

	TX_TYPE_BABBAGE = 5
)
View Source
const (
	BLOCK_TYPE_BYRON_EBB  = 0
	BLOCK_TYPE_BYRON_MAIN = 1

	BLOCK_HEADER_TYPE_BYRON = 0

	TX_TYPE_BYRON = 0
)
View Source
const (
	BLOCK_TYPE_MARY = 4

	BLOCK_HEADER_TYPE_MARY = 3

	TX_TYPE_MARY = 3
)
View Source
const (
	BLOCK_TYPE_SHELLEY = 2

	BLOCK_HEADER_TYPE_SHELLEY = 1

	TX_TYPE_SHELLEY = 1
)

Variables

This section is empty.

Functions

func NewBlockFromCbor

func NewBlockFromCbor(blockType uint, data []byte) (interface{}, error)

func NewBlockHeaderFromCbor

func NewBlockHeaderFromCbor(blockType uint, data []byte) (interface{}, error)

XXX: should this take the block header type instead?

func NewTransactionBodyFromCbor added in v0.2.0

func NewTransactionBodyFromCbor(txType uint, data []byte) (interface{}, error)

func NewTransactionFromCbor

func NewTransactionFromCbor(txType uint, data []byte) (interface{}, error)

Types

type AllegraBlock

type AllegraBlock struct {
	Header                 ShelleyBlockHeader
	TransactionBodies      []AllegraTransactionBody
	TransactionWitnessSets []ShelleyTransactionWitnessSet
	// TODO: figure out how to parse properly
	// We use RawMessage here because the content is arbitrary and can contain data that
	// cannot easily be represented in Go (such as maps with bytestring keys)
	TransactionMetadataSet map[uint]cbor.RawMessage
	// contains filtered or unexported fields
}

func NewAllegraBlockFromCbor

func NewAllegraBlockFromCbor(data []byte) (*AllegraBlock, error)

func (*AllegraBlock) Id

func (b *AllegraBlock) Id() string

type AllegraTransaction

type AllegraTransaction struct {
	Body       AllegraTransactionBody
	WitnessSet ShelleyTransactionWitnessSet
	Metadata   interface{}
}

func NewAllegraTransactionFromCbor

func NewAllegraTransactionFromCbor(data []byte) (*AllegraTransaction, error)

type AllegraTransactionBody added in v0.2.0

type AllegraTransactionBody struct {
	ShelleyTransactionBody
	ValidityIntervalStart uint64 `cbor:"8,keyasint,omitempty"`
}

func NewAllegraTransactionBodyFromCbor added in v0.2.0

func NewAllegraTransactionBodyFromCbor(data []byte) (*AllegraTransactionBody, error)

type AlonzoBlock

type AlonzoBlock struct {
	Header                 ShelleyBlockHeader
	TransactionBodies      []AlonzoTransactionBody
	TransactionWitnessSets []AlonzoTransactionWitnessSet
	// TODO: figure out how to parse properly
	// We use RawMessage here because the content is arbitrary and can contain data that
	// cannot easily be represented in Go (such as maps with bytestring keys)
	TransactionMetadataSet map[uint]cbor.RawMessage
	InvalidTransactions    []uint
	// contains filtered or unexported fields
}

func NewAlonzoBlockFromCbor

func NewAlonzoBlockFromCbor(data []byte) (*AlonzoBlock, error)

func (*AlonzoBlock) Id

func (b *AlonzoBlock) Id() string

type AlonzoTransaction

type AlonzoTransaction struct {
	Body       AlonzoTransactionBody
	WitnessSet AlonzoTransactionWitnessSet
	IsValid    bool
	Metadata   interface{}
}

func NewAlonzoTransactionFromCbor

func NewAlonzoTransactionFromCbor(data []byte) (*AlonzoTransaction, error)

type AlonzoTransactionBody added in v0.2.0

type AlonzoTransactionBody struct {
	MaryTransactionBody
	ScriptDataHash  Blake2b256                `cbor:"11,keyasint,omitempty"`
	Collateral      []ShelleyTransactionInput `cbor:"13,keyasint,omitempty"`
	RequiredSigners []Blake2b224              `cbor:"14,keyasint,omitempty"`
	NetworkId       uint8                     `cbor:"15,keyasint,omitempty"`
}

func NewAlonzoTransactionBodyFromCbor added in v0.2.0

func NewAlonzoTransactionBodyFromCbor(data []byte) (*AlonzoTransactionBody, error)

type AlonzoTransactionWitnessSet

type AlonzoTransactionWitnessSet struct {
	ShelleyTransactionWitnessSet
	PlutusScripts interface{} `cbor:"3,keyasint,omitempty"`
	// TODO: figure out how to parse properly
	// We use RawMessage here because the content is arbitrary and can contain data that
	// cannot easily be represented in Go (such as maps with bytestring keys)
	PlutusData []cbor.RawMessage `cbor:"4,keyasint,omitempty"`
	Redeemers  []cbor.RawMessage `cbor:"5,keyasint,omitempty"`
}

type BabbageBlock

type BabbageBlock struct {
	Header                 BabbageBlockHeader
	TransactionBodies      []BabbageTransactionBody
	TransactionWitnessSets []AlonzoTransactionWitnessSet
	// TODO: figure out how to parse properly
	// We use RawMessage here because the content is arbitrary and can contain data that
	// cannot easily be represented in Go (such as maps with bytestring keys)
	TransactionMetadataSet map[uint]cbor.RawMessage
	InvalidTransactions    []uint
	// contains filtered or unexported fields
}

func NewBabbageBlockFromCbor

func NewBabbageBlockFromCbor(data []byte) (*BabbageBlock, error)

func (*BabbageBlock) Id

func (b *BabbageBlock) Id() string

type BabbageBlockHeader

type BabbageBlockHeader struct {
	Body struct {
		BlockNumber   uint64
		Slot          uint64
		PrevHash      Blake2b256
		IssuerVkey    interface{}
		VrfKey        interface{}
		VrfResult     interface{}
		BlockBodySize uint32
		BlockBodyHash Blake2b256
		OpCert        struct {
			HotVkey        interface{}
			SequenceNumber uint32
			KesPeriod      uint32
			Signature      interface{}
			// contains filtered or unexported fields
		}
		ProtoVersion struct {
			Major uint64
			Minor uint64
			// contains filtered or unexported fields
		}
		// contains filtered or unexported fields
	}
	Signature interface{}
	// contains filtered or unexported fields
}

func NewBabbageBlockHeaderFromCbor

func NewBabbageBlockHeaderFromCbor(data []byte) (*BabbageBlockHeader, error)

func (*BabbageBlockHeader) Id

func (h *BabbageBlockHeader) Id() string

type BabbageTransaction

type BabbageTransaction struct {
	Body       BabbageTransactionBody
	WitnessSet AlonzoTransactionWitnessSet
	IsValid    bool
	Metadata   interface{}
}

func NewBabbageTransactionFromCbor

func NewBabbageTransactionFromCbor(data []byte) (*BabbageTransaction, error)

type BabbageTransactionBody added in v0.2.0

type BabbageTransactionBody struct {
	AlonzoTransactionBody
	CollateralReturn ShelleyTransactionOutput  `cbor:"16,keyasint,omitempty"`
	TotalCollateral  uint64                    `cbor:"17,keyasint,omitempty"`
	ReferenceInputs  []ShelleyTransactionInput `cbor:"18,keyasint,omitempty"`
}

func NewBabbageTransactionBodyFromCbor added in v0.2.0

func NewBabbageTransactionBodyFromCbor(data []byte) (*BabbageTransactionBody, error)

type Blake2b224

type Blake2b224 [28]byte

func (Blake2b224) String

func (b Blake2b224) String() string

type Blake2b256

type Blake2b256 [32]byte

func (Blake2b256) String

func (b Blake2b256) String() string

type ByronEpochBoundaryBlock

type ByronEpochBoundaryBlock struct {
	Header ByronEpochBoundaryBlockHeader
	Body   []Blake2b224
	Extra  []interface{}
	// contains filtered or unexported fields
}

func NewByronEpochBoundaryBlockFromCbor

func NewByronEpochBoundaryBlockFromCbor(data []byte) (*ByronEpochBoundaryBlock, error)

func (*ByronEpochBoundaryBlock) Id

type ByronEpochBoundaryBlockHeader

type ByronEpochBoundaryBlockHeader struct {
	ProtocolMagic uint32
	PrevBlock     Blake2b256
	BodyProof     interface{}
	ConsensusData struct {
		Epoch      uint64
		Difficulty struct {
			Value uint64
			// contains filtered or unexported fields
		}
		// contains filtered or unexported fields
	}
	ExtraData interface{}
	// contains filtered or unexported fields
}

func NewByronEpochBoundaryBlockHeaderFromCbor

func NewByronEpochBoundaryBlockHeaderFromCbor(data []byte) (*ByronEpochBoundaryBlockHeader, error)

func (*ByronEpochBoundaryBlockHeader) Id

type ByronMainBlock

type ByronMainBlock struct {
	Header ByronMainBlockHeader
	Body   ByronMainBlockBody
	Extra  []interface{}
	// contains filtered or unexported fields
}

func NewByronMainBlockFromCbor

func NewByronMainBlockFromCbor(data []byte) (*ByronMainBlock, error)

func (*ByronMainBlock) Id

func (b *ByronMainBlock) Id() string

type ByronMainBlockBody

type ByronMainBlockBody struct {
	TxPayload []ByronTransactionBody
	// We keep this field as raw CBOR, since it contains a map with []byte
	// keys, which Go doesn't allow
	SscPayload cbor.RawMessage
	DlgPayload []interface{}
	UpdPayload []interface{}
	// contains filtered or unexported fields
}

type ByronMainBlockHeader

type ByronMainBlockHeader struct {
	ProtocolMagic uint32
	PrevBlock     Blake2b256
	BodyProof     interface{}
	ConsensusData struct {

		// [slotid, pubkey, difficulty, blocksig]
		SlotId struct {
			Epoch uint64
			Slot  uint16
			// contains filtered or unexported fields
		}
		PubKey     []byte
		Difficulty struct {
			Unknown uint64
			// contains filtered or unexported fields
		}
		BlockSig []interface{}
		// contains filtered or unexported fields
	}
	ExtraData struct {
		BlockVersion struct {
			Major   uint16
			Minor   uint16
			Unknown uint8
			// contains filtered or unexported fields
		}
		SoftwareVersion struct {
			Name    string
			Unknown uint32
			// contains filtered or unexported fields
		}
		Attributes interface{}
		ExtraProof Blake2b256
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

func NewByronMainBlockHeaderFromCbor

func NewByronMainBlockHeaderFromCbor(data []byte) (*ByronMainBlockHeader, error)

func (*ByronMainBlockHeader) Id

func (h *ByronMainBlockHeader) Id() string

type ByronTransaction

type ByronTransaction interface{}

TODO: flesh this out

func NewByronTransactionFromCbor

func NewByronTransactionFromCbor(data []byte) (*ByronTransaction, error)

type ByronTransactionBody added in v0.2.0

type ByronTransactionBody interface{}

TODO: flesh this out

func NewByronTransactionBodyFromCbor added in v0.2.0

func NewByronTransactionBodyFromCbor(data []byte) (*ByronTransactionBody, error)

type MaryBlock

type MaryBlock struct {
	Header                 ShelleyBlockHeader
	TransactionBodies      []MaryTransactionBody
	TransactionWitnessSets []ShelleyTransactionWitnessSet
	// TODO: figure out how to parse properly
	// We use RawMessage here because the content is arbitrary and can contain data that
	// cannot easily be represented in Go (such as maps with bytestring keys)
	TransactionMetadataSet map[uint]cbor.RawMessage
	// contains filtered or unexported fields
}

func NewMaryBlockFromCbor

func NewMaryBlockFromCbor(data []byte) (*MaryBlock, error)

func (*MaryBlock) Id

func (b *MaryBlock) Id() string

type MaryTransaction

type MaryTransaction struct {
	Body       MaryTransactionBody
	WitnessSet ShelleyTransactionWitnessSet
	Metadata   interface{}
}

func NewMaryTransactionFromCbor

func NewMaryTransactionFromCbor(data []byte) (*MaryTransaction, error)

type MaryTransactionBody added in v0.2.0

type MaryTransactionBody struct {
	AllegraTransactionBody
	//Outputs []MaryTransactionOutput `cbor:"1,keyasint,omitempty"`
	Outputs []cbor.RawMessage `cbor:"1,keyasint,omitempty"`
	// TODO: further parsing of this field
	Mint cbor.RawMessage `cbor:"9,keyasint,omitempty"`
}

func NewMaryTransactionBodyFromCbor added in v0.2.0

func NewMaryTransactionBodyFromCbor(data []byte) (*MaryTransactionBody, error)

type MaryTransactionOutput

type MaryTransactionOutput cbor.RawMessage

type ShelleyBlock

type ShelleyBlock struct {
	Header                 ShelleyBlockHeader
	TransactionBodies      []ShelleyTransactionBody
	TransactionWitnessSets []ShelleyTransactionWitnessSet
	// TODO: figure out how to parse properly
	// We use RawMessage here because the content is arbitrary and can contain data that
	// cannot easily be represented in Go (such as maps with bytestring keys)
	TransactionMetadataSet map[uint]cbor.RawMessage
	// contains filtered or unexported fields
}

func NewShelleyBlockFromCbor

func NewShelleyBlockFromCbor(data []byte) (*ShelleyBlock, error)

func (*ShelleyBlock) Id

func (b *ShelleyBlock) Id() string

type ShelleyBlockHeader

type ShelleyBlockHeader struct {
	Body struct {
		BlockNumber          uint64
		Slot                 uint64
		PrevHash             Blake2b256
		IssuerVkey           interface{}
		VrfKey               interface{}
		NonceVrf             interface{}
		LeaderVrf            interface{}
		BlockBodySize        uint32
		BlockBodyHash        Blake2b256
		OpCertHotVkey        interface{}
		OpCertSequenceNumber uint32
		OpCertKesPeriod      uint32
		OpCertSignature      interface{}
		ProtoMajorVersion    uint64
		ProtoMinorVersion    uint64
		// contains filtered or unexported fields
	}
	Signature interface{}
	// contains filtered or unexported fields
}

func NewShelleyBlockHeaderFromCbor

func NewShelleyBlockHeaderFromCbor(data []byte) (*ShelleyBlockHeader, error)

func (*ShelleyBlockHeader) Id

func (h *ShelleyBlockHeader) Id() string

type ShelleyTransaction

type ShelleyTransaction struct {
	Body       ShelleyTransactionBody
	WitnessSet ShelleyTransactionWitnessSet
	Metadata   interface{}
}

func NewShelleyTransactionFromCbor

func NewShelleyTransactionFromCbor(data []byte) (*ShelleyTransaction, error)

type ShelleyTransactionBody added in v0.2.0

type ShelleyTransactionBody struct {
	Inputs  []ShelleyTransactionInput  `cbor:"0,keyasint,omitempty"`
	Outputs []ShelleyTransactionOutput `cbor:"1,keyasint,omitempty"`
	Fee     uint64                     `cbor:"2,keyasint,omitempty"`
	Ttl     uint64                     `cbor:"3,keyasint,omitempty"`
	// TODO: figure out how to parse properly
	Certificates []cbor.RawMessage `cbor:"4,keyasint,omitempty"`
	// TODO: figure out how to parse this correctly
	// We keep the raw CBOR because it can contain a map with []byte keys, which
	// Go does not allow
	Withdrawals cbor.RawMessage `cbor:"5,keyasint,omitempty"`
	Update      struct {

		// TODO: figure out how to parse properly
		// We use RawMessage here because the content is arbitrary and can contain data that
		// cannot easily be represented in Go (such as maps with bytestring keys)
		ProtocolParamUpdates cbor.RawMessage
		Epoch                uint64
		// contains filtered or unexported fields
	} `cbor:"6,keyasint,omitempty"`
	MetadataHash Blake2b256 `cbor:"7,keyasint,omitempty"`
}

func NewShelleyTransactionBodyFromCbor added in v0.2.0

func NewShelleyTransactionBodyFromCbor(data []byte) (*ShelleyTransactionBody, error)

type ShelleyTransactionInput

type ShelleyTransactionInput struct {
	Id    Blake2b256
	Index uint32
	// contains filtered or unexported fields
}

type ShelleyTransactionOutput

type ShelleyTransactionOutput struct {
	Address Blake2b256
	Amount  uint64
	// contains filtered or unexported fields
}

type ShelleyTransactionWitnessSet

type ShelleyTransactionWitnessSet struct {
	VkeyWitnesses      []interface{} `cbor:"0,keyasint,omitempty"`
	MultisigScripts    []interface{} `cbor:"1,keyasint,omitempty"`
	BootstrapWitnesses []interface{} `cbor:"2,keyasint,omitempty"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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