lnwallet+funding: rename Capacity and FundingAmt
Instead use LocalFundingAmt and RemoteFundingAmt to make it clear who is contributing funds.
This commit is contained in:
4 files changed
+113
-107
No files matched your search
@@ -127,7 +127,7 @@ type ChannelReservation struct {
|
||||
// used only internally by lnwallet. In order to concurrent safety, the
|
||||
// creation of all channel reservations should be carried out via the
|
||||
// lnwallet.InitChannelReservation interface.
|
||||
func NewChannelReservation(capacity, fundingAmt btcutil.Amount,
|
||||
func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
||||
commitFeePerKw SatPerKWeight, wallet *LightningWallet,
|
||||
id uint64, pushMSat lnwire.MilliSatoshi, chainHash *chainhash.Hash,
|
||||
flags lnwire.FundingFlag) (*ChannelReservation, error) {
|
||||
@@ -139,14 +139,16 @@ func NewChannelReservation(capacity, fundingAmt btcutil.Amount,
|
||||
)
|
||||
|
||||
commitFee := commitFeePerKw.FeeForWeight(input.CommitWeight)
|
||||
fundingMSat := lnwire.NewMSatFromSatoshis(fundingAmt)
|
||||
localFundingMSat := lnwire.NewMSatFromSatoshis(localFundingAmt)
|
||||
// TODO(halseth): make method take remote funding amount direcly
|
||||
// instead of inferring it from capacity and local amt.
|
||||
capacityMSat := lnwire.NewMSatFromSatoshis(capacity)
|
||||
feeMSat := lnwire.NewMSatFromSatoshis(commitFee)
|
||||
|
||||
// If we're the responder to a single-funder reservation, then we have
|
||||
// no initial balance in the channel unless the remote party is pushing
|
||||
// some funds to us within the first commitment state.
|
||||
if fundingAmt == 0 {
|
||||
if localFundingAmt == 0 {
|
||||
ourBalance = pushMSat
|
||||
theirBalance = capacityMSat - feeMSat - pushMSat
|
||||
initiator = false
|
||||
@@ -163,7 +165,7 @@ func NewChannelReservation(capacity, fundingAmt btcutil.Amount,
|
||||
// TODO(roasbeef): need to rework fee structure in general and
|
||||
// also when we "unlock" dual funder within the daemon
|
||||
|
||||
if capacity == fundingAmt {
|
||||
if capacity == localFundingAmt {
|
||||
// If we're initiating a single funder workflow, then
|
||||
// we pay all the initial fees within the commitment
|
||||
// transaction. We also deduct our balance by the
|
||||
@@ -174,8 +176,8 @@ func NewChannelReservation(capacity, fundingAmt btcutil.Amount,
|
||||
// Otherwise, this is a dual funder workflow where both
|
||||
// slides split the amount funded and the commitment
|
||||
// fee.
|
||||
ourBalance = fundingMSat - (feeMSat / 2)
|
||||
theirBalance = capacityMSat - fundingMSat - (feeMSat / 2) + pushMSat
|
||||
ourBalance = localFundingMSat - (feeMSat / 2)
|
||||
theirBalance = capacityMSat - localFundingMSat - (feeMSat / 2) + pushMSat
|
||||
}
|
||||
|
||||
initiator = true
|
||||
|
||||
Reference in new issue
Block a user