cardano

package module
v0.0.0-...-293d52f Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 37 Imported by: 0

README

cardano-go

Go library and RPC server for interacting with Cardano blockchain nodes. Implements the Ouroboros protocol to sync chain data, process blocks, and provide an HTTP RPC API for Cardano operations. Part of the MayaChain ecosystem.

Features

  • Ouroboros Protocol Implementation - ChainSync, BlockFetch, TxSubmission, LocalStateQuery, KeepAlive
  • HTTP REST API - Full-featured RPC server for blockchain queries and transaction operations
  • Chain Synchronization - Batch processing with configurable reorg window
  • SQLite Storage - Persistent storage for chain points and transaction mappings
  • Address Utilities - Generation, encoding, and decoding of Cardano addresses
  • Transaction Operations - Build, sign, estimate fees, and broadcast transactions
  • Multi-Network Support - Mainnet, preprod, and privnet configurations

Installation

As a Go Module
go get gitlab.com/mayachain/cardano-go
Building from Source
# Build the RPC server
go build -o cardano-rpc ./cmd/rpc

# Build utility commands
go build -o addr_gen ./cmd/addr_gen
go build -o addr_build ./cmd/addr_build
go build -o addr_decode ./cmd/addr_decode
Docker
docker build -t cardano-go .

Quick Start

Running the RPC Server
./cardano-rpc \
  --databasepath cardano-rpc.db \
  --ntnhostport localhost:3000 \
  --ntchostport localhost:3001 \
  --network mainnet \
  --rpchostport localhost:3002 \
  --loglevel info \
  --reorgwindow 6

Or set log level via environment variable:

CARDANO_RPC_LOG_LEVEL=debug ./cardano-rpc

Configuration

Flag Description Default
--databasepath SQLite database file path -
--ntnhostport Node-to-Node connection endpoint localhost:3000
--ntchostport Node-to-Client connection endpoint localhost:3001
--network Network: mainnet, preprod, or privnet -
--rpchostport HTTP RPC server endpoint localhost:3002
--loglevel Log level: trace, debug, info, warn, error, fatal info
--reorgwindow Number of blocks to wait before considering finalized 6

API Reference

Query Endpoints
GET /height

Returns the current chain height.

Response:

{
  "slot": 123456789,
  "hash": "abc123...",
  "height": 10000000
}
GET /status

Returns node status and protocol parameters.

Response:

{
  "tip": {
    "slot": 123456789,
    "hash": "abc123...",
    "height": 10000000
  },
  "fees": {
    "coinsPerUtxoByte": 4310,
    "maxTxSize": 16384,
    "minFeeCoefficient": 44,
    "minFeeConstant": 155381,
    "minUtxoThreshold": 849870
  },
  "reorgWindow": 6
}
GET /block/latest

Returns the latest block with all transactions.

Response:

{
  "height": 10000000,
  "slot": 123456789,
  "hash": "abc123...",
  "type": 6,
  "transactions": [...]
}
GET /block/:numberorhash

Get a block by height (number) or hash (64-character hex string).

Examples:

GET /block/10000000
GET /block/abc123def456...

Response:

{
  "height": 10000000,
  "slot": 123456789,
  "hash": "abc123...",
  "type": 6,
  "transactions": [
    {
      "hash": "txhash123...",
      "inputs": [{"hash": "...", "index": 0}],
      "outputs": [{"amount": 1000000, "address": "addr1..."}],
      "memo": "",
      "fee": 170000
    }
  ]
}
GET /tx/:hash

Get a transaction by hash.

Response:

{
  "hash": "txhash123...",
  "inputs": [
    {"hash": "prevtxhash...", "index": 0}
  ],
  "outputs": [
    {"amount": 1000000, "address": "addr1..."},
    {"amount": 5000000, "address": "addr1..."}
  ],
  "memo": "MAYA:SWAP...",
  "fee": 170000
}
GET /tx/:hash/block

Get the block containing a specific transaction.

Response: Same as GET /block/:numberorhash

GET /utxo/:address

Get all UTXOs for an address (bech32 format).

Example:

GET /utxo/addr1qx...

Response:

[
  {
    "txHash": "abc123...",
    "index": 0,
    "amount": 5000000,
    "address": "addr1qx...",
    "height": 10000000
  }
]
Transaction Endpoints
POST /tx/build

Build an unsigned transaction.

Request:

{
  "txIn": [
    {"txHash": "abc123...", "index": 0}
  ],
  "txOut": [
    {"address": "addr1qx...", "value": 2000000}
  ],
  "changeAddress": "addr1qy...",
  "memo": "optional memo"
}

Response:

{
  "hash": "newtxhash...",
  "rawHex": "84a400...",
  "estimatedFee": 170429
}
POST /tx/sign

Sign a transaction with a private key.

Request:

{
  "tx": "84a400...",
  "privateKeyHex": "5820..."
}

Response:

{
  "tx": "84a500..."
}
POST /tx/broadcast

Broadcast a signed transaction to the network.

Request:

{
  "tx": "84a500..."
}

Response:

{
  "txHash": "submittedtxhash..."
}
POST /tx/estimate-fee

Estimate the fee for a transaction.

Request:

{
  "inputs": 2,
  "outputAmounts": [2000000, 3000000],
  "memo": "optional memo"
}

Response:

{
  "size": 350,
  "fee": 170781
}
Utility Endpoints
POST /tools/pubkey-to-address

Convert a public key to a Cardano address.

Request:

{
  "network": "mainnet",
  "publicKeyHex": "a1b2c3..."
}

Response:

{
  "address": "addr1qx..."
}

CLI Utilities

addr_gen

Generate new Cardano addresses with random Ed25519 keys.

./addr_gen

Outputs addresses for mainnet, preprod, and privnet in hex, CBOR, and bech32 formats.

addr_build

Build addresses from provided public keys.

./addr_build --pubkey <hex> --network mainnet
addr_decode

Decode Cardano addresses to inspect their components.

./addr_decode --address addr1qx...

Using as a Library

Creating an RPC Client
import (
    "gitlab.com/mayachain/cardano-go"
    "gitlab.com/mayachain/cardano-go/rpcclient"
)

client, err := rpcclient.NewHttpRpcClient("http://localhost:3002", cardano.NetworkMainnet)
if err != nil {
    log.Fatal(err)
}
Getting UTXOs
utxos, err := client.GetUtxosForAddress(&rpcclient.GetUtxosForAddressIn{
    Address: myAddress,
})
if err != nil {
    log.Fatal(err)
}

for _, utxo := range utxos {
    fmt.Printf("UTXO: %s#%d - %d lovelace\n", utxo.TxHash, utxo.Index, utxo.Amount)
}
Building and Signing a Transaction
// Build transaction
buildOut, err := client.BuildTx(&rpcclient.TransactionBuildIn{
    Inputs: []rpcclient.TransactionBuildInput{
        {TxHash: "abc123...", Index: 0},
    },
    Outputs: []rpcclient.TransactionBuildOutput{
        {Address: "addr1qx...", Value: 2000000},
    },
    ChangeAddress: "addr1qy...",
    Memo:          "MAYA:SWAP...",
})
if err != nil {
    log.Fatal(err)
}

// Sign transaction
signOut, err := client.SignTx(&rpcclient.TransactionSignIn{
    Tx:            buildOut.RawHex,
    PrivateKeyHex: "5820...",
})
if err != nil {
    log.Fatal(err)
}

// Broadcast transaction
broadcastOut, err := client.BroadcastTx(&rpcclient.BroadcastTxIn{
    TxHex: string(signOut.Tx),
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Transaction submitted: %s\n", broadcastOut.TxHash)

Architecture

Components
  • Client (client.go) - Connects to Cardano nodes via Node-to-Node (NtN) and Node-to-Client (NtC) protocols using the gouroboros library
  • BlockProcessor (block_processor.go) - Processes blocks in batches of 10,000, validates chain continuity, and handles reorgs
  • Database (db_sqlite.go) - SQLite storage for chain points (slot, hash, height) and transaction references
  • HTTP Server (cmd/rpc/http.go) - Fiber-based REST API exposing all endpoints
Protocol Implementation

The library implements several Cardano mini-protocols:

Protocol Description
Handshake Version negotiation with nodes
ChainSync Rolling forward/backward through the chain
BlockFetch Fetching block ranges and individual blocks
LocalStateQuery Querying node state (UTXOs, protocol params)
TxSubmission Broadcasting signed transactions
KeepAlive Maintaining connections
Database Schema
  • point - Chain points (slot, hash, type, height)
  • tx - Transaction hash to block height mappings
  • point_rollback - Audit trail of rolled-back chain points

Network Configuration

Network Magic Description
mainnet 764824073 Cardano mainnet
preprod 1 Pre-production testnet
privnet 42 Private test networks

Node connections require both NtN (default :3000) and NtC (default :3001) ports.

Development

Running Tests
go test ./...           # Run all tests
go test -v ./...        # Verbose output
go test -run TestName   # Run specific test
Dependency Management
go mod tidy      # Clean up dependencies
go mod download  # Download dependencies
go mod vendor    # Vendor dependencies

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Documentation

Index

Constants

View Source
const (
	// MinUtxoBytes The smallest size in bytes a cardano transaction can be.
	//
	// It was originally 160 as defined here:
	// https://github.com/IntersectMBO/cardano-ledger/blob/a6f276a9e3df45d69be3a593d3db6cd9dfaa7a02/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxOut.hs#L680
	//
	// However, the smallest conway transaction I've been able to build was 197 bytes.
	MinUtxoBytes         = 197
	MaxAuxDataStringSize = 64
)
View Source
const (
	SubprotocolLocalStateAcquire               = 0
	SubprotocolLocalStateAcquired              = 1
	SubprotocolLocalStateFailure               = 2
	SubprotocolLocalStateQuery                 = 3
	SubprotocolLocalStateResult                = 4
	SubprotocolLocalStateRelease               = 5
	SubprotocolLocalStateReacquire             = 6
	SubprotocolLocalStateDone                  = 7
	SubprotocolLocalStateAcquireVolatileTip    = 8
	SubprotocolLocalStateReacquireVolatileTip  = 9
	SubprotocolLocalStateAcquireImmutableTip   = 10
	SubprotocolLocalStateReacquireImmutableTip = 11
)
View Source
const (
	N2NProtocolV4 = iota + 4
	N2NProtocolV5
	N2NProtocolV6
	N2NProtocolV7
	N2NProtocolV8
	N2NProtocolV9
	N2NProtocolV10
	N2NProtocolV11
	N2NProtocolV12
	N2NProtocolV13
)
View Source
const (
	BlockBatchSize = 10000
)
View Source
const MayaProtocolAuxKey = 6676

Variables

View Source
var (
	AddressHeaderTypeStakePaymentKeyHash   AddressHeaderType = [4]byte{0, 0, 0, 0}
	AddressHeaderTypeStakeScriptHash       AddressHeaderType = [4]byte{0, 0, 0, 1}
	AddressHeaderTypeScriptPaymentKeyHash  AddressHeaderType = [4]byte{0, 0, 1, 0}
	AddressHeaderTypeScriptScriptHash      AddressHeaderType = [4]byte{0, 0, 1, 1}
	AddressHeaderTypePointerPaymentKeyHash AddressHeaderType = [4]byte{0, 1, 0, 0}
	AddressHeaderTypePointerScriptHash     AddressHeaderType = [4]byte{0, 1, 0, 1}
	AddressHeaderTypePaymentKeyHash        AddressHeaderType = [4]byte{0, 1, 1, 0}
	AddressHeaderTypeScriptHash            AddressHeaderType = [4]byte{0, 1, 1, 1}
	AddressHeaderTypeStakeRewardHash       AddressHeaderType = [4]byte{1, 1, 1, 0}
	AddressHeaderTypeScriptRewardHash      AddressHeaderType = [4]byte{1, 1, 1, 1}

	AddressHeaderNetworkTestnet AddressHeaderNetwork = [4]byte{0, 0, 0, 0}
	AddressHeaderNetworkMainnet AddressHeaderNetwork = [4]byte{0, 0, 0, 1}
)
View Source
var (
	ErrBlockProcessorStarting = RpcError{Msg: "block processor starting", Code: http.StatusNotFound}
	ErrPointNotFound          = RpcError{Msg: "point not found", Code: http.StatusNotFound}
	ErrBlockNotFound          = RpcError{Msg: "block not found", Code: http.StatusNotFound}
	ErrTransactionNotFound    = RpcError{Msg: "transaction not found", Code: http.StatusNotFound}
	ErrNotEnoughFunds         = RpcError{Msg: "not enough funds", Code: http.StatusBadRequest}
	ErrInvalidPrivateKey      = RpcError{Msg: "invalid private key", Code: http.StatusBadRequest}
	ErrInvalidPublicKey       = RpcError{Msg: "invalid public key", Code: http.StatusBadRequest}
	ErrInvalidPublicKeyType   = RpcError{Msg: "invalid public key type", Code: http.StatusBadRequest}
	ErrInvalidCliResponse     = RpcError{Msg: "invalid cardano-cli response", Code: http.StatusBadRequest}
	ErrRpcFailed              = RpcError{Msg: "rpc failed", Code: 0}
	ErrNodeCommandFailed      = RpcError{Msg: "node command failed", Code: http.StatusBadRequest}
	ErrNetworkInvalid         = RpcError{Msg: "network invalid", Code: http.StatusBadRequest}
	ErrNodeUnavailable        = RpcError{Msg: "node unavailable", Code: http.StatusInternalServerError}
)
View Source
var EraStringMap = map[Era]string{
	EraByronEBB: "ByronEBB",
	EraByron:    "Byron",
	EraShelley:  "Shelley",
	EraAllegra:  "Allegra",
	EraMary:     "Mary",
	EraAlonzo:   "Alonzo",
	EraBabbage:  "Babbage",
	EraConway:   "Conway",
}
View Source
var MainNetParams = NetworkParams{}
View Source
var MessageSubprotocolMap = map[reflect.Type]Subprotocol{
	reflect.TypeOf(&MessageProposeVersions{}):   SubprotocolHandshakeProposedVersion,
	reflect.TypeOf(&MessageRefuse{}):            SubprotocolHandshakeRefuse,
	reflect.TypeOf(&MessageQueryReply{}):        SubprotocolHandshakeQueryReply,
	reflect.TypeOf(&MessageAcceptVersionNtN{}):  SubprotocolHandshakeAcceptVersion,
	reflect.TypeOf(&MessageRequestNext{}):       SubprotocolChainSyncRequestNext,
	reflect.TypeOf(&MessageAwaitReply{}):        SubprotocolChainSyncAwaitReply,
	reflect.TypeOf(&MessageRollForward{}):       SubprotocolChainSyncRollForward,
	reflect.TypeOf(&MessageRollBackward{}):      SubprotocolChainSyncRollBackward,
	reflect.TypeOf(&MessageFindIntersect{}):     SubprotocolChainSyncFindIntersect,
	reflect.TypeOf(&MessageIntersectFound{}):    SubprotocolChainSyncIntersectFound,
	reflect.TypeOf(&MessageIntersectNotFound{}): SubprotocolChainSyncIntersectNotFound,
	reflect.TypeOf(&MessageChainSyncDone{}):     SubprotocolChainSyncDone,
	reflect.TypeOf(&MessageRequestRange{}):      SubprotocolBlockFetchRequestRange,
	reflect.TypeOf(&MessageClientDone{}):        SubprotocolBlockFetchClientDone,
	reflect.TypeOf(&MessageStartBatch{}):        SubprotocolBlockFetchStartBatch,
	reflect.TypeOf(&MessageNoBlocks{}):          SubprotocolBlockFetchNoBlocks,
	reflect.TypeOf(&MessageBlock{}):             SubprotocolBlockFetchBlock,
	reflect.TypeOf(&MessageBatchDone{}):         SubprotocolBlockFetchBatchDone,
	reflect.TypeOf(&MessageKeepAliveResponse{}): SubprotocolKeepAliveEcho,
	reflect.TypeOf(&MessageKeepAlive{}):         SubprotocolKeepAlivePing,
}
View Source
var PreProdParams = NetworkParams{}
View Source
var PrivateNetParams = NetworkParams{}
View Source
var ProtocolMessageMap = map[Protocol]map[Subprotocol]Message{
	ProtocolHandshake: {
		SubprotocolHandshakeProposedVersion: &MessageProposeVersions{},
		SubprotocolHandshakeAcceptVersion:   &MessageAcceptVersionNtC{},
		SubprotocolHandshakeRefuse:          &MessageRefuse{},
		SubprotocolHandshakeQueryReply:      &MessageQueryReply{},
	},
	ProtocolChainSync: {
		SubprotocolChainSyncRequestNext:       &MessageRequestNext{},
		SubprotocolChainSyncAwaitReply:        &MessageAwaitReply{},
		SubprotocolChainSyncRollForward:       &MessageRollForward{},
		SubprotocolChainSyncRollBackward:      &MessageRollBackward{},
		SubprotocolChainSyncFindIntersect:     &MessageFindIntersect{},
		SubprotocolChainSyncIntersectFound:    &MessageIntersectFound{},
		SubprotocolChainSyncIntersectNotFound: &MessageIntersectNotFound{},
		SubprotocolChainSyncDone:              &MessageChainSyncDone{},
	},
	ProtocolBlockFetch: {
		SubprotocolBlockFetchRequestRange: &MessageRequestRange{},
		SubprotocolBlockFetchClientDone:   &MessageClientDone{},
		SubprotocolBlockFetchStartBatch:   &MessageStartBatch{},
		SubprotocolBlockFetchNoBlocks:     &MessageNoBlocks{},
		SubprotocolBlockFetchBlock:        &MessageBlock{},
		SubprotocolBlockFetchBatchDone:    &MessageBatchDone{},
	},
	ProtocolKeepAlive: {
		SubprotocolKeepAliveEcho: &MessageKeepAliveResponse{},
		SubprotocolKeepAlivePing: &MessageKeepAlive{},
	},
	ProtocolLocalState: {
		SubprotocolLocalStateAcquire:               &MessageLocalStateAcquire{},
		SubprotocolLocalStateAcquired:              &MessageLocalStateAcquired{},
		SubprotocolLocalStateFailure:               &MessageLocalStateFailure{},
		SubprotocolLocalStateQuery:                 &MessageLocalStateQuery{},
		SubprotocolLocalStateResult:                &MessageLocalStateResult{},
		SubprotocolLocalStateRelease:               &MessageLocalStateRelease{},
		SubprotocolLocalStateReacquire:             &MessageLocalStateReacquire{},
		SubprotocolLocalStateDone:                  &MessageLocalStateDone{},
		SubprotocolLocalStateAcquireVolatileTip:    &MessageLocalStateAcquireVolatileTip{},
		SubprotocolLocalStateReacquireVolatileTip:  &MessageLocalStateReacquireVolatileTip{},
		SubprotocolLocalStateAcquireImmutableTip:   &MessageLocalStateAcquireImmutableTip{},
		SubprotocolLocalStateReacquireImmutableTip: &MessageLocalStateReacquireImmutableTip{},
	},
	ProtocolLocalTx: {},
}
View Source
var ProtocolStringMap = map[Protocol]string{
	ProtocolHandshake:      "handshake",
	ProtocolChainSync:      "chain sync",
	ProtocolBlockFetch:     "block fetch",
	ProtocolTxSubmission:   "tx submission",
	ProtocolLocalChainSync: "local chain sync",
	ProtocolLocalTx:        "local tx",
	ProtocolLocalState:     "local state",
	ProtocolKeepAlive:      "keep alive",
}
View Source
var StandardCborDecoder, _ = cbor.DecOptions{
	UTF8:             cbor.UTF8DecodeInvalid,
	MaxArrayElements: math.MaxInt32,
	MaxMapPairs:      math.MaxInt32,
}.DecMode()

Functions

func BinarySearchCallback

func BinarySearchCallback(start, end uint64, callback func(uint64) (int, error)) error

func Blake2bSum224

func Blake2bSum224(data []byte) (hash []byte, err error)

func BlakeHash

func BlakeHash(target any) (hash []byte, err error)

func Cast

func Cast[X any](target any) (casted X, ok bool)

Cast acts exactly like the builtin go cast but the return value (if ok) is automatically converted from aliases of the target type.

e.g.

type Map map[string]any
nonBuiltinValue := Map{"test": 1}

if builtinValue, ok := Cast[map[string]any](nonBuiltinValue); ok {
  // We have our typed and auto-converted value here
}

func ChunkString

func ChunkString(s string, chunkSize int) []string

func DirectoryExists

func DirectoryExists(path string) bool

func IndentCbor

func IndentCbor(input string) string

func IterateChunkDirectory

func IterateChunkDirectory(dir string, cb func(path string, data []byte, err error) error) error

func Log

func Log() *zerolog.Logger

func LogAtLevel

func LogAtLevel(level zerolog.Level) *zerolog.Logger

func MarshalStack

func MarshalStack(err error) interface{}

func MessageToProtocol

func MessageToProtocol(message Message) (protocol Protocol, subprotocol Subprotocol, err error)

func StackTracerMessage

func StackTracerMessage(err error) string

Types

type Address

type Address []byte

func DecodeAddress

func DecodeAddress(address string, network Network) (decoded Address, err error)

DecodeAddress accepts a Bech32 address string and parses it into a Cardano Address interface.

func EncodeAddress

func EncodeAddress(publicKey []byte, net Network, typ AddressType) (addr Address, err error)

EncodeAddress accepts an Ed25519 public key and returns a Cardano Address interface.

func (Address) Bech32String

func (a Address) Bech32String(network Network) (encoded string, err error)

func (*Address) Binary

func (a *Address) Binary() (out []byte, err error)

func (Address) Header

func (a Address) Header() (header AddressHeader, err error)

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (Address) Network

func (a Address) Network() (net AddressHeaderNetwork, err error)

func (*Address) ParseBech32String

func (a *Address) ParseBech32String(encoded string, network Network) (err error)

func (Address) String

func (a Address) String() string

func (Address) Type

func (a Address) Type() (typ AddressType, err error)

type AddressFormat

type AddressFormat struct {
	Type       AddressType
	HeaderType AddressHeaderType
}

type AddressHeader

type AddressHeader byte

func (AddressHeader) Format

func (a AddressHeader) Format() (format AddressFormat, err error)

func (AddressHeader) IsForNetwork

func (a AddressHeader) IsForNetwork(params *NetworkParams) (match bool, err error)

func (AddressHeader) Network

func (a AddressHeader) Network() (network AddressHeaderNetwork, err error)

func (*AddressHeader) SetNetwork

func (a *AddressHeader) SetNetwork(network AddressHeaderNetwork)

func (*AddressHeader) SetType

func (a *AddressHeader) SetType(headerType AddressHeaderType)

func (AddressHeader) String

func (a AddressHeader) String() string

func (AddressHeader) Type

func (a AddressHeader) Type() (typ AddressType, err error)

func (AddressHeader) Valid

func (a AddressHeader) Valid() bool

func (AddressHeader) Validate

func (a AddressHeader) Validate() (err error)

type AddressHeaderNetwork

type AddressHeaderNetwork [4]byte

func (AddressHeaderNetwork) String

func (a AddressHeaderNetwork) String() string

type AddressHeaderType

type AddressHeaderType [4]byte

type AddressType

type AddressType int
const (
	AddressTypePaymentAndStake AddressType = iota
	AddressTypeScriptAndStake
	AddressTypePaymentAndScript
	AddressTypeScriptAndScript
	AddressTypePaymentAndPointer
	AddressTypeScriptAndPointer
	AddressTypePayment
	AddressTypeScript
	AddressTypeStakeReward
	AddressTypeScriptReward
)

func (AddressType) Format

func (a AddressType) Format() (format AddressFormat, err error)

func (AddressType) String

func (a AddressType) String() string

type AmountData

type AmountData struct {
	Amount   uint64
	Mappings map[cbor.ByteString]map[cbor.ByteString]uint64
	// contains filtered or unexported fields
}

func (AmountData) MarshalJSON

func (t AmountData) MarshalJSON() ([]byte, error)

type AuxData

type AuxData struct {
	Value any
}

func (*AuxData) Hash

func (a *AuxData) Hash() (hash []byte, err error)

func (*AuxData) JSON

func (a *AuxData) JSON() (jsn gjson.Result, err error)

func (*AuxData) MarshalCBOR

func (a *AuxData) MarshalCBOR() (bytes []byte, err error)

func (*AuxData) MarshalJSON

func (a *AuxData) MarshalJSON() (bytes []byte, err error)

func (*AuxData) SetMemo

func (a *AuxData) SetMemo(memo string)

func (*AuxData) UnmarshalCBOR

func (a *AuxData) UnmarshalCBOR(bytes []byte) (err error)

type Base58Bytes

type Base58Bytes []byte

func (Base58Bytes) MarshalJSON

func (b Base58Bytes) MarshalJSON() ([]byte, error)

func (Base58Bytes) String

func (b Base58Bytes) String() string

type Block

type Block struct {
	Era  Era `json:"era"`
	Data struct {
		Header                 BlockHeader             `json:"header"`
		TransactionBodies      []TransactionBody       `json:"transactionBodies"`
		TransactionWitnessSets []TransactionWitnessSet `json:"transactionWitnessSets"`
		AuxiliaryData          AuxData                 `json:"auxiliaryData"`
		InvalidTransactions    []uint64                `json:"invalidTransactions"`
		// contains filtered or unexported fields
	} `json:"data"`
	Raw []byte `cbor:"-" json:"-"`
	// contains filtered or unexported fields
}

func (*Block) Hash

func (b *Block) Hash() (hash HexBytes, err error)

func (*Block) Point

func (b *Block) Point() (point Point, err error)

func (*Block) PointAndNumber

func (b *Block) PointAndNumber() (pn PointAndBlockNum, err error)

type BlockHeader

type BlockHeader struct {
	Body struct {
		Number          uint64   `json:"number,omitempty"`
		Slot            uint64   `json:"slot,omitempty"`
		PrevHash        HexBytes `json:"prevHash,omitempty"`
		IssuerVkey      HexBytes `json:"issuerVkey,omitempty"`
		VrfKey          HexBytes `json:"vrfKey,omitempty"`
		VrfResult       VrfCert  `json:"vrfResult,omitempty"`
		BodySize        uint64   `json:"bodySize,omitempty"`
		BodyHash        HexBytes `json:"bodyHash,omitempty"`
		OperationalCert struct {
			HotVkey   HexBytes `json:"hotVkey,omitempty"`
			Sequence  uint64   `json:"sequence,omitempty"`
			KesPeriod int64    `json:"kesPeriod,omitempty"`
			Sigma     HexBytes `json:"sigma,omitempty"`
			// contains filtered or unexported fields
		} `json:"operationalCert"`
		ProtocolVersion struct {
			Pt1 int64 `json:"pt1,omitempty"`
			Pt2 int64 `json:"pt2,omitempty"`
			// contains filtered or unexported fields
		} `json:"protocolVersion"`
		// contains filtered or unexported fields
	} `json:"body"`
	Signature HexBytes `json:"signature,omitempty"`
	// contains filtered or unexported fields
}

type BlockProcessor

type BlockProcessor struct {
	// contains filtered or unexported fields
}

func NewBlockProcessor

func NewBlockProcessor(db Database, logger *zerolog.Logger, reorgWindow int) (bp *BlockProcessor, err error)

func (*BlockProcessor) HandleRollback

func (bp *BlockProcessor) HandleRollback(rollbackSlot uint64) error

func (*BlockProcessor) TryProcessBlocks

func (bp *BlockProcessor) TryProcessBlocks()

type CBORUnmarshalError

type CBORUnmarshalError struct {
	Target any
	Bytes  []byte
}

func (CBORUnmarshalError) Error

func (c CBORUnmarshalError) Error() string

type Client

type Client struct {
	Options *ClientOptions
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options *ClientOptions) (client *Client, err error)

func (*Client) FetchLatestBlock

func (c *Client) FetchLatestBlock() (block ledger.Block, err error)

func (*Client) GetBlockByHeight

func (c *Client) GetBlockByHeight(height uint64) (block ledger.Block, err error)

func (*Client) GetBlockByPoint

func (c *Client) GetBlockByPoint(point PointRef) (block ledger.Block, err error)

func (*Client) GetHeight

func (c *Client) GetHeight() (height PointRef, err error)

func (*Client) GetProtocolParams

func (c *Client) GetProtocolParams() (params common2.ProtocolParameters, err error)

func (*Client) GetTip

func (c *Client) GetTip() (point PointRef, err error)

func (*Client) GetTransaction

func (c *Client) GetTransaction(hash string) (tx ledger.Transaction, block ledger.Block, err error)

func (*Client) GetUtxoForAddress

func (c *Client) GetUtxoForAddress(address string) (utxos []UtxoWithHeight, err error)

func (*Client) Start

func (c *Client) Start() (err error)

func (*Client) Stop

func (c *Client) Stop() (err error)

func (*Client) SubmitTx

func (c *Client) SubmitTx(signedTx []byte) (err error)

type ClientOptions

type ClientOptions struct {
	NtNHostPort string
	NtCHostPort string
	Network     Network
	Database    Database
	StartPoint  PointRef
	// DisableFollowChain bool
	LogLevel    zerolog.Level
	ReorgWindow int
}

type CollateralInput

type CollateralInput struct {
	A HexBytes `json:"a,omitempty"`
	B int64    `json:"b,omitempty"`
	// contains filtered or unexported fields
}

type CollateralReturn

type CollateralReturn struct {
	HasSubtypes
}

func (CollateralReturn) Subtypes

func (r CollateralReturn) Subtypes() []any

type CollateralReturnA

type CollateralReturnA struct {
	A HexBytes
	B AmountData
	// contains filtered or unexported fields
}

type CollateralReturnB

type CollateralReturnB struct {
	A HexBytes
	B uint64
	// contains filtered or unexported fields
}

type CollateralReturnC

type CollateralReturnC struct {
	A HexBytes `cbor:"0,keyasint"`
	B uint64   `cbor:"1,keyasint"`
}

type CollateralReturnD

type CollateralReturnD struct {
	A HexBytes   `cbor:"0,keyasint"`
	B AmountData `cbor:"1,keyasint"`
}

type Database

type Database interface {
	AddTxsForBlock(refs []TxRef) (err error)
	GetTxs(txHashes []string) (txs []TxRef, err error)
	GetBlockNumForTx(txHash string) (block uint64, err error)
	AddPoints(points []PointRef) (err error)
	SetPointHeights(updates []PointRef) (err error)
	GetPointByHash(blockHash string) (point PointRef, err error)
	GetPointByHeight(height uint64) (point PointRef, err error)
	GetBoundaryPointBehind(blockHash string) (point PointRef, err error)
	GetPointsBySlot(slot uint64) (points []PointRef, err error)
	GetPointsForLastSlot() (points []PointRef, err error)
	GetPointsForProcessing(batchSize int) (points []PointRef, err error)
	GetHighestPoint() (point PointRef, err error)
	HandleRollback(fromSlot uint64) (err error)
}

type Direction

type Direction bool
const (
	DirectionIn  Direction = false
	DirectionOut Direction = true
)

func (Direction) String

func (d Direction) String() string

type Era

type Era uint64
const (
	EraByronEBB Era = iota
	EraByron
	EraShelley
	EraAllegra
	EraMary
	EraAlonzo
	EraBabbage
	EraConway
)

func (Era) MarshalJSON

func (e Era) MarshalJSON() ([]byte, error)

func (Era) RawString

func (e Era) RawString() string

func (Era) String

func (e Era) String() string

func (*Era) UnmarshalCBOR

func (e *Era) UnmarshalCBOR(data []byte) (err error)

func (Era) Valid

func (e Era) Valid() bool

type HasSubtypes

type HasSubtypes interface {
	Subtypes() []any
}

type HexBytes

type HexBytes []byte

func (HexBytes) Equals

func (b HexBytes) Equals(o HexBytes) bool

func (HexBytes) MarshalJSON

func (b HexBytes) MarshalJSON() ([]byte, error)

func (HexBytes) String

func (b HexBytes) String() string

type HexString

type HexString string

func (HexString) Bytes

func (hs HexString) Bytes() (b []byte)

type KV

type KV struct {
	K any
	V any
}

type KVSlice

type KVSlice []KV

func (KVSlice) MarshalCBOR

func (s KVSlice) MarshalCBOR() ([]byte, error)

func (KVSlice) MarshalJSON

func (s KVSlice) MarshalJSON() ([]byte, error)

type Message

type Message interface {
	SetSubprotocol(Subprotocol)
	GetSubprotocol() Subprotocol
	Raw() []byte
	SetRaw(raw []byte)
}

func ProtocolToMessage

func ProtocolToMessage(protocol Protocol, subprotocol Subprotocol) (message Message, err error)

type MessageAcceptTx

type MessageAcceptTx struct {
	WithSubprotocol
}

type MessageAcceptVersionNtC

type MessageAcceptVersionNtC struct {
	WithSubprotocol
	Version     uint16        `json:"version,omitempty"`
	VersionData VersionField1 `json:"versionData,omitempty"`
}

type MessageAcceptVersionNtN

type MessageAcceptVersionNtN struct {
	WithSubprotocol
	Version     uint16        `json:"version,omitempty"`
	VersionData VersionField2 `json:"versionData,omitempty"`
}

type MessageAwaitReply

type MessageAwaitReply struct {
	WithSubprotocol
}

type MessageBatchDone

type MessageBatchDone struct {
	WithSubprotocol
}

type MessageBlock

type MessageBlock struct {
	WithSubprotocol
	BlockData []byte
}

func (*MessageBlock) Block

func (b *MessageBlock) Block() (block *Block, err error)

type MessageChainSyncDone

type MessageChainSyncDone struct {
	WithSubprotocol
}

type MessageClientDone

type MessageClientDone struct {
	WithSubprotocol
}

type MessageFindIntersect

type MessageFindIntersect struct {
	WithSubprotocol
	Points []Point `json:"points"`
}

type MessageIntersectFound

type MessageIntersectFound struct {
	WithSubprotocol
	Point Point            `json:"point,omitempty"`
	Tip   PointAndBlockNum `json:"tip,omitempty"`
}

type MessageIntersectNotFound

type MessageIntersectNotFound struct {
	WithSubprotocol
	Tip PointAndBlockNum `json:"tip"`
}

type MessageKeepAlive

type MessageKeepAlive struct {
	WithSubprotocol
	Cookie uint16 `json:"cookie,omitempty"`
}

type MessageKeepAliveResponse

type MessageKeepAliveResponse struct {
	WithSubprotocol
	Cookie uint16 `json:"cookie,omitempty"`
}

type MessageLocalStateAcquire

type MessageLocalStateAcquire struct {
	WithSubprotocol
}

type MessageLocalStateAcquireImmutableTip

type MessageLocalStateAcquireImmutableTip struct {
	WithSubprotocol
}

type MessageLocalStateAcquireVolatileTip

type MessageLocalStateAcquireVolatileTip struct {
	WithSubprotocol
}

type MessageLocalStateAcquired

type MessageLocalStateAcquired struct {
	WithSubprotocol
}

type MessageLocalStateDone

type MessageLocalStateDone struct {
	WithSubprotocol
}

type MessageLocalStateFailure

type MessageLocalStateFailure struct {
	WithSubprotocol
}

type MessageLocalStateQuery

type MessageLocalStateQuery struct {
	WithSubprotocol
	Query any
}

type MessageLocalStateReacquire

type MessageLocalStateReacquire struct {
	WithSubprotocol
}

type MessageLocalStateReacquireImmutableTip

type MessageLocalStateReacquireImmutableTip struct {
	WithSubprotocol
}

type MessageLocalStateReacquireVolatileTip

type MessageLocalStateReacquireVolatileTip struct {
	WithSubprotocol
}

type MessageLocalStateRelease

type MessageLocalStateRelease struct {
	WithSubprotocol
}

type MessageLocalStateResult

type MessageLocalStateResult struct {
	WithSubprotocol
	Result any
}

type MessageNoBlocks

type MessageNoBlocks struct {
	WithSubprotocol
}

type MessageProposeVersions

type MessageProposeVersions struct {
	WithSubprotocol
	VersionMap VersionMap `json:"versionMap"`
}

type MessageQueryReply

type MessageQueryReply struct {
	WithSubprotocol
}

type MessageReader

type MessageReader struct {
	// contains filtered or unexported fields
}

func NewMessageReader

func NewMessageReader(log *zerolog.Logger) *MessageReader

func (*MessageReader) Read

func (r *MessageReader) Read(data []byte) (messages []Message, err error)

type MessageRefuse

type MessageRefuse struct {
	WithSubprotocol
	Details struct {
		Code    uint16 `json:"something"`
		Version uint16 `json:"version"`
		Reason  string `json:"reason"`
		// contains filtered or unexported fields
	} `json:"details"`
}

type MessageRejectTx

type MessageRejectTx struct {
	WithSubprotocol
	Reason uint64
}

type MessageRequestNext

type MessageRequestNext struct {
	WithSubprotocol
}

type MessageRequestRange

type MessageRequestRange struct {
	WithSubprotocol
	From Point `json:"from"`
	To   Point `json:"to"`
}

type MessageRollBackward

type MessageRollBackward struct {
	WithSubprotocol
	Point Optional[Point]  `json:"point,omitempty"`
	Tip   PointAndBlockNum `json:"tip,omitempty"`
}

type MessageRollForward

type MessageRollForward struct {
	WithSubprotocol
	Data SubtypeOf[MessageRollForwardData] `json:"data"`
	Tip  PointAndBlockNum                  `json:"tip"`
}

type MessageRollForwardData

type MessageRollForwardData struct{}

func (MessageRollForwardData) Subtypes

func (m MessageRollForwardData) Subtypes() []any

type MessageRollForwardDataA

type MessageRollForwardDataA struct {
	Number      uint64   `json:"number"`
	BlockHeader HexBytes `json:"content"`
	// contains filtered or unexported fields
}

type MessageRollForwardDataB

type MessageRollForwardDataB struct {
	EraMaybe uint64
	Header   struct {
		A struct {
			A any
			B any
			// contains filtered or unexported fields
		}
		B HexBytes
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

type MessageStartBatch

type MessageStartBatch struct {
	WithSubprotocol
}

type MessageSubmitTx

type MessageSubmitTx struct {
	WithSubprotocol
	BodyType Era
	TxBytes  []byte
}

type Network

type Network string
const (
	NetworkMainNet    Network = "mainnet"
	NetworkPreProd    Network = "preprod"
	NetworkPrivateNet Network = "privnet"
)

func (Network) Params

func (n Network) Params() (params *NetworkParams, err error)

func (Network) Valid

func (n Network) Valid() bool

func (Network) Validate

func (n Network) Validate() (err error)

type NetworkMagic

type NetworkMagic uint64
const (
	NetworkMagicMainNet       NetworkMagic = 764824073
	NetworkMagicLegacyTestnet NetworkMagic = 1097911063
	NetworkMagicPreProd       NetworkMagic = 1
	NetworkMagicPreview       NetworkMagic = 2
	NetworkMagicSanchonet     NetworkMagic = 4
	NetworkMagicPrivateNet    NetworkMagic = 42
)

type NetworkParams

type NetworkParams struct {
	Name             Network
	Magic            NetworkMagic
	StartTime        uint64
	ByronBlock       uint64
	AddressPrefix    string
	DelegationPrefix string
}

type Optional

type Optional[T any] struct {
	Valid bool
	Value *T
}

func (Optional[T]) MarshalCBOR

func (f Optional[T]) MarshalCBOR() (out []byte, err error)

func (Optional[T]) MarshalJSON

func (f Optional[T]) MarshalJSON() (out []byte, err error)

func (*Optional[T]) UnmarshalCBOR

func (o *Optional[T]) UnmarshalCBOR(data []byte) error

func (*Optional[T]) UnmarshalJSON

func (o *Optional[T]) UnmarshalJSON(data []byte) error

type PeriodicCaller

type PeriodicCaller struct {
	// contains filtered or unexported fields
}

func NewPeriodicCaller

func NewPeriodicCaller(interval time.Duration, action func()) *PeriodicCaller

func (*PeriodicCaller) Postpone

func (pc *PeriodicCaller) Postpone()

func (*PeriodicCaller) Start

func (pc *PeriodicCaller) Start()

func (*PeriodicCaller) Stop

func (pc *PeriodicCaller) Stop()

type Point

type Point struct {
	Slot uint64   `cbor:",omitempty" json:"slot"`
	Hash HexBytes `chor:",omitempty" json:"hash"`
	// contains filtered or unexported fields
}

func NewPoint

func NewPoint() Point

func (*Point) Equals

func (p *Point) Equals(o Point) bool

func (Point) String

func (p Point) String() string

func (*Point) UnmarshalCBOR

func (p *Point) UnmarshalCBOR(bytes []byte) (err error)

type PointAndBlockNum

type PointAndBlockNum struct {
	Point Point  `json:"point"`
	Block uint64 `json:"block"`
	// contains filtered or unexported fields
}

func NewPointAndNum

func NewPointAndNum() PointAndBlockNum

func (PointAndBlockNum) Equals

func (PointAndBlockNum) String

func (t PointAndBlockNum) String() string

type PointRef

type PointRef struct {
	Slot   uint64 `json:"slot"`
	Hash   string `json:"hash"`
	Type   int    `json:"era"`
	Height uint64 `json:"height"`
}

func (PointRef) Common

func (pr PointRef) Common() common.Point

type Protocol

type Protocol uint16
const (
	ProtocolHandshake Protocol = iota
	ProtocolDeltaQueue
	ProtocolChainSync
	ProtocolBlockFetch
	ProtocolTxSubmission
	ProtocolLocalChainSync
	ProtocolLocalTx
	ProtocolLocalState
	ProtocolKeepAlive
)

func (Protocol) String

func (p Protocol) String() string

type RpcError

type RpcError struct {
	Msg     string `json:"error"`
	Details string `json:"details"`
	Code    int    `json:"code"`
}

func (RpcError) Error

func (r RpcError) Error() string

func (RpcError) Is

func (r RpcError) Is(target error) bool

type Segment

type Segment struct {
	Timestamp     uint32
	Protocol      Protocol
	PayloadLength uint16
	Payload       []byte
	Direction     Direction
	// contains filtered or unexported fields
}

func (*Segment) AddMessage

func (s *Segment) AddMessage(message Message) (err error)

func (*Segment) Complete

func (s *Segment) Complete() bool

func (*Segment) MarshalDataItem

func (s *Segment) MarshalDataItem() (out []byte, err error)

func (*Segment) Messages

func (s *Segment) Messages() (messages []Message, err error)

type SqlLiteDatabase

type SqlLiteDatabase struct {
	// contains filtered or unexported fields
}

func NewSqlLiteDatabase

func NewSqlLiteDatabase(path string) (db *SqlLiteDatabase, err error)

func (*SqlLiteDatabase) AddPoints

func (s *SqlLiteDatabase) AddPoints(points []PointRef) (err error)

func (*SqlLiteDatabase) AddTxsForBlock

func (s *SqlLiteDatabase) AddTxsForBlock(refs []TxRef) (err error)

func (*SqlLiteDatabase) GetBlockNumForTx

func (s *SqlLiteDatabase) GetBlockNumForTx(txhash string) (blockNumber uint64, err error)

func (*SqlLiteDatabase) GetBoundaryPointBehind

func (s *SqlLiteDatabase) GetBoundaryPointBehind(blockHash string) (point PointRef, err error)

func (*SqlLiteDatabase) GetHighestPoint

func (s *SqlLiteDatabase) GetHighestPoint() (point PointRef, err error)

func (*SqlLiteDatabase) GetPointByHash

func (s *SqlLiteDatabase) GetPointByHash(blockHash string) (point PointRef, err error)

func (*SqlLiteDatabase) GetPointByHeight

func (s *SqlLiteDatabase) GetPointByHeight(height uint64) (point PointRef, err error)

func (*SqlLiteDatabase) GetPointsBySlot

func (s *SqlLiteDatabase) GetPointsBySlot(slot uint64) (points []PointRef, err error)

func (*SqlLiteDatabase) GetPointsForLastSlot

func (s *SqlLiteDatabase) GetPointsForLastSlot() (points []PointRef, err error)

func (*SqlLiteDatabase) GetPointsForProcessing

func (s *SqlLiteDatabase) GetPointsForProcessing(batchSize int) (points []PointRef, err error)

GetPointsForProcessing returns points ready for block fetching, respecting BlocksUntilConfirmed-distance from tip

func (*SqlLiteDatabase) GetTxs

func (s *SqlLiteDatabase) GetTxs(txHashes []string) (txs []TxRef, err error)

func (*SqlLiteDatabase) HandleRollback

func (s *SqlLiteDatabase) HandleRollback(fromSlot uint64) (err error)

HandleRollback moves points to the rollback table and cleans up related data

func (*SqlLiteDatabase) SetPointHeights

func (s *SqlLiteDatabase) SetPointHeights(updates []PointRef) (err error)

type Subprotocol

type Subprotocol uint16
const (
	SubprotocolHandshakeProposedVersion Subprotocol = iota
	SubprotocolHandshakeAcceptVersion
	SubprotocolHandshakeRefuse
	SubprotocolHandshakeQueryReply
)
const (
	SubprotocolChainSyncRequestNext Subprotocol = iota
	SubprotocolChainSyncAwaitReply
	SubprotocolChainSyncRollForward
	SubprotocolChainSyncRollBackward
	SubprotocolChainSyncFindIntersect
	SubprotocolChainSyncIntersectFound
	SubprotocolChainSyncIntersectNotFound
	SubprotocolChainSyncDone
)
const (
	SubprotocolBlockFetchRequestRange Subprotocol = iota
	SubprotocolBlockFetchClientDone
	SubprotocolBlockFetchStartBatch
	SubprotocolBlockFetchNoBlocks
	SubprotocolBlockFetchBlock
	SubprotocolBlockFetchBatchDone
)
const (
	SubprotocolKeepAliveEcho Subprotocol = iota
	SubprotocolKeepAlivePing
)

type SubtypeOf

type SubtypeOf[T HasSubtypes] struct {
	Subtype any
}

func (*SubtypeOf[T]) MarshalCBOR

func (r *SubtypeOf[T]) MarshalCBOR() (bytes []byte, err error)

func (SubtypeOf[T]) MarshalJSON

func (r SubtypeOf[T]) MarshalJSON() ([]byte, error)

func (*SubtypeOf[T]) UnmarshalCBOR

func (r *SubtypeOf[T]) UnmarshalCBOR(bytes []byte) (err error)

type TransactionBody

type TransactionBody struct {
	Inputs                []TransactionInput                            `cbor:"0,keyasint,omitempty" json:"inputs,omitempty"`
	Outputs               []SubtypeOf[TransactionOutput]                `cbor:"1,keyasint,omitempty" json:"outputs,omitempty"`
	Fee                   uint64                                        `cbor:"2,keyasint,omitempty" json:"fee,omitempty"`
	Ttl                   int64                                         `cbor:"3,keyasint,omitempty" json:"ttl,omitempty"`
	Certificates          any                                           `cbor:"4,keyasint,omitempty" json:"certificates,omitempty"`
	WithdrawalMap         map[cbor.ByteString]uint64                    `cbor:"5,keyasint,omitempty" json:"withdrawalMap,omitempty"`
	UpdateDI              any                                           `cbor:"6,keyasint,omitempty" json:"updateDI,omitempty"`
	AuxiliaryDataHash     HexBytes                                      `cbor:"7,keyasint,omitempty" json:"auxiliaryDataHash,omitempty"`
	ValidityStartInterval int64                                         `cbor:"8,keyasint,omitempty" json:"validityStartInterval,omitempty"`
	MintMap               map[cbor.ByteString]map[cbor.ByteString]int64 `cbor:"9,keyasint,omitempty" json:"mintMap,omitempty"`
	ScriptDataHash        HexBytes                                      `cbor:"11,keyasint,omitempty" json:"scriptDataHash,omitempty"`
	CollateralInputs      []CollateralInput                             `cbor:"13,keyasint,omitempty" json:"collateralInputs,omitempty"`
	RequiredSigners       []HexBytes                                    `cbor:"14,keyasint,omitempty" json:"requiredSigners,omitempty"`
	NetworkId             int64                                         `cbor:"15,keyasint,omitempty" json:"networkId,omitempty"`
	CollateralReturn      *SubtypeOf[CollateralReturn]                  `cbor:"16,keyasint,omitempty" json:"collateralReturn,omitempty"`
	TotalCollateral       int64                                         `cbor:"17,keyasint,omitempty" json:"totalCollateral,omitempty"`
	ReferenceInputs       []TransactionInput                            `cbor:"18,keyasint,omitempty" json:"referenceInputs,omitempty"`
	VotingProcedures      any                                           `cbor:"19,keyasint,omitempty" json:"votingProcedures,omitempty"`
	ProposalProcedure     any                                           `cbor:"20,keyasint,omitempty" json:"proposalProcedure,omitempty"`
	TreasuryValue         any                                           `cbor:"21,keyasint,omitempty" json:"treasuryValue,omitempty"`
	DonationCoin          uint64                                        `cbor:"22,keyasint,omitempty" json:"donationCoin,omitempty"`
}

func (*TransactionBody) Hash

func (tb *TransactionBody) Hash() (hash HexBytes, err error)

func (*TransactionBody) IterateOutputs

func (tb *TransactionBody) IterateOutputs(cb func(index int, output *TransactionOutputGeneric, err error) error) (err error)

type TransactionInput

type TransactionInput struct {
	Txid  HexBytes `json:"txid"`
	Index int64    `json:"index"`
	// contains filtered or unexported fields
}

type TransactionOutput

type TransactionOutput struct {
	HasSubtypes
}

func (TransactionOutput) Subtypes

func (t TransactionOutput) Subtypes() []any

func (TransactionOutput) ToGeneric

func (TransactionOutput) ToGeneric(in any) (out *TransactionOutputGeneric, err error)

type TransactionOutputA

type TransactionOutputA struct {
	Address    Address                          `cbor:"0,keyasint" json:"address"`
	AmountData AmountData                       `cbor:"1,keyasint" json:"amountData"`
	Extra      Optional[TransactionOutputExtra] `cbor:"2,keyasint" json:"extra"`
}

type TransactionOutputB

type TransactionOutputB struct {
	Address Address `cbor:"0,keyasint" json:"address"`
	Amount  uint64  `cbor:"1,keyasint" json:"amount"`
}

type TransactionOutputC

type TransactionOutputC struct {
	Address  Address
	Amount   uint64
	Address2 Address
	// contains filtered or unexported fields
}

type TransactionOutputD

type TransactionOutputD struct {
	Address    Address    `json:"address"`
	AmountData AmountData `json:"amountData"`
	Extra      []any      `json:"extra"`
	// contains filtered or unexported fields
}

type TransactionOutputE

type TransactionOutputE struct {
	Address    Address    `json:"address"`
	AmountData AmountData `json:"amountData"`
	Extra      HexBytes   `json:"extra"`
	// contains filtered or unexported fields
}

type TransactionOutputExtra

type TransactionOutputExtra struct {
	A uint64
	B HexBytes
	// contains filtered or unexported fields
}

type TransactionOutputF

type TransactionOutputF struct {
	Address    Address    `json:"address"`
	AmountData AmountData `json:"amountData"`
	// contains filtered or unexported fields
}

type TransactionOutputG

type TransactionOutputG struct {
	Address Address `json:"address"`
	Amount  uint64  `json:"amount"`
	// contains filtered or unexported fields
}

type TransactionOutputGeneric

type TransactionOutputGeneric struct {
	Address Address
	Amount  uint64
}

type TransactionWitnessSet

type TransactionWitnessSet struct {
	VkeyWitness      any `cbor:"0,keyasint" json:"-"`
	NativeScript     any `cbor:"1,keyasint" json:"-"`
	BootstrapWitness any `cbor:"2,keyasint" json:"-"`
	PlutusV1Script   any `cbor:"3,keyasint" json:"-"`
	PlutusData       any `cbor:"4,keyasint" json:"-"`
	Redeemer         any `cbor:"5,keyasint" json:"-"`
	PlutusV2Script   any `cbor:"6,keyasint" json:"-"`
	PlutusV3Script   any `cbor:"7,keyasint" json:"-"`
}

type TxRef

type TxRef struct {
	Hash        string `json:"hash"`
	BlockHeight uint64 `json:"blockHeight"`
}

type TxSigner

type TxSigner struct {
	Key       HexBytes `json:"key"`
	Signature HexBytes `json:"signature"`
	// contains filtered or unexported fields
}

type TxSubmission

type TxSubmission struct {
	Body          TxSubmissionBody    `json:"body"`
	Witness       TxSubmissionWitness `json:"witness"`
	AlonzoEval    bool                `json:"alonzoEval"`
	AuxiliaryData *AuxData            `json:"auxiliaryData"`
	// contains filtered or unexported fields
}

func (*TxSubmission) Hash

func (tx *TxSubmission) Hash() (hash HexBytes, err error)

type TxSubmissionBody

type TxSubmissionBody struct {
	Inputs            WithCborTag[[]TransactionInput] `cbor:"0,keyasint" json:"inputs"`
	Outputs           []SubtypeOf[TransactionOutput]  `cbor:"1,keyasint" json:"outputs"`
	Fee               uint64                          `cbor:"2,keyasint" json:"fee"`
	AuxiliaryDataHash HexBytes                        `cbor:"7,keyasint,omitempty" json:"auxiliaryDataHash,omitempty"`
}

type TxSubmissionWitness

type TxSubmissionWitness struct {
	Signers WithCborTag[[]TxSigner] `cbor:"0,keyasint" json:"signers"`
}

type UtxoWithHeight

type UtxoWithHeight struct {
	TxHash  string `json:"txHash"`
	Address string `json:"address"`
	Amount  uint64 `json:"amount"`
	Index   uint64 `json:"index"`
	Height  uint64 `json:"height"`
}

type VersionField1

type VersionField1 struct {
	Network                    NetworkMagic `json:"network"`
	InitiatorOnlyDiffusionMode bool         `json:"initiatorOnlyDiffusionMode"`
	// contains filtered or unexported fields
}

type VersionField2

type VersionField2 struct {
	Network                    NetworkMagic `json:"network,omitempty"`
	InitiatorOnlyDiffusionMode bool         `json:"initiatorOnlyDiffusionMode,omitempty"`
	PeerSharing                int          `json:"peerSharing,omitempty"`
	Query                      bool         `json:"query,omitempty"`
	// contains filtered or unexported fields
}

type VersionMap

type VersionMap struct {
	V4  VersionField1 `cbor:"4,keyasint"`
	V5  VersionField1 `cbor:"5,keyasint"`
	V6  VersionField1 `cbor:"6,keyasint"`
	V7  VersionField1 `cbor:"7,keyasint"`
	V8  VersionField1 `cbor:"8,keyasint"`
	V9  VersionField1 `cbor:"9,keyasint"`
	V10 VersionField1 `cbor:"10,keyasint"`
	V11 VersionField2 `cbor:"11,keyasint"`
	V12 VersionField2 `cbor:"12,keyasint"`
	V13 VersionField2 `cbor:"13,keyasint"`
}

type VrfCert

type VrfCert struct {
	Pt1 HexBytes `json:"pt1"`
	Pt2 HexBytes `json:"pt2"`
	// contains filtered or unexported fields
}

type WithCborTag

type WithCborTag[T any] struct {
	Tag   int64
	Value T
}

func (WithCborTag[T]) MarshalCBOR

func (w WithCborTag[T]) MarshalCBOR() (out []byte, err error)

func (WithCborTag[T]) MarshalJSON

func (w WithCborTag[T]) MarshalJSON() ([]byte, error)

func (*WithCborTag[T]) UnmarshalCBOR

func (w *WithCborTag[T]) UnmarshalCBOR(bytes []byte) error

type WithSubprotocol

type WithSubprotocol struct {
	Subprotocol Subprotocol `json:"subprotocol"`
	// contains filtered or unexported fields
}

func (*WithSubprotocol) GetSubprotocol

func (w *WithSubprotocol) GetSubprotocol() (subprotocol Subprotocol)

func (*WithSubprotocol) Raw

func (w *WithSubprotocol) Raw() []byte

func (*WithSubprotocol) SetRaw

func (w *WithSubprotocol) SetRaw(raw []byte)

func (*WithSubprotocol) SetSubprotocol

func (w *WithSubprotocol) SetSubprotocol(subprotocol Subprotocol)

Directories

Path Synopsis
cmd
addr_build command
addr_decode command
addr_gen command
rpc command

Jump to

Keyboard shortcuts

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