mirror of
https://github.com/muun/recovery.git
synced 2025-11-12 14:51:37 -05:00
Update project structure and build process
This commit is contained in:
36
libwallet/newop/context.go
Normal file
36
libwallet/newop/context.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package newop
|
||||
|
||||
import "github.com/muun/libwallet/operation"
|
||||
|
||||
// PaymentContext stores data required to analyze and validate an operation
|
||||
type PaymentContext struct {
|
||||
FeeWindow *FeeWindow
|
||||
NextTransactionSize *NextTransactionSize
|
||||
ExchangeRateWindow *ExchangeRateWindow
|
||||
PrimaryCurrency string
|
||||
MinFeeRateInSatsPerVByte float64
|
||||
SubmarineSwap *SubmarineSwap
|
||||
}
|
||||
|
||||
func (c *PaymentContext) totalBalance() int64 {
|
||||
return c.NextTransactionSize.toInternalType().TotalBalance()
|
||||
}
|
||||
|
||||
func (c *PaymentContext) toBitcoinAmount(sats int64, inputCurrency string) *BitcoinAmount {
|
||||
amount := c.ExchangeRateWindow.convert(
|
||||
NewMonetaryAmountFromSatoshis(sats),
|
||||
inputCurrency,
|
||||
)
|
||||
return &BitcoinAmount{
|
||||
InSat: sats,
|
||||
InInputCurrency: amount,
|
||||
InPrimaryCurrency: c.ExchangeRateWindow.convert(amount, c.PrimaryCurrency),
|
||||
}
|
||||
}
|
||||
|
||||
func newPaymentAnalyzer(context *PaymentContext) *operation.PaymentAnalyzer {
|
||||
return operation.NewPaymentAnalyzer(
|
||||
context.FeeWindow.toInternalType(),
|
||||
context.NextTransactionSize.toInternalType(),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user