mirror of
https://github.com/muun/recovery.git
synced 2025-11-10 22:10:14 -05:00
Release v0.3.0
This commit is contained in:
57
vendor/github.com/muun/libwallet/fees.go
generated
vendored
Normal file
57
vendor/github.com/muun/libwallet/fees.go
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
package libwallet
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/muun/libwallet/fees"
|
||||
)
|
||||
|
||||
type BestRouteFees struct {
|
||||
MaxCapacity int64
|
||||
FeeProportionalMillionth int64
|
||||
FeeBase int64
|
||||
}
|
||||
|
||||
type BestRouteFeesList struct {
|
||||
list []fees.BestRouteFees
|
||||
}
|
||||
|
||||
func (l *BestRouteFeesList) Add(f *BestRouteFees) {
|
||||
l.list = append(l.list, fees.BestRouteFees{
|
||||
MaxCapacity: btcutil.Amount(f.MaxCapacity),
|
||||
FeeProportionalMillionth: uint64(f.FeeProportionalMillionth),
|
||||
FeeBase: btcutil.Amount(f.FeeBase),
|
||||
})
|
||||
}
|
||||
|
||||
type FundingOutputPolicies struct {
|
||||
MaximumDebt int64
|
||||
PotentialCollect int64
|
||||
MaxAmountFor0Conf int64
|
||||
}
|
||||
|
||||
type SwapFees struct {
|
||||
RoutingFee int64
|
||||
SweepFee int64
|
||||
DebtType string
|
||||
DebtAmount int64
|
||||
ConfirmationsNeeded int64
|
||||
}
|
||||
|
||||
func ComputeSwapFees(amount int64, bestRouteFees *BestRouteFeesList, policies *FundingOutputPolicies) *SwapFees {
|
||||
swapFees := fees.ComputeSwapFees(
|
||||
btcutil.Amount(amount),
|
||||
bestRouteFees.list,
|
||||
&fees.FundingOutputPolicies{
|
||||
MaximumDebt: btcutil.Amount(policies.MaximumDebt),
|
||||
PotentialCollect: btcutil.Amount(policies.PotentialCollect),
|
||||
MaxAmountFor0Conf: btcutil.Amount(policies.MaxAmountFor0Conf),
|
||||
},
|
||||
)
|
||||
return &SwapFees{
|
||||
RoutingFee: int64(swapFees.RoutingFee),
|
||||
SweepFee: int64(swapFees.SweepFee),
|
||||
DebtType: string(swapFees.DebtType),
|
||||
DebtAmount: int64(swapFees.DebtAmount),
|
||||
ConfirmationsNeeded: int64(swapFees.ConfirmationsNeeded),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user