multisig

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetWallet

func GetWallet(context view.Context, id string, opts ...token.ServiceOption) *token.OwnerWallet

GetWallet returns the wallet whose id is the passed id

func NewFinalityView

func NewFinalityView(tx *Transaction, opts ...ttx.TxOption) view.View

func RequestRecipientIdentity

func RequestRecipientIdentity(context view.Context, parties []token.Identity, opts ...token.ServiceOption) (token.Identity, error)

RequestRecipientIdentity requests the recipient identity for the given parties. It returns a multisig identity. All the parties are notified about the participants in the multisig identity.

Types

type EscrowAuth

type EscrowAuth struct {
	WalletService driver.WalletService
}

EscrowAuth implements the Authorization interface for this script

func NewEscrowAuth

func NewEscrowAuth(walletService driver.WalletService) *EscrowAuth

func (*EscrowAuth) AmIAnAuditor

func (s *EscrowAuth) AmIAnAuditor() bool

AmIAnAuditor returns false for script ownership

func (*EscrowAuth) IsMine

func (s *EscrowAuth) IsMine(ctx context.Context, tok *token3.Token) (string, []string, bool)

IsMine returns true if either the sender or the recipient is in one of the owner wallets. It returns an empty wallet id.

func (*EscrowAuth) Issued

func (s *EscrowAuth) Issued(ctx context.Context, issuer driver.Identity, tok *token3.Token) bool

func (*EscrowAuth) OwnerType

func (s *EscrowAuth) OwnerType(raw []byte) (driver.IdentityType, []byte, error)

type OwnerWallet

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

OwnerWallet is a combination of a wallet and a query service

func Wallet

func Wallet(context view.Context, wallet *token.OwnerWallet) *OwnerWallet

Wallet returns an OwnerWallet which contains a wallet and a query service

func (*OwnerWallet) ListTokens

func (w *OwnerWallet) ListTokens(ctx context.Context, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)

ListTokens returns a list of tokens that matches the passed options and whose recipient belongs to this wallet

func (*OwnerWallet) ListTokensAsEscrow

func (w *OwnerWallet) ListTokensAsEscrow(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)

ListTokensAsEscrow returns a list of tokens which are co-owned by OwnerWallet

func (*OwnerWallet) ListTokensIterator

func (w *OwnerWallet) ListTokensIterator(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)

ListTokensIterator returns an iterator of tokens that matches the passed options and whose recipient belongs to this wallet

type QueryEngine

type QueryEngine interface {
	// UnspentTokensIteratorBy returns an iterator over all unspent tokens by type and id. Type can be empty
	UnspentTokensIteratorBy(ctx context.Context, id string, tokenType token2.Type) (driver.UnspentTokensIterator, error)
}

type ReceiveSpendRequestView

type ReceiveSpendRequestView struct{}

ReceiveSpendRequestView receives a SpendRequest from the context's session.

func NewReceiveSpendRequestView

func NewReceiveSpendRequestView() *ReceiveSpendRequestView

func (*ReceiveSpendRequestView) Call

func (f *ReceiveSpendRequestView) Call(context view.Context) (any, error)

type ReceiveSpendTxView

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

ReceiveSpendTxView is the co-owner's view: it ACKs the SpendRequest and returns the assembled transaction received from the initiator without endorsing it. The caller is responsible for inspecting the transaction (e.g. confirming it consumes the expected token and does not include other tokens owned by this node) and, if the checks pass, running ttx.NewEndorseView(tx) to produce the signature.

Splitting receive from endorse lets the application decide which business-logic checks to apply rather than baking a fixed policy into the library.

func NewReceiveSpendTxView

func NewReceiveSpendTxView(request *SpendRequest) *ReceiveSpendTxView

NewReceiveSpendTxView returns a new ReceiveSpendTxView for the given request.

func (*ReceiveSpendTxView) Call

func (a *ReceiveSpendTxView) Call(context view.Context) (any, error)

Call implements view.View. It sends the SpendResponse ACK, receives the assembled transaction, and returns it without endorsing. Endorsement is the caller's responsibility once any business-logic checks pass.

type RequestSpendView

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

RequestSpendView sends a SpendRequest to all parties and waits for their responses

func NewRequestSpendView

func NewRequestSpendView(unspentToken *token.UnspentToken, opts ...token2.ServiceOption) *RequestSpendView

func (*RequestSpendView) Call

func (c *RequestSpendView) Call(context view.Context) (any, error)

func (*RequestSpendView) WithTimeout

func (c *RequestSpendView) WithTimeout(timeout time.Duration) *RequestSpendView

type SpendRequest

type SpendRequest struct {
	Token *token.UnspentToken
}

SpendRequest is the request to spend a token

func ReceiveSpendRequest

func ReceiveSpendRequest(context view.Context, opts ...ttx.TxOption) (*SpendRequest, error)

func (*SpendRequest) Bytes

func (r *SpendRequest) Bytes() ([]byte, error)

func (*SpendRequest) String

func (r *SpendRequest) String() string

type SpendResponse

type SpendResponse struct {
	Err error
}

SpendResponse is the response to a SpendRequest

type TokenVault

type TokenVault interface {
	DeleteTokens(ctx context.Context, toDelete ...*token2.ID) error
}

type Transaction

type Transaction struct {
	*ttx.Transaction
}

Transaction wraps a ttx.Transaction to provide a more user-friendly API for multisig transactions.

func ReceiveSpendTx

func ReceiveSpendTx(context view.Context, request *SpendRequest) (*Transaction, error)

ReceiveSpendTx is a convenience wrapper that runs ReceiveSpendTxView and returns the unsigned spend transaction so the caller can inspect it before deciding whether to endorse.

func Wrap

func Wrap(tx *ttx.Transaction) *Transaction

Wrap wraps a ttx.Transaction to provide a more user-friendly API for multisig transactions.

func (*Transaction) Lock

func (t *Transaction) Lock(senderWallet *token2.OwnerWallet, tokenType token.Type, amount uint64, recipient token2.Identity, opts ...token2.TransferOption) error

Lock locks the given amount of tokens of the given type in the sender's wallet and transfers them to the recipient.

func (*Transaction) Spend

func (t *Transaction) Spend(senderWallet *token2.OwnerWallet, at *token.UnspentToken, recipient token2.Identity, opts ...token2.TransferOption) error

Spend spends the given token.

type Vault

type Vault interface {
	DeleteTokens(ctx context.Context, toDelete ...*token2.ID) error
}

Jump to

Keyboard shortcuts

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