wallet-interface icon indicating copy to clipboard operation
wallet-interface copied to clipboard

Exposed wallet-interface types should be interfaces types and not concrete types

Open placer14 opened this issue 5 years ago • 0 comments

Developers and implementors want to promote better abstractions and to motivate anything which consume wallet-interface to rely on their local implementations instead of on internal types. The exported types returned by interface functions mentioned in the wallet-interface package should be represented as interfaces as well. For example:

type TransactionRecord struct {
	Txid      string
	Index     uint32
	Value     int64
	Address   string
	Spent     bool
	Timestamp time.Time
}

should become

type TransactionRecord interface {
	Txid()      string
	Index()     uint32
	Value()     int64
	Address()   string
	Spent()     bool
	Timestamp() time.Time
}

Exported Types to migrate:

  • [ ] Txn
  • [ ] Utxo
  • [ ] Stxo
  • [ ] Txns
  • [ ] Keys
  • [ ] FeeLevel
  • [ ] TransactionInput
  • [ ] TransactionOutput
  • [ ] Signature
  • [ ] TransactionCallback
  • [ ] TransactionRecord

placer14 avatar May 22 '19 19:05 placer14