qln

package
v0.0.0-...-793c700 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
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

	UseIdKey = 111 | hdkeychain.HardenedKeyStart
)

Variables

View Source
var (
	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

	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 Announce

func Announce(priv *btcec.PrivateKey, litport string, litadr string, trackerURL string) error

func GetStateIdxFromTx

func GetStateIdxFromTx(tx *wire.MsgTx, x uint64) uint64

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 Lookup

func Lookup(litadr string, trackerURL string) (string, error)

func SetStateIdxBits

func SetStateIdxBits(tx *wire.MsgTx, idx, x uint64) error

SetStateIdxBits modifies the tx in place, setting the sequence and locktime fields to indicate the given state index.

func SpendMultiSigWitStack

func SpendMultiSigWitStack(pre, sigA, sigB []byte) [][]byte

the scriptsig to put on a P2SH input. Sigs need to be in order!

Types

type InFlightFund

type InFlightFund struct {
	PeerIdx, ChanIdx, Coin uint32
	Amt, InitSend          int64
	// contains filtered or unexported fields
}

InFlightFund is a funding transaction that has not yet been broadcast

func (*InFlightFund) Clear

func (inff *InFlightFund) Clear()

type LitNode

type LitNode struct {
	LitDB *bolt.DB // place to write all this down

	LitFolder string // path to save stuff

	IdentityKey *btcec.PrivateKey

	// all nodes have a watchtower.  but could have a tower without a node
	Tower watchtower.Watcher

	// 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

	RemoteCons map[uint32]*RemotePeer
	RemoteMtx  sync.Mutex

	// WatchCon is currently just for the watchtower
	WatchCon *lndc.LNDConn // merge these later

	// OmniChan is the channel for the OmniHandler
	OmniIn  chan lnutil.LitMsg
	OmniOut chan lnutil.LitMsg

	// the current channel that in the process of being created
	// (1 at a time for now)
	InProg *InFlightFund

	// queue for async messages to RPC user
	UserMessageBox chan string

	// The port(s) in which it listens for incoming connections
	LisIpPorts []string

	// The URL from which lit attempts to resolve the LN address
	TrackerURL string
}

LnNode 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) (*LitNode, error)

Init starts up a lit node. Needs priv key, and a path. Does not activate a subwallet; do that after init.

func (*LitNode) BreakChannel

func (nd *LitNode) BreakChannel(q *Qchan) error

------------------------- break

func (*LitNode) BuildJusticeSig

func (nd *LitNode) BuildJusticeSig(q *Qchan) error

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) CloseHandler

func (nd *LitNode) CloseHandler(msg lnutil.LitMsg) error

func (*LitNode) CloseReqHandler

func (nd *LitNode) CloseReqHandler(msg lnutil.CloseReqMsg)

func (*LitNode) ConnectedToPeer

func (nd *LitNode) ConnectedToPeer(peer uint32) bool

ConnectedToPeer checks whether you're connected to a specific peer

func (*LitNode) CoopClose

func (nd *LitNode) CoopClose(q *Qchan) error

CoopClose requests a cooperative close of the channel

func (*LitNode) DeltaSigHandler

func (nd *LitNode) DeltaSigHandler(msg lnutil.DeltaSigMsg, qc *Qchan) error

DeltaSigHandler takes in a DeltaSig and responds with an SigRev (normally) or a GapSigRev (if there's a collision) Leaves the channel either expecting a Rev (normally) or a GapSigRev (collision)

func (*LitNode) DialPeer

func (nd *LitNode) DialPeer(connectAdr string) error

DialPeer makes an outgoing connection to another node.

func (*LitNode) FWDHandler

func (nd *LitNode) FWDHandler(msg lnutil.LitMsg) error

func (*LitNode) FundChannel

func (nd *LitNode) FundChannel(
	peerIdx, cointype uint32, ccap, initSend int64) (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) 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) GetAllQchans

func (nd *LitNode) GetAllQchans() ([]*Qchan, error)

GetAllQchans returns a slice of all channels. empty slice is OK.

func (*LitNode) GetConnectedPeerList

func (nd *LitNode) GetConnectedPeerList() []PeerInfo

func (*LitNode) GetDHSecret

func (nd *LitNode) GetDHSecret(q *Qchan) ([]byte, error)

GetDHSecret gets a per-channel shared secret from the Diffie-Helman of the two pubkeys in the fund tx.

func (*LitNode) GetElkremRoot

func (nd *LitNode) GetElkremRoot(k portxo.KeyGen) (chainhash.Hash, error)

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

func (nd *LitNode) GetLisAddressAndPorts() (
	string, []string)

Gets the list of ports where LitNode is listening for incoming connections, & the connection key

func (*LitNode) GetNicknameFromPeerIdx

func (nd *LitNode) GetNicknameFromPeerIdx(idx uint32) string

GetNicknameFromPeerIdx gets the nickname for a peer

func (*LitNode) GetPeerIdx

func (nd *LitNode) GetPeerIdx(pub *btcec.PublicKey, host string) (uint32, error)

GetPeerIdx returns the peer index given a pubkey. Creates it if it's not there yet! Also return a bool for new..? not needed?

func (*LitNode) GetPubHostFromPeerIdx

func (nd *LitNode) GetPubHostFromPeerIdx(idx uint32) ([33]byte, string)

GetPubHostFromPeerIdx gets the pubkey and internet host name for a peer

func (*LitNode) GetQchan

func (nd *LitNode) GetQchan(opArr [36]byte) (*Qchan, error)

GetQchan returns a single channel. pubkey and outpoint bytes.

func (*LitNode) GetQchanByIdx

func (nd *LitNode) GetQchanByIdx(cIdx uint32) (*Qchan, error)

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 (nd *LitNode) GetQchanOPfromIdx(cIdx uint32) ([36]byte, error)

func (*LitNode) GetUsePub

func (nd *LitNode) GetUsePub(k portxo.KeyGen, use uint32) (pubArr [33]byte, err error)

GetUsePub gets a pubkey from the base wallet, but first modifies the "use" step

func (*LitNode) IdKey

func (nd *LitNode) IdKey() *btcec.PrivateKey

IdKey returns the identity private key

func (*LitNode) LNDCReader

func (nd *LitNode) LNDCReader(peer *RemotePeer) error

Every lndc has one of these running it listens for incoming messages on the lndc and hands it over to the OmniHandler via omnichan

func (*LitNode) LinkBaseWallet

func (nd *LitNode) LinkBaseWallet(
	privKey *[32]byte, birthHeight int32, resync bool, tower bool,
	host string, param *coinparam.Params) error

LinkBaseWallet activates a wallet and hooks it into the litnode.

func (*LitNode) LoadJusticeSig

func (nd *LitNode) LoadJusticeSig(comnum uint64, pkh [20]byte) ([80]byte, error)

func (*LitNode) NextChannelIdx

func (nd *LitNode) NextChannelIdx() (uint32, error)

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) OpenDB

func (nd *LitNode) OpenDB(filename string) error

Opens the DB file for the LnNode

func (*LitNode) OutMessager

func (nd *LitNode) OutMessager()

OutMessager takes messages from the outbox and sends them to the ether. net.

func (*LitNode) PeerHandler

func (nd *LitNode) PeerHandler(msg lnutil.LitMsg, q *Qchan, peer *RemotePeer) error

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) PushChannel

func (nd LitNode) PushChannel(qc *Qchan, amt uint32) error

PushChannel initiates a state update by sending an DeltaSig

func (*LitNode) PushPullHandler

func (nd *LitNode) PushPullHandler(routedMsg lnutil.LitMsg, q *Qchan) error

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)

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) QchanInfo

func (nd *LitNode) QchanInfo(q *Qchan) error

ChannelInfo prints info about a channel.

func (*LitNode) ReSendMsg

func (nd *LitNode) ReSendMsg(qc *Qchan) error

SendNextMsg determines what message needs to be sent next based on the channel state. It then calls the appropriate function.

func (*LitNode) ReloadQchanState

func (nd *LitNode) ReloadQchanState(q *Qchan) error

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) RestoreQchanFromBucket

func (nd *LitNode) RestoreQchanFromBucket(bkt *bolt.Bucket) (*Qchan, error)

RestoreQchanFromBucket loads the full qchan into memory from the bucket where it's stored. Loads the channel info, the elkrems, and the current state. restore happens all at once, but saving to the db can happen incrementally (updating states) This should populate everything int he Qchan struct: the elkrems and the states. Elkrem sender always works; is derived from local key data. Elkrem receiver can be "empty" with nothing in it (no data in db)

func (*LitNode) RevHandler

func (nd *LitNode) RevHandler(msg lnutil.RevMsg, qc *Qchan) error

REVHandler takes in an 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

func (nd *LitNode) SaveJusticeSig(comnum uint64, pkh [20]byte, txidsig [80]byte) error

SaveJusticeSig save the txid/sig of a justice transaction to the db. Pretty straightforward

func (*LitNode) SaveNicknameForPeerIdx

func (nd *LitNode) SaveNicknameForPeerIdx(nickname string, idx uint32) error

SaveNicknameForPeerIdx saves/overwrites a nickname for a given peer idx

func (*LitNode) SaveQChan

func (nd *LitNode) SaveQChan(q *Qchan) error

register a new Qchan in the db

func (*LitNode) SaveQchanState

func (nd *LitNode) SaveQchanState(q *Qchan) error

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

func (nd *LitNode) SaveQchanUtxoData(q *Qchan) error

SaveQchanUtxoData saves utxo data such as outpoint and close tx / status

func (*LitNode) SelfPushHandler

func (nd *LitNode) SelfPushHandler(msg lnutil.LitMsg) error

func (*LitNode) SendChat

func (nd *LitNode) SendChat(peer uint32, chat string) error

SendChat sends a text string to a peer

func (*LitNode) SendDeltaSig

func (nd *LitNode) SendDeltaSig(q *Qchan) error

SendDeltaSig initiates a push, sending the amount to be pushed and the new sig.

func (*LitNode) SendGapSigRev

func (nd *LitNode) SendGapSigRev(q *Qchan) error

SendGapSigRev is different; it signs for state+1 and revokes state-1

func (*LitNode) SendREV

func (nd *LitNode) SendREV(q *Qchan) error

SendREV sends a REV message based on channel info

func (*LitNode) SendSigRev

func (nd *LitNode) SendSigRev(q *Qchan) error

SendSigRev sends an SigRev message based on channel info

func (*LitNode) SendWatchComMsg

func (nd *LitNode) SendWatchComMsg(qc *Qchan, idx uint64) error

send WatchComMsg generates and sends the ComMsg to a watchtower

func (*LitNode) SetQchanRefund

func (nd *LitNode) SetQchanRefund(q *Qchan, refund, hakdBase [33]byte) error

SetQchanRefund overwrites "theirrefund" and "theirHAKDbase" in a qchan.

This is needed after getting a chanACK.

func (*LitNode) ShowJusticeDB

func (nd *LitNode) ShowJusticeDB() (string, error)

func (*LitNode) SigProofHandler

func (nd *LitNode) SigProofHandler(msg lnutil.SigProofMsg, peer *RemotePeer)

RECIPIENT SigProofHandler saves the signature the recipent stores. In some cases you don't need this message.

func (*LitNode) SigRevHandler

func (nd *LitNode) SigRevHandler(msg lnutil.SigRevMsg, qc *Qchan) error

SIGREVHandler takes in an SIGREV and responds with a REV (if everything goes OK) Leaves the channel in a clear / rest state.

func (*LitNode) SignBreakTx

func (nd *LitNode) SignBreakTx(q *Qchan) (*wire.MsgTx, error)

SignBreak signs YOUR tx, which you already have a sig for

func (*LitNode) SignSimpleClose

func (nd *LitNode) SignSimpleClose(q *Qchan, tx *wire.MsgTx) ([64]byte, error)

SignSimpleClose signs the given simpleClose tx, given the other signature Tx is modified in place.

func (*LitNode) SignState

func (nd *LitNode) SignState(q *Qchan) ([64]byte, error)

SignNextState generates your signature for their state.

func (*LitNode) SyncWatch

func (nd *LitNode) SyncWatch(qc *Qchan) error

SendWatch syncs up the remote watchtower with all justice signatures

func (*LitNode) TCPListener

func (nd *LitNode) TCPListener(
	lisIpPort string) (string, error)

TCPListener starts a litNode listening for incoming LNDC connections

type PeerInfo

type PeerInfo struct {
	PeerNumber uint32
	RemoteHost string
	Nickname   string
}

type QCloseData

type QCloseData struct {
	// 3 txid / height pairs are stored.  All 3 only are used in the
	// case where you grab their invalid close.
	CloseTxid   chainhash.Hash
	CloseHeight int32
	Closed      bool // if channel is closed; if CloseTxid != -1
}

func QCloseFromBytes

func QCloseFromBytes(b []byte) (QCloseData, error)

QCloseFromBytes deserializes a Qclose. Note that a nil slice gives an empty / non closed qclose.

func (*QCloseData) ToBytes

func (c *QCloseData) ToBytes() ([]byte, error)

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

}

Uhh, quick channel. For now. Once you get greater spire it upgrades to a full channel that can do everything.

func QchanFromBytes

func QchanFromBytes(b []byte) (Qchan, error)

QchanFromBytes turns bytes into a Qchan. the first 99 bytes are the 3 pubkeys: channel, refund, HAKD base then 8 bytes for the DH mask the rest is the utxo

func (*Qchan) AdvanceElkrem

func (q *Qchan) AdvanceElkrem(elk *chainhash.Hash, n2Elk [33]byte) error

func (*Qchan) BuildStateTx

func (q *Qchan) BuildStateTx(mine bool) (*wire.MsgTx, error)

BuildStateTx constructs and returns a state tx. 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) Coin

func (q *Qchan) Coin() uint32

Coin returns the coin type of the channel

func (*Qchan) ElkPoint

func (q *Qchan) ElkPoint(mine bool, idx uint64) (p [33]byte, err error)

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) GetChanHint

func (q *Qchan) GetChanHint(mine bool) uint64

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) GetCloseTxos

func (q *Qchan) GetCloseTxos(tx *wire.MsgTx) ([]portxo.PorTxo, error)

GetCloseTxos takes in a tx and sets the QcloseTXO feilds 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) Idx

func (q *Qchan) Idx() uint32

Idx returns the local index of the channel

func (*Qchan) ImFirst

func (q *Qchan) ImFirst() bool

ImFirst decides who goes first when it's unclear. Smaller pubkey goes first.

func (*Qchan) IngestElkrem

func (q *Qchan) IngestElkrem(elk *chainhash.Hash) error

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

func (q *Qchan) N2ElkPointForThem() (p [33]byte, err error)

CurElkPointForThem makes the current state elkrem point to send out

func (*Qchan) Peer

func (q *Qchan) Peer() uint32

Peer returns the local peer index of the channel

func (*Qchan) SimpleCloseTx

func (q *Qchan) SimpleCloseTx() (*wire.MsgTx, error)

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) ToBytes

func (q *Qchan) ToBytes() ([]byte, error)

func (*Qchan) VerifySig

func (q *Qchan) VerifySig(sig [64]byte) error

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 RemotePeer

type RemotePeer struct {
	Idx      uint32 // the peer index
	Nickname string
	Con      *lndc.LNDConn
	QCs      map[uint32]*Qchan   // keep map of all peer's channels in ram
	OpMap    map[[36]byte]uint32 // quick lookup for channels
}

type SigRevMsg

type SigRevMsg struct {
	Op    wire.OutPoint
	Delta int32
	Sig   [64]byte
}

example message struct

func SigRevFromBytes

func SigRevFromBytes(b []byte) (*SigRevMsg, error)

example deserialization method

func (*SigRevMsg) Bytes

func (m *SigRevMsg) Bytes() []byte

example serialization method

type StatCom

type StatCom struct {
	StateIdx uint64 // this is the n'th state commitment

	WatchUpTo uint64 // have sent out to watchtowers up to this state  ( < stateidx)

	MyAmt int64 // my channel allocation

	Fee int64 // symmetric fee in absolute satoshis

	// their Amt is the utxo.Value minus this
	Delta int32 // 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

	// Elkrem point from counterparty, used to make
	// Homomorphic Adversarial Key Derivation public keys (HAKD)
	ElkPoint     [33]byte // saved to disk, current revealable point
	NextElkPoint [33]byte // Point stored for next state
	N2ElkPoint   [33]byte // Point for state after next (in case of collision)
	// contains filtered or unexported fields
}

StatComs are State Commitments. all elements are saved to the db.

func StatComFromBytes

func StatComFromBytes(b []byte) (*StatCom, error)

StatComFromBytes turns 192 bytes into a StatCom

func (*StatCom) ToBytes

func (s *StatCom) ToBytes() ([]byte, error)

ToBytes turns a StatCom into 192ish bytes

type UWallet

type UWallet interface {
	// Ask for a pubkey based on a bip32 path
	GetPub(k portxo.KeyGen) *btcec.PublicKey

	// Have GetPriv for now.  Maybe later get rid of this and have
	// the underlying wallet sign?
	GetPriv(k portxo.KeyGen) *btcec.PrivateKey

	// 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

	// LetMeKnow opens the chan where OutPointEvent flows from the underlying
	// wallet up to the LN module.
	LetMeKnow() chan lnutil.OutPointEvent

	// 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)
}

The UWallet interface are the functions needed to work with the LnNode Verbs are from the perspective of the LnNode, not the underlying wallet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL