github.com/mit-dci/lit@v0.0.0-20221102210550-8c3d3b49f2ce/lncore/storage.go (about)

     1  package lncore
     2  
     3  // CoinSpecific is a meta-interface for coin-specific types.
     4  type CoinSpecific interface {
     5  	GetCoinTypeId() int32
     6  	Bytes() []byte
     7  }
     8  
     9  // LitStorage is an abstract wrapper layer around an arbitrary database.
    10  type LitStorage interface {
    11  	Open(dbpath string) error
    12  	IsSingleFile() bool
    13  	Close() error
    14  
    15  	GetWalletDB(uint32) LitWalletStorage
    16  	GetPeerDB() LitPeerStorage
    17  	GetChannelDB() LitChannelStorage
    18  
    19  	Check() error
    20  }
    21  
    22  // LitWalletStorage is storage for wallet data.
    23  type LitWalletStorage interface {
    24  	CoinSpecific
    25  
    26  	GetAddresses() ([]CoinAddress, error)
    27  
    28  	GetUtxos() ([]Utxo, error)
    29  	AddUtxo(Utxo) error
    30  	RemoveUtxo(Utxo) error
    31  
    32  	// TODO More
    33  }
    34  
    35  type CoinAddress struct {
    36  	cointype int32
    37  	addr     []byte
    38  }
    39  
    40  // AreCoinsCompatible checks to see if two coin-specific objects are for the same coin.
    41  func AreCoinsCompatible(a, b CoinSpecific) bool {
    42  	return a.GetCoinTypeId() == b.GetCoinTypeId()
    43  }