mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-22 22:25:26 +01:00
LocalParams should not include maxFeerateMismatch (#70)
as it is not a direct protocol parameter
This commit is contained in:
parent
102f76e401
commit
378a332954
6 changed files with 11 additions and 14 deletions
|
@ -246,7 +246,7 @@ class Channel(val nodeParams: NodeParams, remoteNodeId: PublicKey, blockchain: A
|
|||
case Success(MakeFundingTxResponse(_, fundingTx, fundingTxOutputIndex, _)) =>
|
||||
// let's create the first commitment tx that spends the yet uncommitted funding tx
|
||||
import data._
|
||||
val (localSpec, localCommitTx, remoteSpec, remoteCommitTx) = Funding.makeFirstCommitTxs(localParams, remoteParams, fundingSatoshis, pushMsat, initialFeeratePerKw, fundingTx.hash, fundingTxOutputIndex, remoteFirstPerCommitmentPoint)
|
||||
val (localSpec, localCommitTx, remoteSpec, remoteCommitTx) = Funding.makeFirstCommitTxs(localParams, remoteParams, fundingSatoshis, pushMsat, initialFeeratePerKw, fundingTx.hash, fundingTxOutputIndex, remoteFirstPerCommitmentPoint, nodeParams.maxFeerateMismatch)
|
||||
|
||||
val localSigOfRemoteTx = Transactions.sign(remoteCommitTx, localParams.fundingPrivKey)
|
||||
// signature of their initial commitment tx that pays remote pushMsat
|
||||
|
@ -275,7 +275,7 @@ class Channel(val nodeParams: NodeParams, remoteNodeId: PublicKey, blockchain: A
|
|||
when(WAIT_FOR_FUNDING_CREATED)(handleExceptions {
|
||||
case Event(FundingCreated(_, fundingTxHash, fundingTxOutputIndex, remoteSig), DATA_WAIT_FOR_FUNDING_CREATED(temporaryChannelId, localParams, remoteParams, fundingSatoshis, pushMsat, initialFeeratePerKw, remoteFirstPerCommitmentPoint, _)) =>
|
||||
// they fund the channel with their funding tx, so the money is theirs (but we are paid pushMsat)
|
||||
val (localSpec, localCommitTx, remoteSpec, remoteCommitTx) = Funding.makeFirstCommitTxs(localParams, remoteParams, fundingSatoshis: Long, pushMsat, initialFeeratePerKw, fundingTxHash, fundingTxOutputIndex, remoteFirstPerCommitmentPoint)
|
||||
val (localSpec, localCommitTx, remoteSpec, remoteCommitTx) = Funding.makeFirstCommitTxs(localParams, remoteParams, fundingSatoshis: Long, pushMsat, initialFeeratePerKw, fundingTxHash, fundingTxOutputIndex, remoteFirstPerCommitmentPoint, nodeParams.maxFeerateMismatch)
|
||||
|
||||
// check remote signature validity
|
||||
val localSigOfLocalTx = Transactions.sign(localCommitTx, localParams.fundingPrivKey)
|
||||
|
@ -494,7 +494,7 @@ class Channel(val nodeParams: NodeParams, remoteNodeId: PublicKey, blockchain: A
|
|||
}
|
||||
|
||||
case Event(fee: UpdateFee, d: DATA_NORMAL) =>
|
||||
Try(Commitments.receiveFee(d.commitments, fee)) match {
|
||||
Try(Commitments.receiveFee(d.commitments, fee, nodeParams.maxFeerateMismatch)) match {
|
||||
case Success(commitments1) => goto(NORMAL) using d.copy(commitments = commitments1)
|
||||
case Failure(cause) => handleLocalError(cause, d)
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ class Channel(val nodeParams: NodeParams, remoteNodeId: PublicKey, blockchain: A
|
|||
}
|
||||
|
||||
case Event(fee: UpdateFee, d: DATA_SHUTDOWN) =>
|
||||
Try(Commitments.receiveFee(d.commitments, fee)) match {
|
||||
Try(Commitments.receiveFee(d.commitments, fee, nodeParams.maxFeerateMismatch)) match {
|
||||
case Success(commitments1) => goto(NORMAL) using d.copy(commitments = commitments1)
|
||||
case Failure(cause) => handleLocalError(cause, d)
|
||||
}
|
||||
|
|
|
@ -167,8 +167,7 @@ final case class LocalParams(nodeId: PublicKey,
|
|||
shaSeed: BinaryData,
|
||||
isFunder: Boolean,
|
||||
globalFeatures: BinaryData,
|
||||
localFeatures: BinaryData,
|
||||
maxFeerateMismatch: Double)
|
||||
localFeatures: BinaryData)
|
||||
|
||||
final case class RemoteParams(nodeId: PublicKey,
|
||||
dustLimitSatoshis: Long,
|
||||
|
|
|
@ -281,7 +281,7 @@ object Commitments extends Logging {
|
|||
commitments.remoteChanges.signed.contains(fee) ||
|
||||
commitments.remoteChanges.acked.contains(fee)
|
||||
|
||||
def receiveFee(commitments: Commitments, fee: UpdateFee): Commitments =
|
||||
def receiveFee(commitments: Commitments, fee: UpdateFee, maxFeerateMismatch: Double): Commitments =
|
||||
isOldFee(commitments, fee) match {
|
||||
case true => commitments
|
||||
case false =>
|
||||
|
@ -290,7 +290,7 @@ object Commitments extends Logging {
|
|||
}
|
||||
|
||||
val localFeeratePerKw = Globals.feeratePerKw.get()
|
||||
if (Helpers.isFeeDiffTooHigh(fee.feeratePerKw, localFeeratePerKw, commitments.localParams.maxFeerateMismatch)) {
|
||||
if (Helpers.isFeeDiffTooHigh(fee.feeratePerKw, localFeeratePerKw, maxFeerateMismatch)) {
|
||||
throw new RuntimeException(s"local/remote feerates are too different: remoteFeeratePerKw=${fee.feeratePerKw} localFeeratePerKw=$localFeeratePerKw")
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ object Helpers {
|
|||
* @param remoteFirstPerCommitmentPoint
|
||||
* @return (localSpec, localTx, remoteSpec, remoteTx, fundingTxOutput)
|
||||
*/
|
||||
def makeFirstCommitTxs(localParams: LocalParams, remoteParams: RemoteParams, fundingSatoshis: Long, pushMsat: Long, initialFeeratePerKw: Long, fundingTxHash: BinaryData, fundingTxOutputIndex: Int, remoteFirstPerCommitmentPoint: Point): (CommitmentSpec, CommitTx, CommitmentSpec, CommitTx) = {
|
||||
def makeFirstCommitTxs(localParams: LocalParams, remoteParams: RemoteParams, fundingSatoshis: Long, pushMsat: Long, initialFeeratePerKw: Long, fundingTxHash: BinaryData, fundingTxOutputIndex: Int, remoteFirstPerCommitmentPoint: Point, maxFeerateMismatch: Double): (CommitmentSpec, CommitTx, CommitmentSpec, CommitTx) = {
|
||||
val toLocalMsat = if (localParams.isFunder) fundingSatoshis * 1000 - pushMsat else pushMsat
|
||||
val toRemoteMsat = if (localParams.isFunder) pushMsat else fundingSatoshis * 1000 - pushMsat
|
||||
|
||||
|
@ -120,7 +120,7 @@ object Helpers {
|
|||
if (!localParams.isFunder) {
|
||||
// they are funder, we need to make sure that they can pay the fee is reasonable, and that they can afford to pay it
|
||||
val localFeeratePerKw = Globals.feeratePerKw.get()
|
||||
if (isFeeDiffTooHigh(initialFeeratePerKw, localFeeratePerKw, localParams.maxFeerateMismatch)) {
|
||||
if (isFeeDiffTooHigh(initialFeeratePerKw, localFeeratePerKw, maxFeerateMismatch)) {
|
||||
throw new RuntimeException(s"local/remote feerates are too different: remoteFeeratePerKw=$initialFeeratePerKw localFeeratePerKw=$localFeeratePerKw")
|
||||
}
|
||||
val toRemote = MilliSatoshi(remoteSpec.toLocalMsat)
|
||||
|
|
|
@ -258,8 +258,7 @@ object Peer {
|
|||
shaSeed = Crypto.sha256(generateKey(nodeParams, keyIndex :: 4L :: Nil).toBin), // TODO: check that
|
||||
isFunder = isFunder,
|
||||
globalFeatures = nodeParams.globalFeatures,
|
||||
localFeatures = nodeParams.localFeatures,
|
||||
maxFeerateMismatch = nodeParams.maxFeerateMismatch)
|
||||
localFeatures = nodeParams.localFeatures)
|
||||
}
|
||||
|
||||
def randomTemporaryChannelId: BinaryData = {
|
||||
|
|
|
@ -46,8 +46,7 @@ object ChannelStateSpec {
|
|||
shaSeed = BinaryData("05" * 32),
|
||||
isFunder = true,
|
||||
globalFeatures = "foo".getBytes(),
|
||||
localFeatures = "bar".getBytes(),
|
||||
maxFeerateMismatch = 5.0)
|
||||
localFeatures = "bar".getBytes())
|
||||
|
||||
val remoteParams = RemoteParams(
|
||||
nodeId = randomKey.publicKey,
|
||||
|
|
Loading…
Add table
Reference in a new issue