lnwallet: CompleteReservation now includes sig for commit tx

This commit is contained in:
Olaoluwa Osuntokun 2015-12-21 15:54:33 -06:00
parent 584fc9b620
commit 829f67f33e
2 changed files with 17 additions and 6 deletions

@ -302,13 +302,14 @@ func (r *ChannelReservation) TheirKeys() (*btcec.PublicKey, *btcec.PublicKey) {
// CompleteFundingReservation...
// TODO(roasbeef): add commit sig also
func (r *ChannelReservation) CompleteReservation(theirSigs [][]byte) error {
func (r *ChannelReservation) CompleteReservation(fundingSigs [][]byte, commitmentSig []byte) error {
errChan := make(chan error, 1)
r.wallet.msgChan <- &addCounterPartySigsMsg{
pendingFundingID: r.reservationID,
theirSigs: theirSigs,
err: errChan,
pendingFundingID: r.reservationID,
theirFundingSigs: fundingSigs,
theirCommitmentSig: commitmentSig,
err: errChan,
}
return <-errChan

@ -124,7 +124,11 @@ type addCounterPartySigsMsg struct {
// Should be order of sorted inputs that are theirs. Sorting is done in accordance
// to BIP-69: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki.
theirSigs [][]byte
theirFundingSigs [][]byte
// This should be 1/2 of the signatures needed to succesfully spend our
// version of the commitment transaction.
theirCommitmentSig []byte
err chan error // Buffered
}
@ -676,7 +680,7 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
// Now we can complete the funding transaction by adding their
// signatures to their inputs.
pendingReservation.theirFundingSigs = msg.theirSigs
pendingReservation.theirFundingSigs = msg.theirFundingSigs
fundingTx := pendingReservation.partialState.fundingTx
for i, txin := range fundingTx.TxIn {
if txin.SignatureScript == nil {
@ -713,6 +717,12 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
}
}
// At this point, wen calso record and verify their isgnature for our
// commitment transaction.
pendingReservation.partialState.theirCommitSig = msg.theirCommitmentSig
// TODO(roasbeef): verify
//commitSig := msg.theirCommitmentSig
// Funding complete, this entry can be removed from limbo.
l.limboMtx.Lock()
delete(l.fundingLimbo, pendingReservation.reservationID)