Documentation ¶
Index ¶
- Constants
- Variables
- func GetHTLCOut(q *Qchan, h HTLC, tx *wire.MsgTx, mine bool) (*wire.TxOut, uint32, error)
- func GetStateIdxFromTx(tx *wire.MsgTx, x uint64) uint64
- func GoAnnounce(priv *koblitz.PrivateKey, port int, litadr string, trackerURL string)
- func SetStateIdxBits(tx *wire.MsgTx, idx, x uint64) error
- func SpendMultiSigWitStack(pre, sigA, sigB []byte) [][]byte
- type ChanData
- type ChannelStateUpdateEvent
- type DualFundingResult
- type HTLC
- type InFlightDualFund
- type InFlightFund
- type InFlightMultihop
- type JusticeTx
- type LinkDesc
- type LitMsgWrapperMessage
- type LitNode
- func (nd *LitNode) AcceptDlc(cIdx uint64) error
- func (nd *LitNode) AddContract() (*lnutil.DlcContract, error)
- func (nd *LitNode) ApplyChanDataToQchan(data *ChanData, qc *Qchan) error
- func (nd *LitNode) AutoReconnect(port int, interval int64, connectedCoinOnly bool)
- func (nd *LitNode) BreakChannel(q *Qchan) error
- func (nd *LitNode) BuildDlcFundingTransaction(c *lnutil.DlcContract) (wire.MsgTx, error)
- func (nd *LitNode) BuildDualFundingTransaction() (*wire.MsgTx, error)
- func (nd *LitNode) BuildJusticeSig(q *Qchan) error
- func (nd *LitNode) ChannelHandler(msg lnutil.LitMsg, peer *RemotePeer) error
- func (nd *LitNode) ClaimHTLC(R [16]byte) ([][32]byte, error)
- func (nd *LitNode) ClaimHTLCOnChain(q *Qchan, h HTLC) (*wire.MsgTx, error)
- func (nd *LitNode) ClaimHTLCTimeouts(coinType uint32, height int32) ([][32]byte, error)
- func (nd *LitNode) ClearHTLC(qc *Qchan, R [16]byte, HTLCIdx uint32, data [32]byte) error
- func (nd *LitNode) CloseHandler(msg lnutil.LitMsg) error
- func (nd *LitNode) CloseReqHandler(msg lnutil.CloseReqMsg)
- func (nd *LitNode) ConnectedToPeer(peer uint32) bool
- func (nd *LitNode) CoopClose(q *Qchan) error
- func (nd *LitNode) DeclineDlc(cIdx uint64, reason uint8) error
- func (nd *LitNode) DeltaSigHandler(msg lnutil.DeltaSigMsg, qc *Qchan) error
- func (nd *LitNode) DialPeer(connectAdr string) error
- func (nd *LitNode) DlcAcceptHandler(msg lnutil.DlcOfferAcceptMsg, peer *RemotePeer) error
- func (nd *LitNode) DlcContractAckHandler(msg lnutil.DlcContractAckMsg, peer *RemotePeer)
- func (nd *LitNode) DlcDeclineHandler(msg lnutil.DlcOfferDeclineMsg, peer *RemotePeer)
- func (nd *LitNode) DlcFundingSigsHandler(msg lnutil.DlcContractFundingSigsMsg, peer *RemotePeer)
- func (nd *LitNode) DlcOfferHandler(msg lnutil.DlcOfferMsg, peer *RemotePeer)
- func (nd *LitNode) DlcSigProofHandler(msg lnutil.DlcContractSigProofMsg, peer *RemotePeer)
- func (nd *LitNode) DualFundAccept() *DualFundingResult
- func (nd *LitNode) DualFundChanAckHandler(msg lnutil.DualFundingChanAckMsg, peer *RemotePeer)
- func (nd *LitNode) DualFundChanDescHandler(msg lnutil.ChanDescMsg) error
- func (nd *LitNode) DualFundChannel(peerIdx, cointype uint32, ourAmount int64, theirAmount int64) (*DualFundingResult, error)
- func (nd *LitNode) DualFundDecline(reason uint8)
- func (nd *LitNode) DualFundSigProofHandler(msg lnutil.SigProofMsg, peer *RemotePeer)
- func (nd *LitNode) DualFundingAcceptHandler(msg lnutil.DualFundingAcceptMsg)
- func (nd *LitNode) DualFundingDeclHandler(msg lnutil.DualFundingDeclMsg)
- func (nd *LitNode) DualFundingHandler(msg lnutil.LitMsg, peer *RemotePeer) error
- func (nd *LitNode) DualFundingReqHandler(msg lnutil.DualFundingReqMsg)
- func (nd *LitNode) DumpJusticeDB() ([]JusticeTx, error)
- func (nd *LitNode) FWDHandler(msg lnutil.LitMsg) error
- func (nd *LitNode) FailChannel(q *Qchan)
- func (nd *LitNode) FindHTLCsByHash(hash [32]byte) ([]HTLC, []*Qchan, error)
- func (nd *LitNode) FindHTLCsByTimeoutHeight(coinType uint32, height int32) ([]HTLC, []*Qchan, error)
- func (nd *LitNode) FindPath(targetPkh [20]byte, destCoinType uint32, originCoinType uint32, amount int64) ([]lnutil.RouteHop, error)
- func (nd *LitNode) FindPeerIndexByAddress(lnAdr string) (uint32, error)
- func (nd *LitNode) FundChannel(peerIdx, cointype uint32, ccap, initSend int64, data [32]byte) (uint32, error)
- func (nd *LitNode) FundContract(c *lnutil.DlcContract) error
- func (nd *LitNode) GapSigRevHandler(msg lnutil.GapSigRevMsg, q *Qchan) error
- func (nd *LitNode) GetAllMultihopPayments() ([]*InFlightMultihop, error)
- func (nd *LitNode) GetAllQchans() ([]*Qchan, error)
- func (nd *LitNode) GetConnectedPeerList() []SimplePeerInfo
- func (nd *LitNode) GetDHSecret(q *Qchan) ([]byte, error)
- func (nd *LitNode) GetElkremRoot(k portxo.KeyGen) (chainhash.Hash, error)
- func (nd *LitNode) GetHTLC(op *wire.OutPoint) (HTLC, *Qchan, error)
- func (nd *LitNode) GetLisAddressAndPorts() (string, []string)
- func (nd *LitNode) GetLnAddr() string
- func (nd *LitNode) GetNicknameFromPeerIdx(idx uint32) string
- func (nd *LitNode) GetPendingRemoteControlRequests() ([]*RemoteControlAuthorization, error)
- func (nd *LitNode) GetPubHostFromPeerIdx(idx uint32) ([33]byte, string)
- func (nd *LitNode) GetQchan(opArr [36]byte) (*Qchan, error)
- func (nd *LitNode) GetQchanByIdx(cIdx uint32) (*Qchan, error)
- func (nd *LitNode) GetQchanOPfromIdx(cIdx uint32) ([36]byte, error)
- func (nd *LitNode) GetRemoteControlAuthorization(pub [33]byte) (*RemoteControlAuthorization, error)
- func (nd *LitNode) GetUsePub(k portxo.KeyGen, use uint32) (pubArr [33]byte, err error)
- func (nd *LitNode) HandleContractOPEvent(c *lnutil.DlcContract, opEvent *lnutil.OutPointEvent) error
- func (nd *LitNode) HashSigHandler(msg lnutil.HashSigMsg, qc *Qchan) error
- func (nd *LitNode) HeightEventHandler(HeightEventChan chan lnutil.HeightEvent)
- func (nd *LitNode) IdKey() *koblitz.PrivateKey
- func (nd *LitNode) InitRouting()
- func (nd *LitNode) LinkBaseWallet(privKey *[32]byte, birthHeight int32, resync bool, tower bool, host string, ...) error
- func (nd *LitNode) LinkMsgHandler(msg lnutil.LinkMsg)
- func (nd *LitNode) LoadJusticeSig(comnum uint64, pkh [20]byte) (JusticeTx, error)
- func (nd *LitNode) MultihopPaymentAckHandler(msg lnutil.MultihopPaymentAckMsg) error
- func (nd *LitNode) MultihopPaymentRequestHandler(msg lnutil.MultihopPaymentRequestMsg) error
- func (nd *LitNode) MultihopPaymentSetupHandler(msg lnutil.MultihopPaymentSetupMsg) error
- func (nd *LitNode) NewChanDataFromQchan(qc *Qchan) *ChanData
- func (nd *LitNode) NewQchanFromChanData(data *ChanData) (*Qchan, error)
- func (nd *LitNode) NextChannelIdx() (uint32, error)
- func (nd *LitNode) OPEventHandler(OPEventChan chan lnutil.OutPointEvent)
- func (nd *LitNode) OfferDlc(peerIdx uint32, cIdx uint64) error
- func (nd *LitNode) OfferHTLC(qc *Qchan, amt uint32, RHash [32]byte, locktime uint32, data [32]byte) error
- func (nd *LitNode) OpenDB(filename string) error
- func (nd *LitNode) PayMultihop(dstLNAdr string, originCoinType uint32, destCoinType uint32, amount int64) (bool, error)
- func (nd *LitNode) PeerHandler(msg lnutil.LitMsg, q *Qchan, peer *RemotePeer) error
- func (nd *LitNode) PointReqHandler(msg lnutil.PointReqMsg)
- func (nd *LitNode) PointRespHandler(msg lnutil.PointRespMsg) error
- func (nd *LitNode) PopulateQchanMap(peer *RemotePeer) error
- func (nd *LitNode) PopulateRates() error
- func (nd *LitNode) PreimageSigHandler(msg lnutil.PreimageSigMsg, qc *Qchan) error
- func (nd *LitNode) PrintBreakTxForDebugging(q *Qchan) error
- func (nd *LitNode) PushChannel(qc *Qchan, amt uint32, data [32]byte) error
- func (nd *LitNode) PushPullHandler(routedMsg lnutil.LitMsg, q *Qchan) error
- func (nd *LitNode) QChanAckHandler(msg lnutil.ChanAckMsg, peer *RemotePeer)
- func (nd *LitNode) QChanDescHandler(msg lnutil.ChanDescMsg) error
- func (nd *LitNode) QchanDeserializeFromBytes(buf []byte) (*Qchan, error)
- func (nd *LitNode) QchanInfo(q *Qchan) error
- func (nd *LitNode) QchanSerializeToBytes(qc *Qchan) []byte
- func (nd *LitNode) QchanUpdateFromBytes(qc *Qchan, buf []byte) error
- func (nd *LitNode) ReSendMsg(qc *Qchan) error
- func (nd *LitNode) ReloadQchanState(qc *Qchan) error
- func (nd *LitNode) RemoteControlRequestHandler(msg lnutil.RemoteControlRpcRequestMsg, peer *RemotePeer) error
- func (nd *LitNode) RemoteControlResponseHandler(msg lnutil.RemoteControlRpcResponseMsg, peer *RemotePeer) error
- func (nd *LitNode) RevHandler(msg lnutil.RevMsg, qc *Qchan) error
- func (nd *LitNode) SaveJusticeSig(comnum uint64, pkh [20]byte, txidsig [120]byte) error
- func (nd *LitNode) SaveMultihopPayment(p *InFlightMultihop) error
- func (nd *LitNode) SaveNicknameForPeerIdx(nickname string, idx uint32) error
- func (nd *LitNode) SaveQChan(q *Qchan) error
- func (nd *LitNode) SaveQchanState(q *Qchan) error
- func (nd *LitNode) SaveQchanUtxoData(q *Qchan) error
- func (nd *LitNode) SaveRemoteControlAuthorization(pub [33]byte, auth *RemoteControlAuthorization) error
- func (nd *LitNode) SelfPushHandler(msg lnutil.LitMsg) error
- func (nd *LitNode) SendChat(peer uint32, chat string) error
- func (nd *LitNode) SendDeltaSig(q *Qchan) error
- func (nd *LitNode) SendGapSigRev(q *Qchan) error
- func (nd *LitNode) SendHashSig(q *Qchan) error
- func (nd *LitNode) SendPreimageSig(q *Qchan, Idx uint32) error
- func (nd *LitNode) SendREV(q *Qchan) error
- func (nd *LitNode) SendSigRev(q *Qchan) error
- func (nd *LitNode) SendWatchComMsg(qc *Qchan, idx uint64, watchPeer uint32) error
- func (nd *LitNode) SetHTLCClearedOnChain(q *Qchan, h HTLC) error
- func (nd *LitNode) SettleContract(cIdx uint64, oracleValue int64, oracleSig [32]byte) ([32]byte, [32]byte, error)
- func (nd *LitNode) ShowJusticeDB() (string, error)
- func (nd *LitNode) SigProofHandler(msg lnutil.SigProofMsg, peer *RemotePeer)
- func (nd *LitNode) SigRevHandler(msg lnutil.SigRevMsg, qc *Qchan) error
- func (nd *LitNode) SignBreakTx(q *Qchan) (*wire.MsgTx, error)
- func (nd *LitNode) SignClaimTx(claimTx *wire.MsgTx, value int64, pre []byte, priv *koblitz.PrivateKey, ...) error
- func (nd *LitNode) SignSettlementDivisions(c *lnutil.DlcContract) ([]lnutil.DlcContractSettlementSignature, error)
- func (nd *LitNode) SignSettlementTx(c *lnutil.DlcContract, tx *wire.MsgTx, priv *koblitz.PrivateKey) ([64]byte, error)
- func (nd *LitNode) SignSimpleClose(q *Qchan, tx *wire.MsgTx) ([64]byte, error)
- func (nd *LitNode) SignState(q *Qchan) ([64]byte, [][64]byte, error)
- func (nd *LitNode) SyncWatch(qc *Qchan, watchPeer uint32) error
- func (nd *LitNode) TCPListener(port int) (string, error)
- func (nd *LitNode) VisualiseGraph() string
- type QCloseData
- type Qchan
- func (q *Qchan) AdvanceElkrem(elk *chainhash.Hash, n2Elk [33]byte) error
- func (q *Qchan) BuildStateTxs(mine bool) (*wire.MsgTx, []*wire.MsgTx, []*wire.TxOut, error)
- func (q *Qchan) Coin() uint32
- func (q *Qchan) ElkPoint(mine bool, idx uint64) (p [33]byte, err error)
- func (q *Qchan) GenHTLCOut(h HTLC, mine bool) (*wire.TxOut, error)
- func (q *Qchan) GenHTLCOutWithElkPointsAndRevPub(h HTLC, mine bool, theirElkPoint, myElkPoint, revPub [33]byte) (*wire.TxOut, error)
- func (q *Qchan) GenHTLCScript(h HTLC, mine bool) ([]byte, error)
- func (q *Qchan) GenHTLCScriptWithElkPointsAndRevPub(h HTLC, mine bool, theirElkPoint, myElkPoint, revPub [33]byte) ([]byte, error)
- func (q *Qchan) GetChanHint(mine bool) uint64
- func (q *Qchan) GetChannelBalances() (int64, int64)
- func (q *Qchan) GetCloseTxos(tx *wire.MsgTx) ([]portxo.PorTxo, error)
- func (q *Qchan) GetCloseTxs() (*wire.MsgTx, []*wire.MsgTx, bool, error)
- func (q *Qchan) GetHtlcTxos(tx *wire.MsgTx, mine bool) ([]*wire.TxOut, []uint32, error)
- func (q *Qchan) GetHtlcTxosWithElkPointsAndRevPub(tx *wire.MsgTx, mine bool, theirElkPoint, myElkPoint, revPub [33]byte) ([]*wire.TxOut, []uint32, error)
- func (q *Qchan) GetKeysFromState(mine bool) (revPub, timePub, pkhPub [33]byte, err error)
- func (q *Qchan) Idx() uint32
- func (q *Qchan) ImFirst() bool
- func (q *Qchan) IngestElkrem(elk *chainhash.Hash) error
- func (q *Qchan) N2ElkPointForThem() (p [33]byte, err error)
- func (q *Qchan) Peer() uint32
- func (q *Qchan) SimpleCloseTx() (*wire.MsgTx, error)
- func (q *Qchan) VerifySigs(sig [64]byte, HTLCSigs [][64]byte) error
- type RCRequestAuthArgs
- type RemoteControlAuthorization
- type RemotePeer
- type SimplePeerInfo
- type StatCom
- type UWallet
Constants ¶
const ( DUALFUND_DECLINE_REASON_USER = 0x01 // User manually declined DUALFUND_DECLINE_REASON_INSUFFICIENT_BALANCE = 0x02 // Not enough balance to accept the request DUALFUND_DECLINE_REASON_UNSUPPORTED_COIN = 0x03 // We don't have that coin type, so we declined automatically DUALFUND_DECLINE_REASON_ALREADY_PENDING_REQUEST = 0x04 // Current design only supports single dualfund request at a time. So decline when we have one in progress. )
const ( UseWallet = 0 | hdkeychain.HardenedKeyStart UseChannelFund = 20 | hdkeychain.HardenedKeyStart UseChannelRefund = 30 | hdkeychain.HardenedKeyStart UseChannelWatchRefund = 31 | hdkeychain.HardenedKeyStart UseChannelHAKDBase = 40 | hdkeychain.HardenedKeyStart UseChannelElkrem = 8888 | hdkeychain.HardenedKeyStart // key derivation path for contract payout keys (the keys the contract pays // TO combined with the oracle's signature) UseContractPayoutBase = 50 | hdkeychain.HardenedKeyStart // key derivation path for contract spending keys (the keys the contract // pays FROM, and the funding TX pays TO) UseContractFundMultisig = 51 | hdkeychain.HardenedKeyStart // key derivation path for contract payout PKH (the hash the contract // pays TO) UseContractPayoutPKH = 52 | hdkeychain.HardenedKeyStart // key derivation path for HTLC pubkeys UseHTLCBase = 60 | hdkeychain.HardenedKeyStart // links Id and channel. replaces UseChannelFund UseIdKey = 111 | hdkeychain.HardenedKeyStart )
Variables ¶
var ( BKTChannelData = []byte("channels") //BKTChannel = []byte("chn") // all channel data is in this bucket. BKTPeers = []byte("pir") // all peer data is in this bucket. BKTPeerMap = []byte("pmp") // map of peer index to pubkey BKTChanMap = []byte("cmp") // map of channel index to outpoint BKTWatch = []byte("wch") // txids & signatures for export to watchtowers BKTHTLCOPs = []byte("hlo") // htlc outpoints to watch BKTPayments = []byte("pym") // array of multihop payments BKTRCAuth = []byte("rca") // Remote control authorization KEYIdx = []byte("idx") // index for key derivation KEYhost = []byte("hst") // hostname where peer lives KEYnickname = []byte("nick") // nickname where peer lives KEYutxo = []byte("utx") // serialized utxo for the channel KEYState = []byte("now") // channel state KEYElkRecv = []byte("elk") // elkrem receiver KEYqclose = []byte("cls") // channel close outpoint & height )
Functions ¶
func GetHTLCOut ¶
func GetStateIdxFromTx ¶
GetStateIdxFromTx returns the state index from a commitment transaction. No errors; returns 0 if there is no retrievable index. Takes the xor input X which is derived from the 0th elkrems.
func GoAnnounce ¶
func GoAnnounce(priv *koblitz.PrivateKey, port int, litadr string, trackerURL string)
func SetStateIdxBits ¶
SetStateIdxBits modifies the tx in place, setting the sequence and locktime fields to indicate the given state index.
func SpendMultiSigWitStack ¶
the scriptsig to put on a P2SH input. Sigs need to be in order!
Types ¶
type ChanData ¶
type ChanData struct { Txo portxo.PorTxo `json:"txo"` CloseData QCloseData `json:"closedata"` TheirPub [33]byte `json:"rpub"` TheirRefundPub [33]byte `json:"rrefpub"` TheirHAKDBase [33]byte `json:"rhakdbase"` State *StatCom `json:"state"` LastUpdate uint64 `json:"updateunix"` }
ChanData is a struct used as a surrogate for going between Qchan and the JSON representation stored on disk. There's an annoying layer in between that make it all work out with hopefully little friction.
type ChannelStateUpdateEvent ¶
type ChannelStateUpdateEvent struct { // Because a lot of these update events are similar, we can use the same // structure for all of them and have a dynamic name, which you wouldn't // normally do. Action string // We include ChanIdx so we can do stuff internally if implemented, and we include State because it's a state // update event, so we'd like to know the new state. ChanIdx uint32 State *StatCom // in case an external application is using this and needs the public key for some reason. TheirPub koblitz.PublicKey // We need to know which coin this was for CoinType uint32 }
ChannelStateUpdateEvent is a struct for a channel state update event
func (ChannelStateUpdateEvent) Flags ¶
func (e ChannelStateUpdateEvent) Flags() uint8
Flags returns the flags for the event
func (ChannelStateUpdateEvent) Name ¶
func (e ChannelStateUpdateEvent) Name() string
Name returns the name of the channel state update event
type DualFundingResult ¶
type HTLC ¶
type HTLC struct { Idx uint32 `json:"idx"` Incoming bool `json:"incoming"` Amt int64 `json:"amt"` RHash [32]byte `json:"hash"` Locktime uint32 `json:"locktime"` MyHTLCBase [33]byte `json:"mhtlcbase"` TheirHTLCBase [33]byte `json:"rhtlcbase"` KeyGen portxo.KeyGen `json:"keygen"` Sig [64]byte `json:"sig"` R [16]byte `json:"preimage"` Clearing bool `json:"clearing"` Cleared bool `json:"cleared"` ClearedOnChain bool `json:"clearedoc"` // To keep track of what HTLCs we claimed on-chain }
4 + 1 + 8 + 32 + 4 + 33 + 33 + 1 + 5 + 32 + 64 = 217 bytes
type InFlightDualFund ¶
type InFlightDualFund struct {
PeerIdx, ChanIdx, CoinType uint32
OurAmount, TheirAmount int64
OurInputs, TheirInputs []lnutil.DualFundingInput
OurChangeAddress, TheirChangeAddress [20]byte
OurPub, OurRefundPub, OurHAKDBase [33]byte
TheirPub, TheirRefundPub, TheirHAKDBase [33]byte
OurNextHTLCBase, OurN2HTLCBase [33]byte
TheirNextHTLCBase, TheirN2HTLCBase [33]byte
OurSignatures, TheirSignatures [][60]byte
InitiatedByUs bool
OutPoint *wire.OutPoint
// contains filtered or unexported fields
}
InFlightDualFund is a dual funding transaction that has not yet been broadcast
func (*InFlightDualFund) Clear ¶
func (inff *InFlightDualFund) Clear()
type InFlightFund ¶
type InFlightFund struct {
PeerIdx, ChanIdx, Coin uint32
Amt, InitSend int64
Data [32]byte
// contains filtered or unexported fields
}
InFlightFund is a funding transaction that has not yet been broadcast
func (*InFlightFund) Clear ¶
func (inff *InFlightFund) Clear()
type InFlightMultihop ¶
type InFlightMultihop struct { Path []lnutil.RouteHop Amt int64 HHash [32]byte PreImage [16]byte Succeeded bool }
func InFlightMultihopFromBytes ¶
func InFlightMultihopFromBytes(b []byte) (*InFlightMultihop, error)
func (*InFlightMultihop) Bytes ¶
func (p *InFlightMultihop) Bytes() []byte
type JusticeTx ¶
type JusticeTx struct { Sig [64]byte Txid [16]byte Amt int64 Data [32]byte Pkh [20]byte Idx uint64 }
func JusticeTxFromBytes ¶
type LitMsgWrapperMessage ¶
type LitMsgWrapperMessage struct {
// contains filtered or unexported fields
}
LitMsgWrapperMessage is a wrapper type for adapting things to other things.
type LitNode ¶
type LitNode struct { LitDB *bolt.DB // place to write all this down NewLitDB lncore.LitStorage LitFolder string // path to save stuff IdentityKey *koblitz.PrivateKey // p2p remote control key DefaultRemoteControlKey *koblitz.PublicKey // event bus Events *eventbus.EventBus // Networking PeerMan *lnp2p.PeerManager // all nodes have a watchtower. but could have a tower without a node Tower watchtower.Watcher // discreet log contract manager DlcManager *dlc.DlcManager // BaseWallet is the underlying wallet which keeps track of utxos, secrets, // and network i/o // map of cointypes to wallets SubWallet map[uint32]UWallet // indicates if multiple wallets are connected MultiWallet bool // cointype of the first (possibly only) wallet connected DefaultCoin uint32 ConnectedCoinTypes map[uint32]bool RemoteCons map[uint32]*RemotePeer RemoteMtx sync.Mutex // the current channel that in the process of being created // (1 at a time for now) InProg *InFlightFund // the current channel in process of being dual funded InProgDual *InFlightDualFund // queue for async messages to RPC user UserMessageBox chan string // The URL from which lit attempts to resolve the LN address TrackerURL string ChannelMap map[[20]byte][]LinkDesc ChannelMapMtx sync.Mutex AdvTimeout *time.Ticker RPC interface{} // Contains the URL string to connect to a SOCKS5 proxy, if provided ProxyURL string Nat string InProgMultihop []*InFlightMultihop MultihopMutex sync.Mutex ExchangeRates map[uint32][]lnutil.RateDesc // REFACTORING FIELDS PeerMap map[*lnp2p.Peer]*RemotePeer // we never remove things from here, so this is a memory leak PeerMapMtx *sync.Mutex }
LitNode is the main struct for the node, keeping track of all channel state and communicating with the underlying UWallet
func NewLitNode ¶
func NewLitNode(privKey *[32]byte, path string, trackerURL string, proxyURL string, nat string) (*LitNode, error)
NewLitNode starts up a lit node. Needs priv key, and a path. Does not activate a subwallet; do that after init.
func (*LitNode) AddContract ¶
func (nd *LitNode) AddContract() (*lnutil.DlcContract, error)
func (*LitNode) ApplyChanDataToQchan ¶
ApplyChanDataToQchan applies the chandata to the qchan without destroying it.
func (*LitNode) AutoReconnect ¶
AutoReconnect will start listening for incoming connections and attempt to automatically reconnect to all previously known peers attached with the coin daemons running.
func (*LitNode) BreakChannel ¶
------------------------- break
func (*LitNode) BuildDlcFundingTransaction ¶
func (*LitNode) BuildDualFundingTransaction ¶
func (*LitNode) BuildJusticeSig ¶
BuildWatchTxidSig builds the partial txid and signature pair which can be exported to the watchtower. This get a channel that is 1 state old. So we can produce a signature.
func (*LitNode) ChannelHandler ¶
func (nd *LitNode) ChannelHandler(msg lnutil.LitMsg, peer *RemotePeer) error
func (*LitNode) ClaimHTLC ¶
ClaimHTLC will claim an HTLC on-chain output from a broken channel using the given preimage. Returns the TXIDs of the claim transactions
func (*LitNode) ClaimHTLCOnChain ¶
func (*LitNode) ClaimHTLCTimeouts ¶
func (*LitNode) CloseReqHandler ¶
func (nd *LitNode) CloseReqHandler(msg lnutil.CloseReqMsg)
func (*LitNode) ConnectedToPeer ¶
ConnectedToPeer checks whether you're connected to a specific peer
func (*LitNode) DeltaSigHandler ¶
func (nd *LitNode) DeltaSigHandler(msg lnutil.DeltaSigMsg, qc *Qchan) error
DeltaSigHandler takes in a DeltaSig and responds with a SigRev (normally) or a GapSigRev (if there's a collision) Leaves the channel either expecting a Rev (normally) or a GapSigRev (collision)
func (*LitNode) DlcAcceptHandler ¶
func (nd *LitNode) DlcAcceptHandler(msg lnutil.DlcOfferAcceptMsg, peer *RemotePeer) error
func (*LitNode) DlcContractAckHandler ¶
func (nd *LitNode) DlcContractAckHandler(msg lnutil.DlcContractAckMsg, peer *RemotePeer)
func (*LitNode) DlcDeclineHandler ¶
func (nd *LitNode) DlcDeclineHandler(msg lnutil.DlcOfferDeclineMsg, peer *RemotePeer)
func (*LitNode) DlcFundingSigsHandler ¶
func (nd *LitNode) DlcFundingSigsHandler(msg lnutil.DlcContractFundingSigsMsg, peer *RemotePeer)
func (*LitNode) DlcOfferHandler ¶
func (nd *LitNode) DlcOfferHandler(msg lnutil.DlcOfferMsg, peer *RemotePeer)
func (*LitNode) DlcSigProofHandler ¶
func (nd *LitNode) DlcSigProofHandler(msg lnutil.DlcContractSigProofMsg, peer *RemotePeer)
func (*LitNode) DualFundAccept ¶
func (nd *LitNode) DualFundAccept() *DualFundingResult
func (*LitNode) DualFundChanAckHandler ¶
func (nd *LitNode) DualFundChanAckHandler(msg lnutil.DualFundingChanAckMsg, peer *RemotePeer)
FUNDER QChanAckHandler takes in an acknowledgement multisig description. when a multisig outpoint is ackd, that causes the funder to sign and broadcast.
func (*LitNode) DualFundChanDescHandler ¶
func (nd *LitNode) DualFundChanDescHandler(msg lnutil.ChanDescMsg) error
RECIPIENT QChanDescHandler takes in a description of a channel output. It then saves it to the local db, and returns a channel acknowledgement
func (*LitNode) DualFundChannel ¶
func (*LitNode) DualFundDecline ¶
Declines the in progress (received) dual funding request
func (*LitNode) DualFundSigProofHandler ¶
func (nd *LitNode) DualFundSigProofHandler(msg lnutil.SigProofMsg, peer *RemotePeer)
RECIPIENT SigProofHandler saves the signature the recipient stores. In some cases you don't need this message.
func (*LitNode) DualFundingAcceptHandler ¶
func (nd *LitNode) DualFundingAcceptHandler(msg lnutil.DualFundingAcceptMsg)
DualFundingAcceptHandler gets a message where the remote party is accepting the request to dualfund.
func (*LitNode) DualFundingDeclHandler ¶
func (nd *LitNode) DualFundingDeclHandler(msg lnutil.DualFundingDeclMsg)
RECIPIENT DualFundingDeclHandler gets a message where the remote party is declining the request to dualfund.
func (*LitNode) DualFundingHandler ¶
func (nd *LitNode) DualFundingHandler(msg lnutil.LitMsg, peer *RemotePeer) error
func (*LitNode) DualFundingReqHandler ¶
func (nd *LitNode) DualFundingReqHandler(msg lnutil.DualFundingReqMsg)
RECIPIENT DualFundingReqHandler gets a request with the funding data of the remote peer, along with the amount of funding requested to return data for.
func (*LitNode) DumpJusticeDB ¶
func (*LitNode) FailChannel ¶
FailChannel sets the fail flag on the channel and attempts to save it
func (*LitNode) FindHTLCsByHash ¶
func (*LitNode) FindHTLCsByTimeoutHeight ¶
func (*LitNode) FindPath ¶
func (nd *LitNode) FindPath(targetPkh [20]byte, destCoinType uint32, originCoinType uint32, amount int64) ([]lnutil.RouteHop, error)
FindPath uses Bellman-Ford and Dijkstra to find the path with the best price that has enough capacity to route the payment
func (*LitNode) FindPeerIndexByAddress ¶
FindPeerIndexByAddress finds the peer index by address. TODO Remove this function.
func (*LitNode) FundChannel ¶
func (nd *LitNode) FundChannel( peerIdx, cointype uint32, ccap, initSend int64, data [32]byte) (uint32, error)
FundChannel opens a channel with a peer. Doesn't return until the channel has been created. Maybe timeout if it takes too long?
func (*LitNode) FundContract ¶
func (nd *LitNode) FundContract(c *lnutil.DlcContract) error
func (*LitNode) GapSigRevHandler ¶
func (nd *LitNode) GapSigRevHandler(msg lnutil.GapSigRevMsg, q *Qchan) error
GapSigRevHandler takes in a GapSigRev, responds with a Rev, and leaves the channel in a state expecting a Rev.
func (*LitNode) GetAllMultihopPayments ¶
func (nd *LitNode) GetAllMultihopPayments() ([]*InFlightMultihop, error)
func (*LitNode) GetAllQchans ¶
GetAllQchans returns a slice of all channels. empty slice is OK.
func (*LitNode) GetConnectedPeerList ¶
func (nd *LitNode) GetConnectedPeerList() []SimplePeerInfo
GetConnectedPeerList .
func (*LitNode) GetDHSecret ¶
GetDHSecret gets a per-channel shared secret from the Diffie-Helman of the two pubkeys in the fund tx.
func (*LitNode) GetElkremRoot ¶
GetElkremRoot returns the Elkrem root for a given key path gets the use-pub for elkrems and hashes it. A little weird because it's a "pub" key you shouldn't reveal. either do this or export privkeys... or signing empty txs or something.
func (*LitNode) GetLisAddressAndPorts ¶
GetLisAddressAndPorts . Gets the list of ports where LitNode is listening for incoming connections, & the connection key
func (*LitNode) GetNicknameFromPeerIdx ¶
GetNicknameFromPeerIdx gets the nickname for a peer
func (*LitNode) GetPendingRemoteControlRequests ¶
func (nd *LitNode) GetPendingRemoteControlRequests() ([]*RemoteControlAuthorization, error)
GetPendingRemoteControlRequests retrieves all pending remote control authorization requests, so that a GUI can print them out for the user to authorize or not.
func (*LitNode) GetPubHostFromPeerIdx ¶
GetPubHostFromPeerIdx gets the pubkey and internet host name for a peer
func (*LitNode) GetQchanByIdx ¶
GetQchanByIdx is a gets the channel when you don't know the peer bytes and outpoint. Probably shouldn't have to use this if the UI is done right though.
func (*LitNode) GetQchanOPfromIdx ¶
func (*LitNode) GetRemoteControlAuthorization ¶
func (nd *LitNode) GetRemoteControlAuthorization(pub [33]byte) (*RemoteControlAuthorization, error)
GetRemoteControlAuthorization retrieves the remote controlauthorizzation for a specific pubkey from the database.
func (*LitNode) GetUsePub ¶
GetUsePub gets a pubkey from the base wallet, but first modifies the "use" step
func (*LitNode) HandleContractOPEvent ¶
func (nd *LitNode) HandleContractOPEvent(c *lnutil.DlcContract, opEvent *lnutil.OutPointEvent) error
func (*LitNode) HashSigHandler ¶
func (nd *LitNode) HashSigHandler(msg lnutil.HashSigMsg, qc *Qchan) error
func (*LitNode) HeightEventHandler ¶
func (nd *LitNode) HeightEventHandler(HeightEventChan chan lnutil.HeightEvent)
func (*LitNode) IdKey ¶
func (nd *LitNode) IdKey() *koblitz.PrivateKey
IdKey returns the identity private key
func (*LitNode) InitRouting ¶
func (nd *LitNode) InitRouting()
func (*LitNode) LinkBaseWallet ¶
func (nd *LitNode) LinkBaseWallet( privKey *[32]byte, birthHeight int32, resync bool, tower bool, host string, proxy string, param *coinparam.Params) error
LinkBaseWallet activates a wallet and hooks it into the litnode.
func (*LitNode) LinkMsgHandler ¶
func (*LitNode) LoadJusticeSig ¶
func (*LitNode) MultihopPaymentAckHandler ¶
func (nd *LitNode) MultihopPaymentAckHandler(msg lnutil.MultihopPaymentAckMsg) error
func (*LitNode) MultihopPaymentRequestHandler ¶
func (nd *LitNode) MultihopPaymentRequestHandler(msg lnutil.MultihopPaymentRequestMsg) error
func (*LitNode) MultihopPaymentSetupHandler ¶
func (nd *LitNode) MultihopPaymentSetupHandler(msg lnutil.MultihopPaymentSetupMsg) error
func (*LitNode) NewChanDataFromQchan ¶
NewChanDataFromQchan extracts the chandata from the qchan.
func (*LitNode) NewQchanFromChanData ¶
NewQchanFromChanData creates a new qchan from a chandata.
func (*LitNode) NextChannelIdx ¶
NextIdx returns the next channel index to use.
func (*LitNode) OPEventHandler ¶
func (nd *LitNode) OPEventHandler(OPEventChan chan lnutil.OutPointEvent)
OPEventHandler gets outpoint events from the base wallet, and modifies the ln node db to reflect confirmations. Can also respond with exporting txos to the base wallet, or penalty txs.
func (*LitNode) PayMultihop ¶
func (*LitNode) PeerHandler ¶
handles stuff that comes in over the wire. Not user-initiated.
func (*LitNode) PointReqHandler ¶
func (nd *LitNode) PointReqHandler(msg lnutil.PointReqMsg)
RECIPIENT PubReqHandler gets a (content-less) pubkey request. Respond with a pubkey and a refund pubkey hash. (currently makes pubkey hash, need to only make 1) so if someone sends 10 pubkeyreqs, they'll get the same pubkey back 10 times. they have to provide an actual tx before the next pubkey will come out.
func (*LitNode) PointRespHandler ¶
func (nd *LitNode) PointRespHandler(msg lnutil.PointRespMsg) error
FUNDER PointRespHandler takes in a point response, and returns a channel description
func (*LitNode) PopulateQchanMap ¶
func (nd *LitNode) PopulateQchanMap(peer *RemotePeer) error
func (*LitNode) PopulateRates ¶
func (*LitNode) PreimageSigHandler ¶
func (nd *LitNode) PreimageSigHandler(msg lnutil.PreimageSigMsg, qc *Qchan) error
func (*LitNode) PrintBreakTxForDebugging ¶
func (*LitNode) PushChannel ¶
PushChannel initiates a state update by sending a DeltaSig
func (*LitNode) PushPullHandler ¶
func (*LitNode) QChanAckHandler ¶
func (nd *LitNode) QChanAckHandler(msg lnutil.ChanAckMsg, peer *RemotePeer)
FUNDER QChanAckHandler takes in an acknowledgement multisig description. when a multisig outpoint is ackd, that causes the funder to sign and broadcast.
func (*LitNode) QChanDescHandler ¶
func (nd *LitNode) QChanDescHandler(msg lnutil.ChanDescMsg) error
RECIPIENT QChanDescHandler takes in a description of a channel output. It then saves it to the local db, and returns a channel acknowledgement
func (*LitNode) QchanDeserializeFromBytes ¶
func (*LitNode) QchanSerializeToBytes ¶
func (*LitNode) QchanUpdateFromBytes ¶
func (*LitNode) ReSendMsg ¶
SendNextMsg determines what message needs to be sent next based on the channel state. It then calls the appropriate function.
func (*LitNode) ReloadQchanState ¶
ReloadQchan loads updated data from the db into the qchan. Loads elkrem and state, but does not change qchan info itself. Faster than GetQchan() also reload the channel close state
func (*LitNode) RemoteControlRequestHandler ¶
func (nd *LitNode) RemoteControlRequestHandler(msg lnutil.RemoteControlRpcRequestMsg, peer *RemotePeer) error
RemoteControlRequestHandler handles an incoming remote control request
func (*LitNode) RemoteControlResponseHandler ¶
func (nd *LitNode) RemoteControlResponseHandler(msg lnutil.RemoteControlRpcResponseMsg, peer *RemotePeer) error
RemoteControlResponseHandler handles the remote control response messages. At this time, this is not used in lit itself. Remote control messages are sent from the LndcRpcClient and responses are handled there. In normal operation two regular lit nodes do not talk to each other using remote control. But just in case someone sends us one, we print it out here.
func (*LitNode) RevHandler ¶
REVHandler takes in a REV and clears the state's prev HAKD. This is the final message in the state update process and there is no response. Leaves the channel in a clear / rest state.
func (*LitNode) SaveJusticeSig ¶
SaveJusticeSig save the txid/sig of a justice transaction to the db. Pretty straightforward
func (*LitNode) SaveMultihopPayment ¶
func (nd *LitNode) SaveMultihopPayment(p *InFlightMultihop) error
SaveMultihopPayment saves a new (or updates an existing) multihop payment in the database
func (*LitNode) SaveNicknameForPeerIdx ¶
SaveNicknameForPeerIdx saves/overwrites a nickname for a given peer idx
func (*LitNode) SaveQchanState ¶
Save / overwrite state of qChan in db the descent into the qchan bucket is boilerplate and it'd be nice if we can make that it's own function. Get channel bucket maybe? But then you have to close it...
func (*LitNode) SaveQchanUtxoData ¶
SaveQchanUtxoData saves utxo data such as outpoint and close tx / status.
func (*LitNode) SaveRemoteControlAuthorization ¶
func (nd *LitNode) SaveRemoteControlAuthorization(pub [33]byte, auth *RemoteControlAuthorization) error
SaveRemoteControlAuthorization saves the authorization for a specific pubkey into the database.
func (*LitNode) SendDeltaSig ¶
SendDeltaSig initiates a push, sending the amount to be pushed and the new sig.
func (*LitNode) SendGapSigRev ¶
SendGapSigRev is different; it signs for state+1 and revokes state-1
func (*LitNode) SendHashSig ¶
func (*LitNode) SendSigRev ¶
SendSigRev sends a SigRev message based on channel info
func (*LitNode) SendWatchComMsg ¶
send WatchComMsg generates and sends the ComMsg to a watchtower
func (*LitNode) SetHTLCClearedOnChain ¶
func (*LitNode) SettleContract ¶
func (*LitNode) ShowJusticeDB ¶
func (*LitNode) SigProofHandler ¶
func (nd *LitNode) SigProofHandler(msg lnutil.SigProofMsg, peer *RemotePeer)
RECIPIENT SigProofHandler saves the signature the recipient stores. In some cases you don't need this message.
func (*LitNode) SigRevHandler ¶
SIGREVHandler takes in a SIGREV and responds with a REV (if everything goes OK) Leaves the channel in a clear / rest state.
func (*LitNode) SignBreakTx ¶
SignBreak signs YOUR tx, which you already have a sig for
func (*LitNode) SignClaimTx ¶
func (nd *LitNode) SignClaimTx(claimTx *wire.MsgTx, value int64, pre []byte, priv *koblitz.PrivateKey, timeout bool) error
SignClaimTx signs the given claim tx based on the passed preimage and value using the passed private key. Tx is modified in place. timeout=false means it's a regular claim, timeout=true means we're claiming an output that has expired (for instance if someone) published the wrong settlement TX, we can claim this output back to our wallet after the timelock expired.
func (*LitNode) SignSettlementDivisions ¶
func (nd *LitNode) SignSettlementDivisions(c *lnutil.DlcContract) ([]lnutil.DlcContractSettlementSignature, error)
func (*LitNode) SignSettlementTx ¶
func (nd *LitNode) SignSettlementTx(c *lnutil.DlcContract, tx *wire.MsgTx, priv *koblitz.PrivateKey) ([64]byte, error)
SignSettlementTx signs the given settlement tx based on the passed contract using the passed private key. Tx is modified in place.
func (*LitNode) SignSimpleClose ¶
SignSimpleClose signs the given simpleClose tx, given the other signature Tx is modified in place.
func (*LitNode) TCPListener ¶
TCPListener starts a litNode listening for incoming LNDC connections.
func (*LitNode) VisualiseGraph ¶
type QCloseData ¶
type Qchan ¶
type Qchan struct { portxo.PorTxo // S underlying utxo data CloseData QCloseData // S closing outpoint MyPub [33]byte // D my channel specific pubkey TheirPub [33]byte // S their channel specific pubkey // Refunds are also elkremified MyRefundPub [33]byte // D my refund pubkey for channel break TheirRefundPub [33]byte // S their pubkey for channel break MyHAKDBase [33]byte // D my base point for HAKD and timeout keys TheirHAKDBase [33]byte // S their base point for HAKD and timeout keys // PKH for penalty tx. Derived WatchRefundAdr [20]byte // Elkrem is used for revoking state commitments ElkSnd *elkrem.ElkremSender // D derived from channel specific key ElkRcv *elkrem.ElkremReceiver // S stored in db Delay uint16 // blocks for timeout (default 5 for testing) State *StatCom // S current state of channel ClearToSend chan bool // send a true here when you get a rev ChanMtx sync.Mutex LastUpdate uint64 // unix timestamp of last update (milliseconds) }
Uhh, quick channel. For now. Once you get greater spire it upgrades to a full channel that can do everything.
func (*Qchan) AdvanceElkrem ¶
func (*Qchan) BuildStateTxs ¶
BuildStateTxs constructs and returns a state commitment tx and a list of HTLC success/failure txs. As simple as I can make it. This func just makes the tx with data from State in ram, and HAKD key arg
func (*Qchan) ElkPoint ¶
ElkPoint generates an elkrem Point. "My" elkrem point is the point I receive from the counter party, and can create after the state has been revoked. "Their" elkrem point (mine=false) is generated from my elkrem sender at any index. Elkrem points pubkeys where the scalar is a hash coming from the elkrem tree. With delinearized aggregation, only one point is needed. I'm pretty sure.
func (*Qchan) GenHTLCOutWithElkPointsAndRevPub ¶
func (*Qchan) GenHTLCScriptWithElkPointsAndRevPub ¶
func (*Qchan) GetChanHint ¶
GetChanHint gives the 6 byte hint mask of the channel. It's derived from the hash of the PKH output pubkeys. "Mine" means the hint is in the tx I store. So it's actually a hint for them to decode... which is confusing, but consistent with the "mine" bool for transactions, so "my" tx has "my" hint. (1<<48 - 1 is the max valid value)
func (*Qchan) GetChannelBalances ¶
GetChannelBalances returns myAmt and theirAmt in the channel that aren't locked up in HTLCs in satoshis
func (*Qchan) GetCloseTxos ¶
GetCloseTxos takes in a tx and sets the QcloseTXO fields based on the tx. It also returns the spendable (u)txos generated by the close. TODO way too long. Need to split up. TODO problem with collisions, and insufficiently high elk receiver...?
func (*Qchan) GetHtlcTxos ¶
func (*Qchan) GetHtlcTxosWithElkPointsAndRevPub ¶
func (*Qchan) GetKeysFromState ¶
GetKeysFromState will inspect the channel state and return the revPub, timePub and pkhPub based on whether we're building our own or the remote transaction.
func (*Qchan) ImFirst ¶
ImFirst decides who goes first when it's unclear. Smaller pubkey goes first.
func (*Qchan) IngestElkrem ¶
IngestElkrem takes in an elkrem hash, performing 2 checks: that it produces the proper elk point, and that it fits into the elkrem tree. If either of these checks fail, and definitely the second one fails, I'm pretty sure the channel is not recoverable and needs to be closed.
func (*Qchan) N2ElkPointForThem ¶
CurElkPointForThem makes the current state elkrem point to send out
func (*Qchan) SimpleCloseTx ¶
SimpleCloseTx produces a close tx based on the current state. The PKH addresses are my refund base with their r-elkrem point, and their refund base with my r-elkrem point. "Their" point means they have the point but not the scalar.
func (*Qchan) VerifySigs ¶
VerifySig verifies their signature for your next state. it also saves the sig if it's good. do bool, error or just error? Bad sig is an error I guess. for verifying signature, always use theirHAKDpub, so generate & populate within this function.
type RCRequestAuthArgs ¶
type RCRequestAuthArgs struct { // Public Key to authorize PubKey [33]byte }
RCRequestAuthArgs contains the required parameters to request authorization for remote control. Only the pub key is necessary
type RemoteControlAuthorization ¶
For now, this is simple: Allowed yes or no In the future allow more finegrained control over which RPCs are allowed and which are not, and perhaps authorize up to a certain amount for commands like send / push
func RemoteControlAuthorizationFromBytes ¶
func RemoteControlAuthorizationFromBytes(b []byte, pubKey [33]byte) *RemoteControlAuthorization
RemoteControlAuthorizationFromBytes parses a byteslice into a RemoteControlAuthorization object
func (*RemoteControlAuthorization) Bytes ¶
func (r *RemoteControlAuthorization) Bytes() []byte
Bytes serializes a remotecontrol authorization into a byteslice
type RemotePeer ¶
type SimplePeerInfo ¶
SimplePeerInfo .
type StatCom ¶
type StatCom struct { StateIdx uint64 `json:"idx"` // this is the n'th state commitment WatchUpTo uint64 `json:"watchupto"` // have sent out to watchtowers up to this state ( < stateidx) MyAmt int64 `json:"amt"` // my channel allocation Fee int64 `json:"fee"` // symmetric fee in absolute satoshis Data [32]byte `json:"miscdata"` // their Amt is the utxo.Value minus this Delta int32 `json:"delta"` // fund amount in-transit; is negative for the pusher // Delta for when the channel is in a collision state which needs to be resolved Collision int32 `json:"collision"` // Elkrem point from counterparty, used to make // Homomorphic Adversarial Key Derivation public keys (HAKD) ElkPoint [33]byte `json:"elkp0"` // saved to disk, current revealable point NextElkPoint [33]byte `json:"elkp1"` // Point stored for next state N2ElkPoint [33]byte `json:"elkp2"` // Point for state after next (in case of collision) Sig [64]byte `json:"sig"` // Counterparty's signature for current state HTLCIdx uint32 `json:"htlcidx"` InProgHTLC *HTLC `json:"iphtlc"` // Current in progress HTLC CollidingHTLC *HTLC `json:"collhtlc"` // HTLC for when the channel is colliding CollidingHashDelta bool `json:"colhd"` // True when colliding between a DeltaSig and HashSig/PreImageSig CollidingHashPreimage bool `json:"colhp"` // True when colliding between HashSig and PreimageSig CollidingPreimages bool `json:"colpp"` // True when colliding between PreimageSig and PreimageSig CollidingPreimageDelta bool `json:"colpd"` // True when colliding between a DeltaSig and HashSig/PreImageSig // Analogous to the ElkPoints above but used for generating their pubkey for the HTLC NextHTLCBase [33]byte `json:"rnexthtlcbase"` N2HTLCBase [33]byte `json:"rnexthtlcbase2"` MyNextHTLCBase [33]byte `json:"mnexthtlcbase"` MyN2HTLCBase [33]byte `json:"mnexthtlcbase2"` // Any HTLCs associated with this channel state (can be nil) HTLCs []HTLC `json:"htlcs"` Failed bool `json:"failed"` // S there was a fatal error with the channel }
StatComs are State Commitments. all elements are saved to the db.
type UWallet ¶
type UWallet interface { // Ask for a pubkey based on a bip32 path GetPub(k portxo.KeyGen) *koblitz.PublicKey // Have GetPriv for now. Maybe later get rid of this and have // the underlying wallet sign? GetPriv(k portxo.KeyGen) (*koblitz.PrivateKey, error) // export the chainhook that the UWallet uses, for pushTx and fullblock ExportHook() uspv.ChainHook PushTx(tx *wire.MsgTx) error // ExportUtxo gives a utxo to the underlying wallet; that wallet saves it // and can spend it later. Doesn't return errors; error will exist only in // base wallet. ExportUtxo(txo *portxo.PorTxo) // MaybeSend makes an unsigned tx, populated with inputs and outputs. // The specified txouts are in there somewhere. // Only segwit txins are in the generated tx. (txid won't change) // There's probably an extra change txout in there which is OK. // The inputs are "frozen" until ReallySend / NahDontSend / program restart. // Retruns the txid, and then the txout indexes of the specified txos. // The outpoints returned will all have the same hash (txid) // So if you (as usual) just give one txo, you basically get back an outpoint. MaybeSend(txos []*wire.TxOut, onlyWit bool) ([]*wire.OutPoint, error) // ReallySend really sends the transaction specified previously in MaybeSend. // Underlying wallet does all needed signing. // Once you call ReallySend, the outpoint is tracked and responses are // sent through LetMeKnow ReallySend(txid *chainhash.Hash) error // NahDontSend cancels the MaybeSend transaction. NahDontSend(txid *chainhash.Hash) error // Return a new address NewAdr() ([20]byte, error) // Dump all the utxos in the sub wallet UtxoDump() ([]*portxo.PorTxo, error) // Dump all the addresses the sub wallet is watching AdrDump() ([][20]byte, error) // Return current height the wallet is synced to CurrentHeight() int32 // WatchThis tells the basewallet to watch an outpoint WatchThis(wire.OutPoint) error // StopWatchingThis tells the basewallet to stop watching an outpoint StopWatchingThis(wire.OutPoint) error // LetMeKnow opens the chan where OutPointEvent flows from the underlying // wallet up to the LN module. LetMeKnow() chan lnutil.OutPointEvent // LetMeKnowHeight opens the chan where the blockheight flows from the underlying // wallet up to the LN module. Used for monitoring HTLC timeouts LetMeKnowHeight() chan lnutil.HeightEvent // Ask for network parameters Params() *coinparam.Params // Get current fee rate. Fee() int64 // Set fee rate SetFee(int64) int64 // ===== TESTING / SPAMMING ONLY, these funcs will not be in the real interface // Sweep sends lots of txs (uint32 of them) to the specified address. Sweep([]byte, uint32) ([]*chainhash.Hash, error) PickUtxos(amtWanted, outputByteSize, feePerByte int64, ow bool) (portxo.TxoSliceByBip69, int64, error) SignMyInputs(tx *wire.MsgTx) error DirectSendTx(tx *wire.MsgTx) error }
The UWallet interface are the functions needed to work with the LnNode Verbs are from the perspective of the LnNode, not the underlying wallet
Source Files ¶
- autoconnect.go
- basewallet.go
- break.go
- buildtx.go
- close.go
- dlc.go
- dualfund.go
- elkpoints.go
- eventhandlers.go
- events.go
- fund.go
- heap.go
- htlc.go
- init.go
- justicetx.go
- lnchannels.go
- lndb.go
- magicnums.go
- msghandler.go
- msgtypes.go
- multihop.go
- netio.go
- pushpull.go
- remotecontrol.go
- routing.go
- serdes.go
- signtx.go