Documentation ¶
Index ¶
- Constants
- Variables
- type DlcManager
- func (mgr *DlcManager) AddContract() (*lnutil.DlcContract, error)
- func (mgr *DlcManager) AddOracle(key [33]byte, name string) (*DlcOracle, error)
- func (mgr *DlcManager) FindOracleByKey(key [33]byte) (*DlcOracle, error)
- func (mgr *DlcManager) ImportOracle(url string, name string) (*DlcOracle, error)
- func (mgr *DlcManager) InitDB(dbPath string) error
- func (mgr *DlcManager) ListContracts() ([]*lnutil.DlcContract, error)
- func (mgr *DlcManager) ListOracles() ([]*DlcOracle, error)
- func (mgr *DlcManager) LoadContract(idx uint64) (*lnutil.DlcContract, error)
- func (mgr *DlcManager) LoadOracle(idx uint64) (*DlcOracle, error)
- func (mgr *DlcManager) SaveContract(c *lnutil.DlcContract) error
- func (mgr *DlcManager) SaveOracle(o *DlcOracle) error
- func (mgr *DlcManager) SetContractCoinType(cIdx uint64, cointype uint32) error
- func (mgr *DlcManager) SetContractDatafeed(cIdx, feed uint64) error
- func (mgr *DlcManager) SetContractDivision(cIdx uint64, valueAllOurs, valueAllTheirs int64) error
- func (mgr *DlcManager) SetContractFunding(cIdx uint64, our, their int64) error
- func (mgr *DlcManager) SetContractOracle(cIdx, oIdx uint64) error
- func (mgr *DlcManager) SetContractRPoint(cIdx uint64, rPoint [33]byte) error
- func (mgr *DlcManager) SetContractSettlementTime(cIdx, time uint64) error
- type DlcOracle
- type DlcOracleRPointResponse
- type DlcOracleRestPubkeyResponse
Constants ¶
const COINTYPE_NOT_SET = ^uint32(0) // Max Uint
Variables ¶
var ( BKTOracles = []byte("Oracles") BKTContracts = []byte("Contracts") )
const strings for db usage
Functions ¶
This section is empty.
Types ¶
type DlcManager ¶
func NewManager ¶
func NewManager(dbPath string) (*DlcManager, error)
NewManager generates a new manager to add to the LitNode
func (*DlcManager) AddContract ¶
func (mgr *DlcManager) AddContract() (*lnutil.DlcContract, error)
AddContract starts a new draft contract
func (*DlcManager) AddOracle ¶
func (mgr *DlcManager) AddOracle(key [33]byte, name string) (*DlcOracle, error)
AddOracle manually imports an oracle using the pubkey (A) and a name for reference purposes
func (*DlcManager) FindOracleByKey ¶
func (mgr *DlcManager) FindOracleByKey(key [33]byte) (*DlcOracle, error)
FindOracleByKey function looks up an oracle based on its key
func (*DlcManager) ImportOracle ¶
func (mgr *DlcManager) ImportOracle(url string, name string) (*DlcOracle, error)
ImportOracle imports an oracle using a REST endpoint. It will save the oracle in the database and give it the passed name.
func (*DlcManager) InitDB ¶
func (mgr *DlcManager) InitDB(dbPath string) error
InitDB initializes the database for Discreet Log Contract storage
func (*DlcManager) ListContracts ¶
func (mgr *DlcManager) ListContracts() ([]*lnutil.DlcContract, error)
ListContracts loads all contracts from the database
func (*DlcManager) ListOracles ¶
func (mgr *DlcManager) ListOracles() ([]*DlcOracle, error)
ListOracles loads all oracles from the database and returns them as an array
func (*DlcManager) LoadContract ¶
func (mgr *DlcManager) LoadContract(idx uint64) (*lnutil.DlcContract, error)
LoadContract loads a contract from the database by index.
func (*DlcManager) LoadOracle ¶
func (mgr *DlcManager) LoadOracle(idx uint64) (*DlcOracle, error)
LoadOracle loads an oracle from the database by index.
func (*DlcManager) SaveContract ¶
func (mgr *DlcManager) SaveContract(c *lnutil.DlcContract) error
SaveContract saves a contract into the database. Will generate a new index if the passed object doesn't have one.
func (*DlcManager) SaveOracle ¶
func (mgr *DlcManager) SaveOracle(o *DlcOracle) error
SaveOracle saves an oracle into the database. Generates a new index if the passed oracle doesn't have one
func (*DlcManager) SetContractCoinType ¶
func (mgr *DlcManager) SetContractCoinType(cIdx uint64, cointype uint32) error
SetContractCoinType sets the cointype for a particular contract
func (*DlcManager) SetContractDatafeed ¶
func (mgr *DlcManager) SetContractDatafeed(cIdx, feed uint64) error
SetContractDatafeed will automatically fetch the R-point from the REST API, if an oracle is imported from a REST API. You need to set the settlement time first, because the R point is a key unique for the time and feed
func (*DlcManager) SetContractDivision ¶
func (mgr *DlcManager) SetContractDivision(cIdx uint64, valueAllOurs, valueAllTheirs int64) error
SetContractDivision sets the division of the contract settlement. If the oraclized value is valueAllOurs, then the entire value of the contract is payable to us. If the oraclized value is valueAllTheirs, then the entire value is paid to our peer. Between those, the value is divided linearly.
func (*DlcManager) SetContractFunding ¶
func (mgr *DlcManager) SetContractFunding(cIdx uint64, our, their int64) error
SetContractFunding sets the funding to the contract. It will specify how much we (the offering party) are funding, as well as
func (*DlcManager) SetContractOracle ¶
func (mgr *DlcManager) SetContractOracle(cIdx, oIdx uint64) error
SetContractOracle assigns a particular oracle to a contract - used for determining which pubkey A to use and can also allow for fetching R-points automatically when the oracle was imported from a REST api
func (*DlcManager) SetContractRPoint ¶
func (mgr *DlcManager) SetContractRPoint(cIdx uint64, rPoint [33]byte) error
SetContractRPoint allows you to manually set the R-point key if an oracle is not imported from a REST API
func (*DlcManager) SetContractSettlementTime ¶
func (mgr *DlcManager) SetContractSettlementTime(cIdx, time uint64) error
SetContractSettlementTime sets the unix epoch at which the oracle will sign a message containing the value the contract pays out on.
type DlcOracle ¶
type DlcOracle struct { Idx uint64 // Index of the oracle for refencing in commands A [33]byte // public key of the oracle Name string // Name of the oracle for display purposes Url string // Base URL of the oracle, if its REST based (optional) }
DlcOracle contains the identifying data of an Oracle
func DlcOracleFromBytes ¶
DlcOracleFromBytes parses a byte array that was serialized using DlcOracle.Bytes() back into a DlcOracle struct
type DlcOracleRPointResponse ¶
type DlcOracleRPointResponse struct {
RHex string `json:"R"`
}
DlcOracleRPointResponse is the response format for the REST API that returns the R-point
type DlcOracleRestPubkeyResponse ¶
type DlcOracleRestPubkeyResponse struct {
AHex string `json:"A"`
}
DlcOracleRestPubkeyResponse is the response format for the REST API that returns the pubkey