custody

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Account_Config           = [8]byte{155, 12, 170, 224, 30, 250, 204, 130}
	Account_WithdrawalRecord = [8]byte{88, 59, 154, 202, 216, 210, 211, 237}
)

Account discriminators

View Source
var (
	Event_Deposited      = [8]byte{111, 141, 26, 45, 161, 35, 100, 57}
	Event_Executed       = [8]byte{8, 232, 139, 132, 197, 45, 29, 164}
	Event_SignersUpdated = [8]byte{71, 177, 47, 237, 194, 42, 20, 105}
)

Event discriminators

View Source
var (
	Instruction_DepositSol    = [8]byte{108, 81, 78, 117, 125, 155, 56, 200}
	Instruction_DepositSpl    = [8]byte{224, 0, 198, 175, 198, 47, 105, 204}
	Instruction_Execute       = [8]byte{130, 221, 242, 154, 13, 193, 189, 29}
	Instruction_Initialize    = [8]byte{175, 175, 109, 31, 13, 152, 155, 237}
	Instruction_UpdateSigners = [8]byte{228, 82, 68, 150, 92, 66, 140, 174}
)

Instruction discriminators

View Source
var ProgramID = solanago.MustPublicKeyFromBase58("98eVpih8X9CAcgU9bzNB9V7VtkRrnFZUmqzEnsq7cfmg")

Functions

func NewDepositSolInstruction

func NewDepositSolInstruction(

	accountParam [20]uint8,
	referenceParam [32]uint8,
	amountParam uint64,

	depositorAccount solanago.PublicKey,
	vaultAccount solanago.PublicKey,
	systemProgramAccount solanago.PublicKey,
	eventAuthorityAccount solanago.PublicKey,
	programAccount solanago.PublicKey,
) (solanago.Instruction, error)

Builds a "deposit_sol" instruction. Native SOL deposit crediting the 20-byte clearnet `account`, with an // optional ADR-015 sub-account `reference` ([0u8; 32] for none).

func NewDepositSplInstruction

func NewDepositSplInstruction(

	accountParam [20]uint8,
	referenceParam [32]uint8,
	amountParam uint64,

	depositorAccount solanago.PublicKey,
	mintAccount solanago.PublicKey,
	depositorAtaAccount solanago.PublicKey,
	vaultAccount solanago.PublicKey,
	vaultAtaAccount solanago.PublicKey,
	tokenProgramAccount solanago.PublicKey,
	associatedTokenProgramAccount solanago.PublicKey,
	eventAuthorityAccount solanago.PublicKey,
	programAccount solanago.PublicKey,
) (solanago.Instruction, error)

Builds a "deposit_spl" instruction. SPL token deposit crediting the 20-byte clearnet `account`, with an // optional ADR-015 sub-account `reference` ([0u8; 32] for none).

func NewExecuteInstruction

func NewExecuteInstruction(

	toParam solanago.PublicKey,
	mintParam solanago.PublicKey,
	amountParam uint64,
	withdrawalIdParam [32]uint8,
	sigIxIndexParam uint8,
	deadlineParam int64,

	feePayerAccount solanago.PublicKey,
	configAccount solanago.PublicKey,
	vaultAccount solanago.PublicKey,
	withdrawalAccount solanago.PublicKey,
	recipientAccount solanago.PublicKey,
	instructionsAccount solanago.PublicKey,
	systemProgramAccount solanago.PublicKey,
	eventAuthorityAccount solanago.PublicKey,
	programAccount solanago.PublicKey,
) (solanago.Instruction, error)

Builds a "execute" instruction. Execute a quorum-authorized withdrawal (native or SPL).

func NewInitializeInstruction

func NewInitializeInstruction(

	signersParam []solanago.PublicKey,
	thresholdParam uint8,
	chainIdParam uint64,

	configAccount solanago.PublicKey,
	payerAccount solanago.PublicKey,
	programAccount solanago.PublicKey,
	programDataAccount solanago.PublicKey,
	systemProgramAccount solanago.PublicKey,
) (solanago.Instruction, error)

Builds a "initialize" instruction. One-time setup of the Config PDA (signer set, threshold, chain_id).

func NewUpdateSignersInstruction

func NewUpdateSignersInstruction(

	newSignersParam []solanago.PublicKey,
	newThresholdParam uint8,
	sigIxIndexParam uint8,

	configAccount solanago.PublicKey,
	instructionsAccount solanago.PublicKey,
	eventAuthorityAccount solanago.PublicKey,
	programAccount solanago.PublicKey,
) (solanago.Instruction, error)

Builds a "update_signers" instruction. In-place signer rotation (ADR-013 Flow A).

func ParseAnyAccount

func ParseAnyAccount(accountData []byte) (any, error)

func ParseAnyEvent

func ParseAnyEvent(eventData []byte) (any, error)

Types

type Config

type Config struct {
	Signers     []solanago.PublicKey `json:"signers"`
	Threshold   uint8                `json:"threshold"`
	SignerNonce uint64               `json:"signerNonce"`
	ChainId     uint64               `json:"chainId"`
	Bump        uint8                `json:"bump"`
}

Config PDA — seeds `["config"]`. The on-chain analogue of `Custody.sol`'s signer set + threshold + nonce. `signers` is kept strictly ascending so a linear membership scan in the Ed25519 verifier is unambiguous.

func ParseAccount_Config

func ParseAccount_Config(accountData []byte) (*Config, error)

func UnmarshalConfig

func UnmarshalConfig(buf []byte) (*Config, error)

func (Config) Marshal

func (obj Config) Marshal() ([]byte, error)

func (Config) MarshalWithEncoder

func (obj Config) MarshalWithEncoder(encoder *binary.Encoder) (err error)

func (*Config) Unmarshal

func (obj *Config) Unmarshal(buf []byte) error

func (*Config) UnmarshalWithDecoder

func (obj *Config) UnmarshalWithDecoder(decoder *binary.Decoder) (err error)

type Deposited

type Deposited struct {
	Depositor solanago.PublicKey `json:"depositor"`
	Account   [20]uint8          `json:"account"`
	Reference [32]uint8          `json:"reference"`
	Mint      solanago.PublicKey `json:"mint"`
	Amount    uint64             `json:"amount"`
}

Emitted by `deposit_sol` / `deposit_spl` via `emit_cpi!`. The custody watcher decodes these from the self-CPI inner instructions and turns each into a `chains.DepositEvent`. `mint == Pubkey::default()` denotes native SOL (the analogue of EVM's `asset == address(0)`). `account` is the 20-byte clearnet account the deposit credits. `reference` is the ADR-015 opaque sub-account selector ([0u8; 32] when absent); never interpreted on-chain, the watcher folds it into the account URI as a /tag/<reference> suffix.

func ParseEvent_Deposited

func ParseEvent_Deposited(eventData []byte) (*Deposited, error)

func UnmarshalDeposited

func UnmarshalDeposited(buf []byte) (*Deposited, error)

func (Deposited) Marshal

func (obj Deposited) Marshal() ([]byte, error)

func (Deposited) MarshalWithEncoder

func (obj Deposited) MarshalWithEncoder(encoder *binary.Encoder) (err error)

func (*Deposited) Unmarshal

func (obj *Deposited) Unmarshal(buf []byte) error

func (*Deposited) UnmarshalWithDecoder

func (obj *Deposited) UnmarshalWithDecoder(decoder *binary.Decoder) (err error)

type Executed

type Executed struct {
	WithdrawalId [32]uint8          `json:"withdrawalId"`
	To           solanago.PublicKey `json:"to"`
	Mint         solanago.PublicKey `json:"mint"`
	Amount       uint64             `json:"amount"`
}

Emitted by `execute` via `emit_cpi!`. The watcher writes a ledger row keyed by `withdrawal_id` (the reconciliation key against `signing_wal`).

func ParseEvent_Executed

func ParseEvent_Executed(eventData []byte) (*Executed, error)

func UnmarshalExecuted

func UnmarshalExecuted(buf []byte) (*Executed, error)

func (Executed) Marshal

func (obj Executed) Marshal() ([]byte, error)

func (Executed) MarshalWithEncoder

func (obj Executed) MarshalWithEncoder(encoder *binary.Encoder) (err error)

func (*Executed) Unmarshal

func (obj *Executed) Unmarshal(buf []byte) error

func (*Executed) UnmarshalWithDecoder

func (obj *Executed) UnmarshalWithDecoder(decoder *binary.Decoder) (err error)

type SignersUpdated

type SignersUpdated struct {
	Signers     []solanago.PublicKey `json:"signers"`
	Threshold   uint8                `json:"threshold"`
	SignerNonce uint64               `json:"signerNonce"`
}

Emitted by `update_signers` via `emit_cpi!`.

func ParseEvent_SignersUpdated

func ParseEvent_SignersUpdated(eventData []byte) (*SignersUpdated, error)

func UnmarshalSignersUpdated

func UnmarshalSignersUpdated(buf []byte) (*SignersUpdated, error)

func (SignersUpdated) Marshal

func (obj SignersUpdated) Marshal() ([]byte, error)

func (SignersUpdated) MarshalWithEncoder

func (obj SignersUpdated) MarshalWithEncoder(encoder *binary.Encoder) (err error)

func (*SignersUpdated) Unmarshal

func (obj *SignersUpdated) Unmarshal(buf []byte) error

func (*SignersUpdated) UnmarshalWithDecoder

func (obj *SignersUpdated) UnmarshalWithDecoder(decoder *binary.Decoder) (err error)

type WithdrawalRecord

type WithdrawalRecord struct {
	To     solanago.PublicKey `json:"to"`
	Mint   solanago.PublicKey `json:"mint"`
	Amount uint64             `json:"amount"`
}

WithdrawalRecord PDA — seeds `["withdrawal", withdrawal_id]`. Its mere existence is the replay guard: `execute` creates it with `init`, so a second execution of the same `withdrawal_id` fails at account creation. The analogue of `Custody.sol`'s `executed[withdrawalId]` storage slot; never closed (closing would re-enable replay).

func ParseAccount_WithdrawalRecord

func ParseAccount_WithdrawalRecord(accountData []byte) (*WithdrawalRecord, error)

func UnmarshalWithdrawalRecord

func UnmarshalWithdrawalRecord(buf []byte) (*WithdrawalRecord, error)

func (WithdrawalRecord) Marshal

func (obj WithdrawalRecord) Marshal() ([]byte, error)

func (WithdrawalRecord) MarshalWithEncoder

func (obj WithdrawalRecord) MarshalWithEncoder(encoder *binary.Encoder) (err error)

func (*WithdrawalRecord) Unmarshal

func (obj *WithdrawalRecord) Unmarshal(buf []byte) error

func (*WithdrawalRecord) UnmarshalWithDecoder

func (obj *WithdrawalRecord) UnmarshalWithDecoder(decoder *binary.Decoder) (err error)

Jump to

Keyboard shortcuts

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