Documentation ¶
Overview ¶
Package wallet contains the definition of the wallet backend interfaces, and manages a global wallet backend instance that is accessible from the rest of the project.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IndexOfAddr ¶
IndexOfAddr returns the index of the given address in the address slice, or -1 if it is not part of the slice.
func SetBackend ¶
func SetBackend(b Backend)
SetBackend sets the global wallet backend. Must not be called directly but through importing the needed backend.
func SetBackendTest ¶
SetBackendTest is a generic test to test that the wallet backend is set correctly.
Types ¶
type Account ¶
type Account interface { // Address used by this account. Address() Address // SignData requests a signature from this account. // It returns the signature or an error. SignData(data []byte) ([]byte, error) }
Account represents a single account.
type Address ¶
type Address interface { io.Serializer // Bytes should return the representation of the address as byte slice. Bytes() []byte // String converts this address to a string fmt.Stringer // Equals checks the equality of two addresses Equals(Address) bool }
Address represents a identifier used in a cryptocurrency. It is dependent on the currency and needs to be implemented for every blockchain.
type Backend ¶
type Backend interface { // DecodeAddress reads and decodes an address from an io.Writer DecodeAddress(io.Reader) (Address, error) // DecodeSig reads a signature from the provided stream. It is needed for // decoding of wire messages. DecodeSig(io.Reader) (Sig, error) // VerifySignature verifies if this signature was signed by this address. // It should return an error iff the signature or message are malformed. // If the signature does not match the address it should return false, nil VerifySignature(msg []byte, sign Sig, a Address) (bool, error) }
Backend provides useful methods for this blockchain.