common

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainClientKey   = "Key.ChainClientKey"
	SsmClientKey     = "Key.SsmClientKey"
	SsmDeviceInfoKey = "Key.SsmDeviceInfoKey"
	CryptoModeKey    = "Key.CryptoModeKey"
)
View Source
const (
	CryptoAddressNextDepositSubject = chanPrefix + "CryptoAddress.NextDeposit"
	CryptoAddressNewDepositSubject  = chanPrefix + "CryptoAddress.NewDeposit"
	AddressInfoSubject              = chanPrefix + "CryptoAddress.AddressInfo"
)

Variables

This section is empty.

Functions

func ChainClientContext

func ChainClientContext(ctx context.Context, chain string, client ChainClient) context.Context

func CryptoModeContext added in v0.0.5

func CryptoModeContext(ctx context.Context, mode CryptoMode) context.Context

func SsmClientContext added in v0.0.5

func SsmClientContext(ctx context.Context, device string, client SsmClient) context.Context

func SsmDeviceInfoContext added in v0.0.5

func SsmDeviceInfoContext(ctx context.Context, info SsmDeviceInfo) context.Context

Types

type AddressInfo

type AddressInfo struct {
	Chain          string
	PublicAddress  string
	Unconfidential string
	IsValid        bool
}

func (*AddressInfo) Decode added in v0.0.5

func (p *AddressInfo) Decode(data []byte) error

func (*AddressInfo) Encode added in v0.0.5

func (p *AddressInfo) Encode() ([]byte, error)

type ChainClient

type ChainClient interface {
	GetNewAddress(ctx context.Context, account string) (string, error)
	ImportAddress(ctx context.Context, account, address, pubkey, blindingkey string) error
	GetAddressInfo(ctx context.Context, address string) (AddressInfo, error)
	GetBlockCount(ctx context.Context) (int64, error)
	ListUnspent(ctx context.Context, minConf, maxConf int, addresses ...string) ([]TransactionInfo, error)
	ListUnspentByAsset(ctx context.Context, minConf, maxConf int, asset string) ([]TransactionInfo, error)
	LockUnspent(ctx context.Context, unlock bool, transactions ...TransactionInfo) error
	ListLockUnspent(ctx context.Context) ([]TransactionInfo, error)
	GetTransaction(ctx context.Context, txID string) (TransactionInfo, error)

	SpendFunds(ctx context.Context, changeAddress string, inputs []UTXOInfo, outputs []SpendInfo, addressInfo GetAddressInfo, blindTransaction bool) (SpendTx, error)
}

ChainClient interface specification for bitcoin and elements

func ChainClientFromContext

func ChainClientFromContext(ctx context.Context, chain string) ChainClient

type CryptoAddress

type CryptoAddress struct {
	CryptoAddressID  uint64
	Chain            string
	AccountID        uint64
	PublicAddress    string
	Unconfidential   string
	IgnoreAccounting bool
}

func (*CryptoAddress) Decode

func (p *CryptoAddress) Decode(data []byte) error

func (*CryptoAddress) Encode

func (p *CryptoAddress) Encode() ([]byte, error)

type CryptoMode added in v0.0.5

type CryptoMode string
const (
	CryptoModeBitcoinCore CryptoMode = "bitcoin-core"
	CryptoModeCryptoSsm   CryptoMode = "crypto-ssm"
)

func CryptoModeFromContext added in v0.0.5

func CryptoModeFromContext(ctx context.Context) CryptoMode

type GetAddressInfo added in v0.0.5

type GetAddressInfo func(ctx context.Context, address string, isUnConfidential bool) (commands.SsmPath, error)

type SpendAssetInfo added in v0.0.5

type SpendAssetInfo struct {
	Hash          string
	ChangeAddress string
	ChangeAmount  float64
}

type SpendInfo added in v0.0.5

type SpendInfo struct {
	PublicAddress string
	Amount        float64
	// Asset optional
	Asset SpendAssetInfo
}

type SpendTx added in v0.0.5

type SpendTx struct {
	TxID string
}

type SsmAddress added in v0.0.5

type SsmAddress struct {
	Chain       string
	Address     string
	PubKey      string
	BlindingKey string
}

type SsmChain added in v0.0.5

type SsmChain string

type SsmClient added in v0.0.5

type SsmClient interface {
	NewAddress(ctx context.Context, ssmPath commands.SsmPath) (SsmAddress, error)
	SignTx(ctx context.Context, chain, inputransaction string, inputs ...commands.SignTxInputs) (string, error)
}

SsmClient interface specification for crypto-ssm

func SsmClientFromContext added in v0.0.5

func SsmClientFromContext(ctx context.Context, device string) SsmClient

type SsmDevice added in v0.0.5

type SsmDevice string

type SsmDeviceInfo added in v0.0.5

type SsmDeviceInfo interface {
	Fingerprint(ctx context.Context, chain SsmChain) (SsmFingerprint, error)
}

func SsmDeviceInfoFromContext added in v0.0.5

func SsmDeviceInfoFromContext(ctx context.Context) SsmDeviceInfo

type SsmFingerprint added in v0.0.5

type SsmFingerprint string

type TransactionInfo

type TransactionInfo struct {
	Chain         string
	Account       string
	Address       string
	Asset         string
	TxID          string
	Vout          int64
	Amount        float64
	Confirmations int64
	Spendable     bool
}

type UTXOInfo added in v0.0.5

type UTXOInfo struct {
	TxID string
	Vout int
}

Jump to

Keyboard shortcuts

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