Documentation ¶
Index ¶
- Variables
- type DepositConfirmation
- type PhononTerminal
- func (t *PhononTerminal) AddSession(sess *Session)
- func (t *PhononTerminal) GenerateMock() (string, error)
- func (t *PhononTerminal) ListSessions() []*Session
- func (t *PhononTerminal) RefreshSessions() ([]*Session, error)
- func (t *PhononTerminal) RemoveSession(sessID string)
- func (t *PhononTerminal) SessionFromID(id string) *Session
- type Session
- func (s *Session) CardPair(initPairingData []byte) ([]byte, error)
- func (s *Session) CardPair2(cardPairData []byte) (cardPair2Data []byte, err error)
- func (s *Session) ChangePIN(pin string) error
- func (s *Session) Connect() error
- func (s *Session) ConnectToCounterparty(cardID string) error
- func (s *Session) ConnectToLocalProvider() error
- func (s *Session) ConnectToRemoteProvider(RemoteURL string) error
- func (s *Session) CreatePhonon() (keyIndex uint16, pubkey model.PhononPubKey, err error)
- func (s *Session) DestroyPhonon(keyIndex uint16) (privKey *ecdsa.PrivateKey, err error)
- func (s *Session) FinalizeCardPair(cardPair2Data []byte) error
- func (s *Session) FinalizeDepositPhonon(dc DepositConfirmation) error
- func (s *Session) FinalizeDepositPhonons(confirmations []DepositConfirmation) ([]DepositConfirmation, error)
- func (s *Session) GenerateInvoice() ([]byte, error)
- func (s *Session) GetCertificate() (*cert.CardCertificate, error)
- func (s *Session) GetName() string
- func (s *Session) GetPhononPubKey(keyIndex uint16, crv model.CurveType) (pubkey model.PhononPubKey, err error)
- func (s *Session) IdentifyCard(nonce []byte) (cardPubKey *ecdsa.PublicKey, cardSig *util.ECDSASignature, err error)
- func (s *Session) Init(pin string) error
- func (s *Session) InitCardPairing(receiverCert cert.CardCertificate) ([]byte, error)
- func (s *Session) InitDepositPhonons(currencyType model.CurrencyType, denoms []*model.Denomination) (phonons []*model.Phonon, err error)
- func (s *Session) IsInitialized() bool
- func (s *Session) IsPairedToCard() bool
- func (s *Session) IsUnlocked() bool
- func (s *Session) ListPhonons(currencyType model.CurrencyType, lessThanValue uint64, greaterThanValue uint64) ([]*model.Phonon, error)
- func (s *Session) PairWithRemoteCard(remoteCard model.CounterpartyPhononCard) error
- func (s *Session) ReceiveInvoice(invoiceData []byte) error
- func (s *Session) ReceivePhonons(phononTransferPacket []byte) error
- func (s *Session) RedeemPhonon(p *model.Phonon, redeemAddress string) (transactionData string, privKeyString string, err error)
- func (s *Session) SendPhonons(keyIndices []uint16) error
- func (s *Session) SetDescriptor(p *model.Phonon) error
- func (s *Session) SetPaired(status bool)
- func (s *Session) VerifyPIN(pin string) error
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyInitialized = errors.New("card is already initialized with a pin")
var ErrCardNotPairedToCard = errors.New("card not paired with any other card")
var ErrInitFailed = errors.New("card failed initialized check after init command accepted")
var ErrNoSession error = errors.New("No connected session with id found")
var ErrRemoteNotPaired error = errors.New("no remote card paired")
var ErrorRequestNotRecognized = errors.New("Unrecognized request sent to session")
Functions ¶
This section is empty.
Types ¶
type DepositConfirmation ¶
Phonon Deposit and Redeem higher level methods
type PhononTerminal ¶
type PhononTerminal struct {
// contains filtered or unexported fields
}
func NewPhononTerminal ¶
func NewPhononTerminal() *PhononTerminal
NewPhononTerminal returns a new reference to the global phonon terminal singleton.
func (*PhononTerminal) AddSession ¶
func (t *PhononTerminal) AddSession(sess *Session)
func (*PhononTerminal) GenerateMock ¶
func (t *PhononTerminal) GenerateMock() (string, error)
// basic multi-session management //
func (*PhononTerminal) ListSessions ¶
func (t *PhononTerminal) ListSessions() []*Session
func (*PhononTerminal) RefreshSessions ¶
func (t *PhononTerminal) RefreshSessions() ([]*Session, error)
func (*PhononTerminal) RemoveSession ¶
func (t *PhononTerminal) RemoveSession(sessID string)
func (*PhononTerminal) SessionFromID ¶
func (t *PhononTerminal) SessionFromID(id string) *Session
type Session ¶
type Session struct { RemoteCard model.CounterpartyPhononCard Cert *cert.CardCertificate ElementUsageMtex sync.Mutex // contains filtered or unexported fields }
The session struct handles a local connection with a card Keeps a client side cache of the card state to make interaction with the card through this API more convenient
func NewSession ¶
func NewSession(storage model.PhononCard) (s *Session, err error)
Creates a new card session, automatically connecting if the card is already initialized with a PIN The next step is to run VerifyPIN to gain access to the secure commands on the card
func (*Session) ConnectToCounterparty ¶
func (*Session) ConnectToLocalProvider ¶
func (*Session) ConnectToRemoteProvider ¶
func (*Session) CreatePhonon ¶
func (s *Session) CreatePhonon() (keyIndex uint16, pubkey model.PhononPubKey, err error)
func (*Session) DestroyPhonon ¶
func (s *Session) DestroyPhonon(keyIndex uint16) (privKey *ecdsa.PrivateKey, err error)
func (*Session) FinalizeCardPair ¶
func (*Session) FinalizeDepositPhonon ¶
func (s *Session) FinalizeDepositPhonon(dc DepositConfirmation) error
func (*Session) FinalizeDepositPhonons ¶
func (s *Session) FinalizeDepositPhonons(confirmations []DepositConfirmation) ([]DepositConfirmation, error)
func (*Session) GenerateInvoice ¶
func (*Session) GetCertificate ¶
func (s *Session) GetCertificate() (*cert.CardCertificate, error)
func (*Session) GetPhononPubKey ¶
func (*Session) IdentifyCard ¶
func (*Session) Init ¶
Initializes the card with a PIN Also creates a secure channel and verifies the PIN that was just set
func (*Session) InitCardPairing ¶
func (s *Session) InitCardPairing(receiverCert cert.CardCertificate) ([]byte, error)
func (*Session) InitDepositPhonons ¶
func (s *Session) InitDepositPhonons(currencyType model.CurrencyType, denoms []*model.Denomination) (phonons []*model.Phonon, err error)
InitDepositPhonons takes a currencyType and a map of denominations to quantity, Creates the required phonons, deposits them using the configured service for the asset and upon success sets their descriptors
func (*Session) IsInitialized ¶
func (*Session) IsPairedToCard ¶
func (*Session) IsUnlocked ¶
func (*Session) ListPhonons ¶
func (*Session) PairWithRemoteCard ¶
func (s *Session) PairWithRemoteCard(remoteCard model.CounterpartyPhononCard) error
func (*Session) ReceiveInvoice ¶
func (*Session) ReceivePhonons ¶
func (*Session) RedeemPhonon ¶
func (s *Session) RedeemPhonon(p *model.Phonon, redeemAddress string) (transactionData string, privKeyString string, err error)
RedeemPhonon takes a phonon and a redemptionAddress as an asset specific address string (usually hex encoded) and submits a transaction to the asset's chain in order to transfer it to another address In case the on chain transfer fails, returns the private key as a fallback so that access to the asset is not lost