lnwallet: add skeleton for LightningChannel
* pretty much same as strux/lchannel.go * Too beefy atm, added note to bring back old CompleteReservation struct
This commit is contained in:
parent
a83dac4e86
commit
48c1c39dc9
@ -9,11 +9,7 @@ import (
|
|||||||
"github.com/btcsuite/btcwallet/walletdb"
|
"github.com/btcsuite/btcwallet/walletdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LightningChannel struct {
|
|
||||||
shachan *revocation.HyperShaChain
|
|
||||||
wallet *LightningWallet
|
|
||||||
|
|
||||||
channelEvents *chainntnfs.ChainNotifier
|
|
||||||
// P2SHify...
|
// P2SHify...
|
||||||
func P2SHify(scriptBytes []byte) ([]byte, error) {
|
func P2SHify(scriptBytes []byte) ([]byte, error) {
|
||||||
bldr := txscript.NewScriptBuilder()
|
bldr := txscript.NewScriptBuilder()
|
||||||
@ -23,19 +19,111 @@ func P2SHify(scriptBytes []byte) ([]byte, error) {
|
|||||||
return bldr.Script()
|
return bldr.Script()
|
||||||
}
|
}
|
||||||
|
|
||||||
sync.RWMutex
|
|
||||||
|
|
||||||
|
type nodeId [32]byte
|
||||||
|
|
||||||
|
type LightningChannel struct {
|
||||||
|
wallet *LightningWallet
|
||||||
|
channelEvents *chainntnfs.ChainNotifier
|
||||||
|
|
||||||
|
// TODO(roasbeef): Stores all previous R values + timeouts for each
|
||||||
|
// commitment update, plus some other meta-data...Or just use OP_RETURN
|
||||||
|
// to help out?
|
||||||
channelNamespace walletdb.Namespace
|
channelNamespace walletdb.Namespace
|
||||||
|
|
||||||
// TODO(roasbeef): create and embed 'Service' interface w/ below?
|
Id [32]byte
|
||||||
started int32
|
|
||||||
|
|
||||||
|
capacity btcutil.Amount
|
||||||
|
ourTotalFunds btcutil.Amount
|
||||||
|
theirTotalFunds btcutil.Amount
|
||||||
|
|
||||||
|
// TODO(roasbeef): another shachain for R values for HTLC's?
|
||||||
|
// solve above?
|
||||||
|
ourShaChain *revocation.HyperShaChain
|
||||||
|
theirShaChain *revocation.HyperShaChain
|
||||||
|
|
||||||
|
ourFundingKey *btcec.PrivateKey
|
||||||
|
theirFundingKey *btcec.PublicKey
|
||||||
|
|
||||||
|
ourCommitKey *btcec.PublicKey
|
||||||
|
theirCommitKey *btcec.PublicKey
|
||||||
|
|
||||||
|
fundingTx *wire.MsgTx
|
||||||
|
commitmentTx *wire.MsgTx
|
||||||
|
|
||||||
|
sync.RWMutex
|
||||||
|
|
||||||
|
// TODO(roasbeef): create and embed 'Service' interface w/ below?
|
||||||
|
started int32
|
||||||
shutdown int32
|
shutdown int32
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLightningChannel() *LightningChannel {
|
// newLightningChannel...
|
||||||
|
// TODO(roasbeef): bring back and embedd CompleteReservation struct? kinda large
|
||||||
|
// atm.....
|
||||||
|
func newLightningChannel(wallet *LightningWallet, events *chainntnfs.ChainNotifier,
|
||||||
|
dbNamespace walletdb.Namespace, theirNodeID nodeId, ourFunds,
|
||||||
|
theirFunds btcutil.Amount, ourChain, theirChain *revocation.HyperShaChain,
|
||||||
|
ourFundingKey *btcec.PrivateKey, theirFundingKey *btcec.PublicKey,
|
||||||
|
commitKey, theirCommitKey *btcec.PublicKey, fundingTx,
|
||||||
|
commitTx *wire.MsgTx) (*LightningChannel, error) {
|
||||||
|
|
||||||
|
return &LightningChannel{
|
||||||
|
wallet: wallet,
|
||||||
|
channelEvents: events,
|
||||||
|
channelNamespace: dbNamespace,
|
||||||
|
Id: theirNodeID,
|
||||||
|
capacity: ourFunds + theirFunds,
|
||||||
|
ourTotalFunds: ourFunds,
|
||||||
|
theirTotalFunds: theirFunds,
|
||||||
|
ourShaChain: ourChain,
|
||||||
|
theirShaChain: theirChain,
|
||||||
|
ourFundingKey: ourFundingKey,
|
||||||
|
theirFundingKey: theirFundingKey,
|
||||||
|
ourCommitKey: commitKey,
|
||||||
|
theirCommitKey: theirCommitKey,
|
||||||
|
fundingTx: fundingTx,
|
||||||
|
commitmentTx: commitTx,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddHTLC...
|
||||||
|
func (lc *LightningChannel) AddHTLC() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SettleHTLC...
|
||||||
|
func (lc *LightningChannel) SettleHTLC() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// OurBalance...
|
||||||
|
func (lc *LightningChannel) OurBalance() btcutil.Amount {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// TheirBalance...
|
||||||
|
func (lc *LightningChannel) TheirBalance() btcutil.Amount {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrentCommitTx...
|
||||||
|
func (lc *LightningChannel) CurrentCommitTx() *btcutil.Tx {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignTheirCommitTx...
|
||||||
|
func (lc *LightningChannel) SignTheirCommitTx(commitTx *btcutil.Tx) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddTheirSig...
|
||||||
|
func (lc *LightningChannel) AddTheirSig(sig []byte) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VerifyCommitmentUpdate...
|
||||||
|
func (lc *LightningChannel) VerifyCommitmentUpdate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user