From 42ba1a53946f6d61376bdb3d34ebf4ee5e344733 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 28 Nov 2015 18:20:57 -0600 Subject: [PATCH] lnwallet/reservation: s/Unlock/RUnlock, fix panic caused by double unlock --- wallet/reservation.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wallet/reservation.go b/wallet/reservation.go index 59ce6bee3..1f58b5efc 100644 --- a/wallet/reservation.go +++ b/wallet/reservation.go @@ -16,7 +16,7 @@ type ChannelReservation struct { ReserveAmount btcutil.Amount MinFeePerKb btcutil.Amount - sync.RWMutex // All fields below owned by the wallet. + sync.RWMutex // All fields below owned by the lnwallet. theirInputs []*wire.TxIn ourInputs []*wire.TxIn @@ -59,7 +59,7 @@ func newChannelReservation(t FundingType, fundingAmt btcutil.Amount, // OurFunds... func (r *ChannelReservation) OurFunds() ([]*wire.TxIn, []*wire.TxOut, *btcec.PublicKey) { r.RLock() - defer r.Unlock() + defer r.RUnlock() return r.ourInputs, r.ourChange, r.ourKey.PubKey() } @@ -80,14 +80,15 @@ func (r *ChannelReservation) AddFunds(theirInputs []*wire.TxIn, theirChangeOutpu // OurSigs... func (r *ChannelReservation) OurSigs() [][]byte { r.RLock() - defer r.Unlock() + defer r.RUnlock() return r.ourSigs } // TheirFunds... +// TODO(roasbeef): return error if accessors not yet populated? func (r *ChannelReservation) TheirFunds() ([]*wire.TxIn, []*wire.TxOut, *btcec.PublicKey) { r.RLock() - defer r.Unlock() + defer r.RUnlock() return r.theirInputs, r.theirChange, r.theirKey } @@ -107,7 +108,7 @@ func (r *ChannelReservation) CompleteReservation(theirSigs [][]byte) error { // FinalFundingTransaction... func (r *ChannelReservation) FinalFundingTx() *btcutil.Tx { r.RLock() - defer r.Unlock() + defer r.RUnlock() return r.completedFundingTx }