lnwallet: use InputScripts struct within ChannelReservation
This allows the reservation workflow to support pure witness program outputs, as well as witness programs nested within p2sh.
This commit is contained in:
parent
eeb2887fe9
commit
0e74672797
@ -48,6 +48,14 @@ type ChannelContribution struct {
|
|||||||
CsvDelay uint32
|
CsvDelay uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InputScripts represents any script inputs required to redeem a previous
|
||||||
|
// output. This struct is used rather than just a witness, or scripSig in
|
||||||
|
// order to accomdate nested p2sh which utilizes both types of input scripts.
|
||||||
|
type InputScript struct {
|
||||||
|
Witness [][]byte
|
||||||
|
ScriptSig []byte
|
||||||
|
}
|
||||||
|
|
||||||
// ChannelReservation represents an intent to open a lightning payment channel
|
// ChannelReservation represents an intent to open a lightning payment channel
|
||||||
// a counterpaty. The funding proceses from reservation to channel opening is a
|
// a counterpaty. The funding proceses from reservation to channel opening is a
|
||||||
// 3-step process. In order to allow for full concurrency during the reservation
|
// 3-step process. In order to allow for full concurrency during the reservation
|
||||||
@ -89,8 +97,8 @@ type ChannelReservation struct {
|
|||||||
|
|
||||||
// In order of sorted inputs. Sorting is done in accordance
|
// In order of sorted inputs. Sorting is done in accordance
|
||||||
// to BIP-69: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki.
|
// to BIP-69: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki.
|
||||||
ourFundingSigs [][]byte
|
ourFundingInputScripts []*InputScript
|
||||||
theirFundingSigs [][]byte
|
theirFundingInputScripts []*InputScript
|
||||||
|
|
||||||
// Our signature for their version of the commitment transaction.
|
// Our signature for their version of the commitment transaction.
|
||||||
ourCommitmentSig []byte
|
ourCommitmentSig []byte
|
||||||
@ -188,10 +196,10 @@ func (r *ChannelReservation) TheirContribution() *ChannelContribution {
|
|||||||
// BIP-69: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki.
|
// BIP-69: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki.
|
||||||
// NOTE: These signatures will only be populated after a call to
|
// NOTE: These signatures will only be populated after a call to
|
||||||
// .ProcesContribution()
|
// .ProcesContribution()
|
||||||
func (r *ChannelReservation) OurSignatures() ([][]byte, []byte) {
|
func (r *ChannelReservation) OurSignatures() ([]*InputScript, []byte) {
|
||||||
r.RLock()
|
r.RLock()
|
||||||
defer r.RUnlock()
|
defer r.RUnlock()
|
||||||
return r.ourFundingSigs, r.ourCommitmentSig
|
return r.ourFundingInputScripts, r.ourCommitmentSig
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompleteFundingReservation finalizes the pending channel reservation,
|
// CompleteFundingReservation finalizes the pending channel reservation,
|
||||||
@ -206,16 +214,16 @@ func (r *ChannelReservation) OurSignatures() ([][]byte, []byte) {
|
|||||||
// which will block until the funding transaction obtains the configured number
|
// which will block until the funding transaction obtains the configured number
|
||||||
// of confirmations. Once the method unblocks, a LightningChannel instance is
|
// of confirmations. Once the method unblocks, a LightningChannel instance is
|
||||||
// returned, marking the channel available for updates.
|
// returned, marking the channel available for updates.
|
||||||
func (r *ChannelReservation) CompleteReservation(fundingSigs [][]byte,
|
func (r *ChannelReservation) CompleteReservation(fundingInputScripts []*InputScript,
|
||||||
commitmentSig []byte) error {
|
commitmentSig []byte) error {
|
||||||
|
|
||||||
errChan := make(chan error, 1)
|
errChan := make(chan error, 1)
|
||||||
|
|
||||||
r.wallet.msgChan <- &addCounterPartySigsMsg{
|
r.wallet.msgChan <- &addCounterPartySigsMsg{
|
||||||
pendingFundingID: r.reservationID,
|
pendingFundingID: r.reservationID,
|
||||||
theirFundingSigs: fundingSigs,
|
theirFundingInputScripts: fundingInputScripts,
|
||||||
theirCommitmentSig: commitmentSig,
|
theirCommitmentSig: commitmentSig,
|
||||||
err: errChan,
|
err: errChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
return <-errChan
|
return <-errChan
|
||||||
@ -227,10 +235,10 @@ func (r *ChannelReservation) CompleteReservation(fundingSigs [][]byte,
|
|||||||
// additional verification, such as needed by tests.
|
// additional verification, such as needed by tests.
|
||||||
// NOTE: These attributes will be unpopulated before a call to
|
// NOTE: These attributes will be unpopulated before a call to
|
||||||
// .CompleteReservation().
|
// .CompleteReservation().
|
||||||
func (r *ChannelReservation) TheirSignatures() ([][]byte, []byte) {
|
func (r *ChannelReservation) TheirSignatures() ([]*InputScript, []byte) {
|
||||||
r.RLock()
|
r.RLock()
|
||||||
defer r.RUnlock()
|
defer r.RUnlock()
|
||||||
return r.theirFundingSigs, r.theirCommitmentSig
|
return r.theirFundingInputScripts, r.theirCommitmentSig
|
||||||
}
|
}
|
||||||
|
|
||||||
// FinalFundingTx returns the finalized, fully signed funding transaction for
|
// FinalFundingTx returns the finalized, fully signed funding transaction for
|
||||||
@ -267,11 +275,5 @@ func (r *ChannelReservation) WaitForChannelOpen() *LightningChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// * finish reset of tests
|
// * finish reset of tests
|
||||||
// * comment out stuff that'll need a node.
|
|
||||||
// * start on commitment side
|
// * start on commitment side
|
||||||
// * implement rusty's shachain
|
|
||||||
// * set up logic to get notification from node when funding tx gets 6 deep.
|
|
||||||
// * prob spawn into ChainNotifier struct
|
|
||||||
// * create builder for initial funding transaction
|
|
||||||
// * fascade through the wallet, for signing and such.
|
|
||||||
// * channel should have active namespace to it's bucket, query at that point fo past commits etc
|
// * channel should have active namespace to it's bucket, query at that point fo past commits etc
|
||||||
|
Loading…
Reference in New Issue
Block a user