-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ const ( | |
// DefaultLtcChannelConstraints is the default set of channel constraints that | ||
// are meant to be used when initially funding a Litecoin channel. | ||
var DefaultLtcChannelConstraints = channeldb.ChannelConstraints{ | ||
DustLimit: DefaultLitecoinDustLimit, | ||
DustLimit: uint64(DefaultLitecoinDustLimit), | ||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2, | ||
} | ||
|
||
|
@@ -240,7 +240,7 @@ func GenDefaultBtcConstraints() channeldb.ChannelConstraints { | |
dustLimit := lnwallet.DustLimitForSize(input.UnknownWitnessSize) | ||
|
||
return channeldb.ChannelConstraints{ | ||
DustLimit: dustLimit, | ||
DustLimit: uint64(dustLimit), | ||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2, | ||
} | ||
} | ||
|
@@ -264,9 +264,11 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) { | |
switch cfg.PrimaryChain() { | ||
case BitcoinChain: | ||
cc.RoutingPolicy = htlcswitch.ForwardingPolicy{ | ||
MinHTLCOut: uint64( cfg.Bitcoin.MinHTLCOut), | ||
BaseFee: cfg.Bitcoin.BaseFee, | ||
FeeRate: cfg.Bitcoin.FeeRate, | ||
Cfg: htlcswitch.ForwardingPolicyCfg{ | ||
MinHTLCOut: cfg.Bitcoin.MinHTLCOut, | ||
BaseFee: cfg.Bitcoin.BaseFee, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
neocarmack
Member
|
||
FeeRate: cfg.Bitcoin.FeeRate, | ||
}, | ||
TimeLockDelta: cfg.Bitcoin.TimeLockDelta, | ||
} | ||
cc.MinHtlcIn = cfg.Bitcoin.MinHTLCIn | ||
|
@@ -276,9 +278,11 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) { | |
) | ||
case LitecoinChain: | ||
cc.RoutingPolicy = htlcswitch.ForwardingPolicy{ | ||
MinHTLCOut: uint64(cfg.Litecoin.MinHTLCOut), | ||
BaseFee: cfg.Litecoin.BaseFee, | ||
FeeRate: cfg.Litecoin.FeeRate, | ||
Cfg: htlcswitch.ForwardingPolicyCfg{ | ||
MinHTLCOut: cfg.Litecoin.MinHTLCOut, | ||
BaseFee: cfg.Litecoin.BaseFee, | ||
FeeRate: cfg.Litecoin.FeeRate, | ||
}, | ||
TimeLockDelta: cfg.Litecoin.TimeLockDelta, | ||
} | ||
cc.MinHtlcIn = cfg.Litecoin.MinHTLCIn | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ import ( | |
"errors" | ||
|
||
"github.com/btcsuite/btcd/btcec" | ||
"github.com/btcsuite/btcutil" | ||
"github.com/lightningnetwork/lnd/lnwire" | ||
) | ||
|
||
|
@@ -46,18 +45,21 @@ type ChannelAcceptResponse struct { | |
|
||
// Reserve is the amount that require the remote peer hold in reserve | ||
// on the channel. | ||
Reserve btcutil.Amount | ||
This comment has been minimized.
Sorry, something went wrong.
neocarmack
Member
|
||
//Reserve btcutil.Amount | ||
Reserve uint64 | ||
|
||
// InFlightTotal is the maximum amount that we allow the remote peer to | ||
// hold in outstanding htlcs. | ||
InFlightTotal lnwire.MilliSatoshi | ||
//InFlightTotal lnwire.MilliSatoshi | ||
InFlightTotal uint64 | ||
|
||
// HtlcLimit is the maximum number of htlcs that we allow the remote | ||
// peer to offer us. | ||
HtlcLimit uint16 | ||
|
||
// MinHtlcIn is the minimum incoming htlc value allowed on the channel. | ||
MinHtlcIn lnwire.MilliSatoshi | ||
//MinHtlcIn lnwire.MilliSatoshi | ||
MinHtlcIn uint64 | ||
|
||
// MinAcceptDepth is the minimum depth that the initiator of the | ||
// channel should wait before considering the channel open. | ||
|
@@ -71,8 +73,8 @@ type ChannelAcceptResponse struct { | |
// error. | ||
func NewChannelAcceptResponse(accept bool, acceptErr error, | ||
upfrontShutdown lnwire.DeliveryAddress, csvDelay, htlcLimit, | ||
minDepth uint16, reserve btcutil.Amount, inFlight, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
minHtlcIn lnwire.MilliSatoshi) *ChannelAcceptResponse { | ||
minDepth uint16, reserve uint64, inFlight, | ||
minHtlcIn uint64) *ChannelAcceptResponse { | ||
|
||
resp := &ChannelAcceptResponse{ | ||
UpfrontShutdown: upfrontShutdown, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,14 +312,21 @@ func (c ChannelType) HasLeaseExpiration() bool { | |
return c&LeaseExpirationBit == LeaseExpirationBit | ||
} | ||
|
||
// ChannelConstraints represents a set of constraints meant to allow a node to | ||
// limit their exposure, enact flow control and ensure that all HTLCs are | ||
// economically relevant. This struct will be mirrored for both sides of the | ||
// channel, as each side will enforce various constraints that MUST be adhered | ||
// to for the life time of the channel. The parameters for each of these | ||
// constraints are static for the duration of the channel, meaning the channel | ||
// must be torn down for them to change. | ||
type ChannelConstraints struct { | ||
func (ccc *ChannelConstraints)LoadCfg(assetId uint32){ | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
neocarmack
Member
|
||
// get usdt value,btc/usdt ~ 30000 | ||
ccc.DustLimit=30* uint64(ccc.Cfg.DustLimit) | ||
ccc.ChanReserve=30* uint64(ccc.Cfg.ChanReserve) | ||
if assetId==omnicore.BtcAssetId{ | ||
ccc.DustLimit=uint64(ccc.Cfg.DustLimit) | ||
ccc.ChanReserve=uint64(ccc.Cfg.ChanReserve) | ||
} | ||
ccc.MaxPendingAmount=lnwire.MstatCfgToI64(assetId,ccc.Cfg.MaxPendingAmount) | ||
ccc.MinHTLC=lnwire.MstatCfgToI64(assetId,ccc.Cfg.MinHTLC) | ||
} | ||
|
||
type ChannelConstraintsCfg struct { | ||
|
||
// DustLimit is the threshold (in satoshis) below which any outputs | ||
// should be trimmed. When an output is trimmed, it isn't materialized | ||
// as an actual output, but is instead burned to miner's fees. | ||
|
@@ -343,6 +350,33 @@ type ChannelConstraints struct { | |
// tandem with the dust limit allows a node to regulate the | ||
// smallest HTLC that it deems economically relevant. | ||
MinHTLC lnwire.MilliSatoshi | ||
} | ||
type ChannelConstraints struct { | ||
Cfg ChannelConstraintsCfg | ||
|
||
// DustLimit is the threshold (in satoshis) below which any outputs | ||
// should be trimmed. When an output is trimmed, it isn't materialized | ||
// as an actual output, but is instead burned to miner's fees. | ||
DustLimit uint64 | ||
|
||
// ChanReserve is an absolute reservation on the channel for the | ||
// owner of this set of constraints. This means that the current | ||
// settled balance for this node CANNOT dip below the reservation | ||
// amount. This acts as a defense against costless attacks when | ||
// either side no longer has any skin in the game. | ||
ChanReserve uint64 | ||
|
||
// MaxPendingAmount is the maximum pending HTLC value that the | ||
// owner of these constraints can offer the remote node at a | ||
// particular time. | ||
MaxPendingAmount uint64 | ||
|
||
// MinHTLC is the minimum HTLC value that the owner of these | ||
// constraints can offer the remote node. If any HTLCs below this | ||
// amount are offered, then the HTLC will be rejected. This, in | ||
// tandem with the dust limit allows a node to regulate the | ||
// smallest HTLC that it deems economically relevant. | ||
MinHTLC uint64 | ||
|
||
// MaxAcceptedHtlcs is the maximum number of HTLCs that the owner of | ||
// this set of constraints can offer the remote node. This allows each | ||
|
@@ -594,17 +628,17 @@ func (c ChannelStatus) String() string { | |
return statusStr | ||
} | ||
func (ch *OpenChannel) GetMsgCapForHtlc() uint64{ | ||
if ch.AssetID==1{ | ||
if ch.AssetID==omnicore.BtcAssetId{ | ||
return uint64(ch.BtcCapacity)*1000 | ||
}else if ch.AssetID>1 { | ||
return uint64(ch.AssetCapacity) | ||
} | ||
return 0 | ||
} | ||
func (ch *OpenChannel) GetMsgCap() uint64{ | ||
if ch.AssetID==1{ | ||
if ch.AssetID==omnicore.BtcAssetId{ | ||
return uint64(ch.BtcCapacity) | ||
}else if ch.AssetID>1{ | ||
}else if ch.AssetID>omnicore.BtcAssetId{ | ||
return uint64(ch.AssetCapacity) | ||
} | ||
return 0 | ||
|
//Ben, Wu: for assets, the basefee is not required.