diff --git a/lnwallet/reservation.go b/lnwallet/reservation.go index 5f988f6d..b3db23bd 100644 --- a/lnwallet/reservation.go +++ b/lnwallet/reservation.go @@ -48,6 +48,14 @@ type ChannelContribution struct { 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 // 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 @@ -89,8 +97,8 @@ type ChannelReservation struct { // In order of sorted inputs. Sorting is done in accordance // to BIP-69: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki. - ourFundingSigs [][]byte - theirFundingSigs [][]byte + ourFundingInputScripts []*InputScript + theirFundingInputScripts []*InputScript // Our signature for their version of the commitment transaction. ourCommitmentSig []byte @@ -188,10 +196,10 @@ func (r *ChannelReservation) TheirContribution() *ChannelContribution { // BIP-69: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki. // NOTE: These signatures will only be populated after a call to // .ProcesContribution() -func (r *ChannelReservation) OurSignatures() ([][]byte, []byte) { +func (r *ChannelReservation) OurSignatures() ([]*InputScript, []byte) { r.RLock() defer r.RUnlock() - return r.ourFundingSigs, r.ourCommitmentSig + return r.ourFundingInputScripts, r.ourCommitmentSig } // 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 // of confirmations. Once the method unblocks, a LightningChannel instance is // returned, marking the channel available for updates. -func (r *ChannelReservation) CompleteReservation(fundingSigs [][]byte, +func (r *ChannelReservation) CompleteReservation(fundingInputScripts []*InputScript, commitmentSig []byte) error { errChan := make(chan error, 1) r.wallet.msgChan <- &addCounterPartySigsMsg{ - pendingFundingID: r.reservationID, - theirFundingSigs: fundingSigs, - theirCommitmentSig: commitmentSig, - err: errChan, + pendingFundingID: r.reservationID, + theirFundingInputScripts: fundingInputScripts, + theirCommitmentSig: commitmentSig, + err: errChan, } return <-errChan @@ -227,10 +235,10 @@ func (r *ChannelReservation) CompleteReservation(fundingSigs [][]byte, // additional verification, such as needed by tests. // NOTE: These attributes will be unpopulated before a call to // .CompleteReservation(). -func (r *ChannelReservation) TheirSignatures() ([][]byte, []byte) { +func (r *ChannelReservation) TheirSignatures() ([]*InputScript, []byte) { r.RLock() defer r.RUnlock() - return r.theirFundingSigs, r.theirCommitmentSig + return r.theirFundingInputScripts, r.theirCommitmentSig } // FinalFundingTx returns the finalized, fully signed funding transaction for @@ -267,11 +275,5 @@ func (r *ChannelReservation) WaitForChannelOpen() *LightningChannel { } // * finish reset of tests -// * comment out stuff that'll need a node. // * 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