diff --git a/CHANGELOG.md b/CHANGELOG.md index 939441fc..599e571f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # edge-currency-plugins +## Unreleased + +- changed: Re-enabled maximum fee rate checks from AltcoinJS. +- added: Configurable `maximumFeeRate` field for currency info's `EngineInfo` to change from default 5000 sats-per-vbyte + ## v2.3.0 (2023-09-29) - removed: BSV from BCH's split options diff --git a/src/common/fees/calcMinerFeePerByte.ts b/src/common/fees/calcMinerFeePerByte.ts index 562ed6a5..a7a9ad7d 100644 --- a/src/common/fees/calcMinerFeePerByte.ts +++ b/src/common/fees/calcMinerFeePerByte.ts @@ -1,21 +1,21 @@ import { add, div, gte, lte, mul, round, sub } from 'biggystring' import { EdgeSpendInfo } from 'edge-core-js/types' -import { SimpleFeeSettings } from '../plugin/types' +import { FeeInfo } from '../plugin/types' type NetworkFeeOption = EdgeSpendInfo['networkFeeOption'] /** * Calculate the sat/byte mining fee given an amount to spend and a SimpleFeeSettings object * @param nativeAmount - * @param fees + * @param feeInfo * @param networkFeeOption * @param customNetworkFee * @returns {string} */ export const calcMinerFeePerByte = ( nativeAmount: string, - fees: SimpleFeeSettings, + feeInfo: FeeInfo, networkFeeOption?: NetworkFeeOption, customNetworkFee?: string ): string => { @@ -26,8 +26,8 @@ export const calcMinerFeePerByte = ( standardFeeHighFudgeFactor = '1', standardFeeLowAmount, standardFeeLowFudgeFactor = '1' - } = fees - let { highFee, lowFee, standardFeeHigh, standardFeeLow } = fees + } = feeInfo + let { highFee, lowFee, standardFeeHigh, standardFeeLow } = feeInfo highFee = round(mul(highFee, highFeeFudgeFactor), 0) lowFee = round(mul(lowFee, lowFeeFudgeFactor), 0) diff --git a/src/common/fees/makeFees.ts b/src/common/fees/makeFees.ts index de688666..62d8ff19 100644 --- a/src/common/fees/makeFees.ts +++ b/src/common/fees/makeFees.ts @@ -1,5 +1,5 @@ import * as bs from 'biggystring' -import { asMaybe } from 'cleaners' +import { asMaybe, Cleaner } from 'cleaners' import { Disklet } from 'disklet' import { EdgeIo, @@ -11,13 +11,8 @@ import { makeMemlet, Memlet } from 'memlet' import { removeUndefined } from '../../util/filterUndefined' import { FEES_PATH, INFO_SERVER_URI } from '../constants' -import { - asSimpleFeeSettings, - PluginInfo, - SimpleFeeSettings -} from '../plugin/types' +import { asFeeInfo, FeeInfo, PluginInfo } from '../plugin/types' import { calcMinerFeePerByte } from './calcMinerFeePerByte' -import { processInfoServerFees } from './processInfoServerFees' import { processMempoolSpaceFees } from './processMempoolSpaceFees' interface MakeFeesConfig extends Common { @@ -35,7 +30,7 @@ export interface Fees { stop: () => void clearCache: () => Promise getRate: (edgeSpendInfo: EdgeSpendInfo) => Promise - fees: SimpleFeeSettings + feeInfo: FeeInfo } export const makeFees = async (config: MakeFeesConfig): Promise => { @@ -43,9 +38,9 @@ export const makeFees = async (config: MakeFeesConfig): Promise => { const { currencyInfo, engineInfo } = pluginInfo const memlet = makeMemlet(disklet) - const fees: SimpleFeeSettings = await fetchCachedFees( + const feeInfo: FeeInfo = await fetchCachedFees( memlet, - engineInfo.simpleFeeSettings + engineInfo.defaultFeeInfo ) // The last time the fees were updated let timestamp = 0 @@ -59,10 +54,10 @@ export const makeFees = async (config: MakeFeesConfig): Promise => { mempoolSpaceFeeInfoServer: engineInfo.mempoolSpaceFeeInfoServer }) const cleanedVendorFees = removeUndefined(vendorFees ?? {}) - Object.assign(fees, cleanedVendorFees) + Object.assign(feeInfo, cleanedVendorFees) timestamp = Date.now() - await cacheFees(memlet, fees) + await cacheFees(memlet, feeInfo) } return { @@ -70,9 +65,9 @@ export const makeFees = async (config: MakeFeesConfig): Promise => { const edgeFees = await fetchFees({ ...common, uri: `${INFO_SERVER_URI}/v1/networkFees/${currencyInfo.pluginId}`, - processor: processInfoServerFees + cleaner: asMaybe(asFeeInfo, null) }) - Object.assign(fees, edgeFees) + Object.assign(feeInfo, edgeFees) await updateVendorFees() vendorIntervalId = setInterval( // eslint-disable-next-line @typescript-eslint/no-misused-promises @@ -109,32 +104,30 @@ export const makeFees = async (config: MakeFeesConfig): Promise => { const rate = calcMinerFeePerByte( sumSpendTargets(spendTargets), - fees, + feeInfo, networkFeeOption, customNetworkFee[customFeeTemplate.key] ) return rate }, - get fees(): SimpleFeeSettings { - return fees + get feeInfo(): FeeInfo { + return feeInfo } } } const fetchCachedFees = async ( memlet: Memlet, - fallback: SimpleFeeSettings -): Promise => { + fallback: FeeInfo +): Promise => { const data = await memlet.getJson(FEES_PATH).catch(() => undefined) - const feeSettings = asMaybe(asSimpleFeeSettings, fallback)(data) + const feeSettings = asMaybe(asFeeInfo, fallback)(data) return feeSettings } -const cacheFees = async ( - memlet: Memlet, - fees: SimpleFeeSettings -): Promise => await memlet.setJson(FEES_PATH, fees) +const cacheFees = async (memlet: Memlet, feeInfo: FeeInfo): Promise => + await memlet.setJson(FEES_PATH, feeInfo) const sumSpendTargets = (spendTargets: EdgeSpendTarget[]): string => spendTargets.reduce((amount, { nativeAmount }) => { @@ -145,17 +138,17 @@ const sumSpendTargets = (spendTargets: EdgeSpendTarget[]): string => interface FetchFeesArgs extends Common { uri: string - processor: (fees: unknown) => T + cleaner: Cleaner } const fetchFees = async (args: FetchFeesArgs): Promise => { - const { uri, processor, io, log } = args + const { uri, cleaner, io, log } = args try { const response = await io.fetch(uri) if (!response.ok) throw new Error(`Error fetching fees from ${uri}`) const fees = await response.json() - return processor(fees) + return cleaner(fees) } catch (err) { log(err.message) return null @@ -168,12 +161,12 @@ interface FetchFeesFromVendorArgs extends Common { const fetchFeesFromVendor = async ( args: FetchFeesFromVendorArgs -): Promise> => { +): Promise> => { if (args.mempoolSpaceFeeInfoServer != null) { const mempoolFees = await fetchFees({ ...args, uri: args.mempoolSpaceFeeInfoServer, - processor: processMempoolSpaceFees + cleaner: processMempoolSpaceFees }) if (mempoolFees != null) { return mempoolFees diff --git a/src/common/fees/processInfoServerFees.ts b/src/common/fees/processInfoServerFees.ts deleted file mode 100644 index 27f75655..00000000 --- a/src/common/fees/processInfoServerFees.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { asSimpleFeeSettings, SimpleFeeSettings } from '../plugin/types' - -/** - * Processes the fee object from Edge Info Server - * @param fees - * @returns {SimpleFeeSettings} - */ -export const processInfoServerFees = ( - fees: unknown -): SimpleFeeSettings | null => { - try { - return asSimpleFeeSettings(fees) - } catch { - return null - } -} diff --git a/src/common/plugin/types.ts b/src/common/plugin/types.ts index 62607fae..805e8681 100644 --- a/src/common/plugin/types.ts +++ b/src/common/plugin/types.ts @@ -4,6 +4,7 @@ import { asMaybe, asNumber, asObject, + asOptional, asString, asValue, Cleaner @@ -61,7 +62,7 @@ export interface EngineInfo { defaultFee: number feeUpdateInterval: number mempoolSpaceFeeInfoServer?: string - simpleFeeSettings: SimpleFeeSettings + defaultFeeInfo: FeeInfo scriptTemplates?: ScriptTemplates // Codec Cleaners asBlockbookAddress?: Cleaner @@ -151,8 +152,16 @@ export const asFeeRates = asObject({ highFee: asString }) -export type SimpleFeeSettings = ReturnType -export const asSimpleFeeSettings = asObject({ +export type FeeInfo = FeeRates & { + lowFeeFudgeFactor?: string + standardFeeLowFudgeFactor?: string + standardFeeHighFudgeFactor?: string + highFeeFudgeFactor?: string + standardFeeLowAmount: string + standardFeeHighAmount: string + maximumFeeRate?: string +} +export const asFeeInfo = asObject({ ...asFeeRates.shape, lowFeeFudgeFactor: asMaybe(asString), @@ -160,8 +169,12 @@ export const asSimpleFeeSettings = asObject({ standardFeeHighFudgeFactor: asMaybe(asString), highFeeFudgeFactor: asMaybe(asString), + // The amount of satoshis which will be charged the standardFeeLow standardFeeLowAmount: asString, - standardFeeHighAmount: asString + // The amount of satoshis which will be charged the standardFeeHigh + standardFeeHighAmount: asString, + // A safe-guard for any potential software bugs: + maximumFeeRate: asOptional(asString) }) export interface EngineConfig { diff --git a/src/common/plugin/util/maximumFeeRateCalculator.ts b/src/common/plugin/util/maximumFeeRateCalculator.ts new file mode 100644 index 00000000..9cc4fe60 --- /dev/null +++ b/src/common/plugin/util/maximumFeeRateCalculator.ts @@ -0,0 +1,23 @@ +import { div, mul, round } from 'biggystring' +import { EdgeCurrencyInfo } from 'edge-core-js/types' + +/** + * Calculates a maximum fee rate of 1 USD per vByte given a USD exchange rate + * (usdPrice). + */ +export const maximumFeeRateCalculator = ( + currencyInfo: EdgeCurrencyInfo, + usdPrice: number +): string | undefined => { + const { currencyCode, denominations } = currencyInfo + const primaryDenomination = denominations.find( + denom => denom.name === currencyCode + ) + if (primaryDenomination == null) + throw new Error(`Missing primary currency denomination for ${currencyCode}`) + + return round( + mul(div('1', String(usdPrice), 16), primaryDenomination.multiplier), + 0 + ) +} diff --git a/src/common/utxobased/engine/makeUtxoEngine.ts b/src/common/utxobased/engine/makeUtxoEngine.ts index 94ea5cfb..671044bf 100644 --- a/src/common/utxobased/engine/makeUtxoEngine.ts +++ b/src/common/utxobased/engine/makeUtxoEngine.ts @@ -625,9 +625,10 @@ export async function makeUtxoEngine( } })() const signedTx = await signTx({ - psbtBase64: psbt.base64, coin: coinInfo.name, - privateKeyEncodings: privateKeyEncodings + feeInfo: fees.feeInfo, + privateKeyEncodings: privateKeyEncodings, + psbtBase64: psbt.base64 }) transaction.txid = signedTx.id transaction.signedTx = signedTx.hex diff --git a/src/common/utxobased/info/badcoin.ts b/src/common/utxobased/info/badcoin.ts index b2883d7d..a7b4034f 100644 --- a/src/common/utxobased/info/badcoin.ts +++ b/src/common/utxobased/info/badcoin.ts @@ -43,7 +43,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 500000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, diff --git a/src/common/utxobased/info/bitcoin.ts b/src/common/utxobased/info/bitcoin.ts index 9e4aa5bd..9a9ef6c6 100644 --- a/src/common/utxobased/info/bitcoin.ts +++ b/src/common/utxobased/info/bitcoin.ts @@ -2,6 +2,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { IMAGE_SERVER_URL } from '../../constants' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -59,7 +60,7 @@ const engineInfo: EngineInfo = { defaultFee: 1000, feeUpdateInterval: 60000, mempoolSpaceFeeInfoServer: 'https://mempool.space/api/v1/fees/recommended', - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -70,7 +71,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '50', standardFeeHigh: '100', standardFeeLowAmount: '173200', - standardFeeHighAmount: '8670000' + standardFeeHighAmount: '8670000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 27460.65) } } diff --git a/src/common/utxobased/info/bitcoincash.ts b/src/common/utxobased/info/bitcoincash.ts index 2492c15a..7bfe1bbc 100644 --- a/src/common/utxobased/info/bitcoincash.ts +++ b/src/common/utxobased/info/bitcoincash.ts @@ -4,6 +4,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { IMAGE_SERVER_URL } from '../../constants' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' import { scriptTemplates } from './scriptTemplates/bitcoincashScriptTemplates' @@ -60,7 +61,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 10000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -71,7 +72,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '5', standardFeeHigh: '10', standardFeeLowAmount: '1000000', - standardFeeHighAmount: '65000000' + standardFeeHighAmount: '65000000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 212.86) }, scriptTemplates, asBlockbookAddress: asCodec( diff --git a/src/common/utxobased/info/bitcoincashtestnet.ts b/src/common/utxobased/info/bitcoincashtestnet.ts index 41035f94..dface633 100644 --- a/src/common/utxobased/info/bitcoincashtestnet.ts +++ b/src/common/utxobased/info/bitcoincashtestnet.ts @@ -45,7 +45,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 10000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, diff --git a/src/common/utxobased/info/bitcoingold.ts b/src/common/utxobased/info/bitcoingold.ts index 63f7203c..29997c96 100644 --- a/src/common/utxobased/info/bitcoingold.ts +++ b/src/common/utxobased/info/bitcoingold.ts @@ -2,6 +2,7 @@ import { Psbt } from 'altcoin-js' import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -51,7 +52,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -62,7 +63,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '15', standardFeeHigh: '140', standardFeeLowAmount: '17320', - standardFeeHighAmount: '86700000' + standardFeeHighAmount: '86700000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 12.62) } } diff --git a/src/common/utxobased/info/bitcoingoldtestnet.ts b/src/common/utxobased/info/bitcoingoldtestnet.ts index 57892806..d7025ed5 100644 --- a/src/common/utxobased/info/bitcoingoldtestnet.ts +++ b/src/common/utxobased/info/bitcoingoldtestnet.ts @@ -37,7 +37,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, diff --git a/src/common/utxobased/info/bitcoinsv.ts b/src/common/utxobased/info/bitcoinsv.ts index f096af9c..2dccb646 100644 --- a/src/common/utxobased/info/bitcoinsv.ts +++ b/src/common/utxobased/info/bitcoinsv.ts @@ -4,6 +4,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { IMAGE_SERVER_URL } from '../../constants' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { addressToScriptPubkey, AddressTypeEnum, @@ -57,7 +58,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 10000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -68,7 +69,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '5', standardFeeHigh: '10', standardFeeLowAmount: '1000000', - standardFeeHighAmount: '65000000' + standardFeeHighAmount: '65000000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 33.61) }, /* This is to support cashaddr and 1-addresses coming from the network. diff --git a/src/common/utxobased/info/bitcointestnet.ts b/src/common/utxobased/info/bitcointestnet.ts index a8c0b9ca..14c79e8f 100644 --- a/src/common/utxobased/info/bitcointestnet.ts +++ b/src/common/utxobased/info/bitcointestnet.ts @@ -53,7 +53,7 @@ export const engineInfo: EngineInfo = { defaultFee: 1000, feeUpdateInterval: 60000, mempoolSpaceFeeInfoServer: 'https://mempool.space/api/v1/fees/recommended', - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, diff --git a/src/common/utxobased/info/dash.ts b/src/common/utxobased/info/dash.ts index 8fd98c7b..b369d256 100644 --- a/src/common/utxobased/info/dash.ts +++ b/src/common/utxobased/info/dash.ts @@ -2,6 +2,7 @@ import { asBoolean, asMaybe, asObject, asOptional } from 'cleaners' import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { IProcessorTransaction } from '../db/types' import { memoInfo } from './commonInfo' @@ -52,7 +53,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 10000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -63,7 +64,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '150', standardFeeHigh: '200', standardFeeLowAmount: '20000000', - standardFeeHighAmount: '981000000' + standardFeeHighAmount: '981000000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 25.8) }, txSpecificHandling: ( tx: IProcessorTransaction, diff --git a/src/common/utxobased/info/digibyte.ts b/src/common/utxobased/info/digibyte.ts index 301bdeba..d1873ce8 100644 --- a/src/common/utxobased/info/digibyte.ts +++ b/src/common/utxobased/info/digibyte.ts @@ -1,6 +1,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -44,7 +45,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -55,7 +56,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '50', standardFeeHigh: '100', standardFeeLowAmount: '173200', - standardFeeHighAmount: '8670000' + standardFeeHighAmount: '8670000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.006176) } } diff --git a/src/common/utxobased/info/dogecoin.ts b/src/common/utxobased/info/dogecoin.ts index 8ff07293..6550afb9 100644 --- a/src/common/utxobased/info/dogecoin.ts +++ b/src/common/utxobased/info/dogecoin.ts @@ -1,6 +1,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' import { makeDogeUtxoPicker } from './utxoPickers/dogeUtxoPicker' @@ -48,7 +49,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 10000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -59,7 +60,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '526316', standardFeeHigh: '526316', standardFeeLowAmount: '2000000000', - standardFeeHighAmount: '98100000000' + standardFeeHighAmount: '98100000000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.05938) } } diff --git a/src/common/utxobased/info/eboost.ts b/src/common/utxobased/info/eboost.ts index b23ff2b6..ff3ca093 100644 --- a/src/common/utxobased/info/eboost.ts +++ b/src/common/utxobased/info/eboost.ts @@ -1,6 +1,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -43,7 +44,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 500000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -54,7 +55,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '150', standardFeeHigh: '200', standardFeeLowAmount: '20000000', - standardFeeHighAmount: '981000000' + standardFeeHighAmount: '981000000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.0033) } } diff --git a/src/common/utxobased/info/feathercoin.ts b/src/common/utxobased/info/feathercoin.ts index 4a9f5489..9494f716 100644 --- a/src/common/utxobased/info/feathercoin.ts +++ b/src/common/utxobased/info/feathercoin.ts @@ -2,6 +2,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { IMAGE_SERVER_URL } from '../../constants' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' export const currencyInfo: EdgeCurrencyInfo = { @@ -48,7 +49,7 @@ export const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -59,7 +60,8 @@ export const engineInfo: EngineInfo = { standardFeeLow: '600', standardFeeHigh: '800', standardFeeLowAmount: '2000000000', - standardFeeHighAmount: '98100000000' + standardFeeHighAmount: '98100000000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.002275) } } diff --git a/src/common/utxobased/info/groestlcoin.ts b/src/common/utxobased/info/groestlcoin.ts index 23aadcce..93a99353 100644 --- a/src/common/utxobased/info/groestlcoin.ts +++ b/src/common/utxobased/info/groestlcoin.ts @@ -5,6 +5,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import * as wifgrs from 'wifgrs' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -49,7 +50,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 100000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -60,7 +61,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '50', standardFeeHigh: '100', standardFeeLowAmount: '173200', - standardFeeHighAmount: '8670000' + standardFeeHighAmount: '8670000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.4705) } } diff --git a/src/common/utxobased/info/litecoin.ts b/src/common/utxobased/info/litecoin.ts index d30259ef..c49d376b 100644 --- a/src/common/utxobased/info/litecoin.ts +++ b/src/common/utxobased/info/litecoin.ts @@ -2,6 +2,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { IMAGE_SERVER_URL } from '../../constants' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' export const currencyInfo: EdgeCurrencyInfo = { @@ -55,7 +56,7 @@ export const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 50000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -66,7 +67,8 @@ export const engineInfo: EngineInfo = { standardFeeLow: '150', standardFeeHigh: '200', standardFeeLowAmount: '20000000', - standardFeeHighAmount: '981000000' + standardFeeHighAmount: '981000000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 63.64) } } diff --git a/src/common/utxobased/info/qtum.ts b/src/common/utxobased/info/qtum.ts index 19097a3c..e76120ae 100644 --- a/src/common/utxobased/info/qtum.ts +++ b/src/common/utxobased/info/qtum.ts @@ -1,6 +1,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -40,7 +41,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -51,7 +52,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '450', standardFeeHigh: '700', standardFeeLowAmount: '20000000', - standardFeeHighAmount: '981000000' + standardFeeHighAmount: '981000000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 2.13) } } diff --git a/src/common/utxobased/info/ravencoin.ts b/src/common/utxobased/info/ravencoin.ts index e048c5f8..4f5bf020 100644 --- a/src/common/utxobased/info/ravencoin.ts +++ b/src/common/utxobased/info/ravencoin.ts @@ -1,6 +1,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -40,7 +41,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -51,7 +52,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '50', standardFeeHigh: '100', standardFeeLowAmount: '173200', - standardFeeHighAmount: '8670000' + standardFeeHighAmount: '8670000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.01419) } } diff --git a/src/common/utxobased/info/smartcash.ts b/src/common/utxobased/info/smartcash.ts index 4c137442..b3579ed5 100644 --- a/src/common/utxobased/info/smartcash.ts +++ b/src/common/utxobased/info/smartcash.ts @@ -4,6 +4,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import * as wifsmart from 'wif-smart' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -46,7 +47,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 100000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -57,7 +58,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '500', standardFeeHigh: '1000', standardFeeLowAmount: '1732000', - standardFeeHighAmount: '86700000' + standardFeeHighAmount: '86700000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.0002171) } } diff --git a/src/common/utxobased/info/ufo.ts b/src/common/utxobased/info/ufo.ts index e7ad47f5..36e4f74c 100644 --- a/src/common/utxobased/info/ufo.ts +++ b/src/common/utxobased/info/ufo.ts @@ -1,6 +1,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -43,7 +44,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 50000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -54,7 +55,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '1100', standardFeeHigh: '2000', standardFeeLowAmount: '51282051282051', - standardFeeHighAmount: '5128205128205100' + standardFeeHighAmount: '5128205128205100', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.000137) } } diff --git a/src/common/utxobased/info/vertcoin.ts b/src/common/utxobased/info/vertcoin.ts index b86803e1..7715d509 100644 --- a/src/common/utxobased/info/vertcoin.ts +++ b/src/common/utxobased/info/vertcoin.ts @@ -1,6 +1,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' const currencyInfo: EdgeCurrencyInfo = { @@ -50,7 +51,7 @@ const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -61,7 +62,8 @@ const engineInfo: EngineInfo = { standardFeeLow: '50', standardFeeHigh: '100', standardFeeLowAmount: '173200', - standardFeeHighAmount: '8670000' + standardFeeHighAmount: '8670000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 0.04662) } } diff --git a/src/common/utxobased/info/zcoin.ts b/src/common/utxobased/info/zcoin.ts index d5167204..637a2fe9 100644 --- a/src/common/utxobased/info/zcoin.ts +++ b/src/common/utxobased/info/zcoin.ts @@ -2,6 +2,7 @@ import { EdgeCurrencyInfo } from 'edge-core-js/types' import { IMAGE_SERVER_URL } from '../../constants' import { CoinInfo, EngineInfo, PluginInfo } from '../../plugin/types' +import { maximumFeeRateCalculator } from '../../plugin/util/maximumFeeRateCalculator' import { memoInfo } from './commonInfo' export const currencyInfo: EdgeCurrencyInfo = { @@ -49,7 +50,7 @@ export const engineInfo: EngineInfo = { gapLimit: 10, defaultFee: 1000, feeUpdateInterval: 60000, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -60,7 +61,8 @@ export const engineInfo: EngineInfo = { standardFeeLow: '50', standardFeeHigh: '100', standardFeeLowAmount: '173200', - standardFeeHighAmount: '8670000' + standardFeeHighAmount: '8670000', + maximumFeeRate: maximumFeeRateCalculator(currencyInfo, 1.39) } } diff --git a/src/common/utxobased/keymanager/keymanager.ts b/src/common/utxobased/keymanager/keymanager.ts index 6e3e42c9..6775b349 100644 --- a/src/common/utxobased/keymanager/keymanager.ts +++ b/src/common/utxobased/keymanager/keymanager.ts @@ -17,7 +17,7 @@ import { EdgeLog, EdgeMemo, InsufficientFundsError } from 'edge-core-js/types' import { indexAtProtected } from '../../../util/indexAtProtected' import { undefinedIfEmptyString } from '../../../util/undefinedIfEmptyString' -import { ChangePath, CoinInfo, CoinPrefixes } from '../../plugin/types' +import { ChangePath, CoinInfo, CoinPrefixes, FeeInfo } from '../../plugin/types' import { IUTXO } from '../db/types' import { ScriptTemplate, ScriptTemplates } from '../info/scriptTemplates/types' import { sortInputs, sortOutputs } from './bip69' @@ -234,9 +234,10 @@ interface MakeTxReturn extends Required { } export interface SignTxArgs { - privateKeyEncodings: PrivateKeyEncoding[] - psbtBase64: string coin: string + feeInfo: FeeInfo + psbtBase64: string + privateKeyEncodings: PrivateKeyEncoding[] } interface SignTxReturn { @@ -1084,7 +1085,10 @@ export function makeTx(args: MakeTxArgs): MakeTxReturn { } export async function signTx(args: SignTxArgs): Promise { - const psbt = Psbt.fromBase64(args.psbtBase64) + const { maximumFeeRate } = args.feeInfo + const opts = + maximumFeeRate != null ? { maximumFeeRate: parseInt(maximumFeeRate) } : {} + const psbt = Psbt.fromBase64(args.psbtBase64, opts) const coin = getCoinFromString(args.coin) const validator = ( @@ -1107,7 +1111,7 @@ export async function signTx(args: SignTxArgs): Promise { psbt.validateSignaturesOfInput(i, validator) psbt.finalizeInput(i) } - const tx = psbt.extractTransaction(true) + const tx = psbt.extractTransaction() return { id: tx.getId(coin.txHashFunction), hex: tx.toHex() diff --git a/test/common/fees/fees.spec.ts b/test/common/fees/fees.spec.ts index cbb6f607..2506af6f 100644 --- a/test/common/fees/fees.spec.ts +++ b/test/common/fees/fees.spec.ts @@ -5,7 +5,7 @@ import { MemoryStorage } from 'disklet/lib/src/backends/memory' import { FEES_PATH } from '../../../src/common/constants' import { Fees, makeFees } from '../../../src/common/fees/makeFees' -import { SimpleFeeSettings } from '../../../src/common/plugin/types' +import { FeeInfo } from '../../../src/common/plugin/types' import { makeFakeIo, makeFakeLog, makeFakePluginInfo } from '../../utils' chai.should() @@ -20,7 +20,7 @@ describe('fees', function () { const disklet = makeMemoryDisklet(memory) let fees: Fees - const testJson = (expected?: SimpleFeeSettings): void => { + const testJson = (expected?: FeeInfo): void => { const str = memory[`/${FEES_PATH}`] if (typeof str === 'string') { // eslint-disable-next-line @typescript-eslint/no-unused-expressions @@ -39,7 +39,7 @@ describe('fees', function () { log: fakeLog }) - fees.fees.should.eql(fakeMakePluginInfo.engineInfo.simpleFeeSettings) + fees.feeInfo.should.eql(fakeMakePluginInfo.engineInfo.defaultFeeInfo) testJson() }) @@ -47,7 +47,7 @@ describe('fees', function () { it('should cache fees after started', async () => { await fees.start() - testJson(fakeMakePluginInfo.engineInfo.simpleFeeSettings) + testJson(fakeMakePluginInfo.engineInfo.defaultFeeInfo) // be sure to stop after start, test will hang otherwise fees.stop() diff --git a/test/common/utxobased/keymanager/coins/bitcoincashtransactiontest.spec.ts b/test/common/utxobased/keymanager/coins/bitcoincashtransactiontest.spec.ts index 07e15d4a..5c509e70 100644 --- a/test/common/utxobased/keymanager/coins/bitcoincashtransactiontest.spec.ts +++ b/test/common/utxobased/keymanager/coins/bitcoincashtransactiontest.spec.ts @@ -1,6 +1,7 @@ import { expect } from 'chai' import { describe, it } from 'mocha' +import { info as bitcoincash } from '../../../../../src/common/utxobased/info/bitcoincash' import { scriptTemplates } from '../../../../../src/common/utxobased/info/scriptTemplates/bitcoincashScriptTemplates' import { AddressTypeEnum, @@ -78,9 +79,10 @@ describe('bitcoincash transaction creation and signing test', () => { targets: [] }) const signedTx = await signTx({ - psbtBase64, + coin: 'bitcoincash', + feeInfo: bitcoincash.engineInfo.defaultFeeInfo, privateKeyEncodings: [privateKeyEncoding], - coin: 'bitcoincash' + psbtBase64 }) expect(signedTx.hex).to.equal( '02000000013ebc8203037dda39d482bf41ff3be955996c50d9d4f7cfc3d2097a694a7b067d000000006a473044022041e30e01f06523646374a356a61238da09f67cfbb5017ff7df47be7c5d1fc1bf0220788ed258f1b6d9c2b28d49c10909cd2cf48f49139c1bb9fe6bfd102f9bf4e44141210365db9da3f8a260078a7e8f8b708a1161468fb2323ffda5ec16b261ec1056f455ffffffff0180380100000000001976a9148bbc95d2709c71607c60ee3f097c1217482f518d88ac00000000' @@ -159,9 +161,10 @@ describe('bitcoincash replay protection transaction creation and signing test', targets: [] }) const signedTx = await signTx({ - psbtBase64, + coin: 'bitcoincash', + feeInfo: bitcoincash.engineInfo.defaultFeeInfo, privateKeyEncodings: [privateKeyEncoding], - coin: 'bitcoincash' + psbtBase64 }) expect(signedTx.hex).to.equal( '02000000010c95c06e793d969af6d1b253d71da18bbc3e549a9d9816214c2a21bb1eed9be600000000d84730440220398da49dabcb8bde7b004d62b7a4f50e0c8b74e5f0f99ebb86ce2932ba3df05e02200ba98a43fa4f67f6252b04f586660ed934ee1ef2c3de6cca3ec3b407c93b095c414c8e4630440220256c12175e809381f97637933ed6ab97737d263eaaebca6add21bced67fd12a402205ce29ecc1369d6fc1b51977ed38faaf41119e3be1d7edfafd7cfaf0b6061bd070021038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508bb210365db9da3f8a260078a7e8f8b708a1161468fb2323ffda5ec16b261ec1056f455acffffffff0180380100000000001976a9148bbc95d2709c71607c60ee3f097c1217482f518d88ac00000000' diff --git a/test/common/utxobased/keymanager/coins/bitcointransactiontest.spec.ts b/test/common/utxobased/keymanager/coins/bitcointransactiontest.spec.ts index 22ed4aae..ef00485c 100644 --- a/test/common/utxobased/keymanager/coins/bitcointransactiontest.spec.ts +++ b/test/common/utxobased/keymanager/coins/bitcointransactiontest.spec.ts @@ -2,6 +2,7 @@ import { expect } from 'chai' import { describe, it } from 'mocha' import { IUTXO } from '../../../../../src/common/utxobased/db/types' +import { info as bitcoin } from '../../../../../src/common/utxobased/info/bitcoin' import { addressToScriptPubkey, AddressTypeEnum, @@ -191,9 +192,10 @@ describe('bitcoin transaction creation and signing test', function () { outputSort: 'bip69' }) const signedTx = await signTx({ - psbtBase64, + coin: 'bitcoin', + feeInfo: bitcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: [privateKeyEncoding], - coin: 'bitcoin' + psbtBase64 }) expect(signedTx.hex).to.equal( '02000000013ebc8203037dda39d482bf41ff3be955996c50d9d4f7cfc3d2097a694a7' + @@ -258,9 +260,10 @@ describe('bitcoin transaction creation and signing test', function () { outputSort: 'bip69' }) const signedTx = await signTx({ - psbtBase64, + coin: 'bitcoin', + feeInfo: bitcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: [privateKeyEncoding], - coin: 'bitcoin' + psbtBase64 }) expect(signedTx.hex).to.equal( '02000000013ebc8203037dda39d482bf41ff3be955996c50d9d4f7cfc3d2097a694a7b067d000000006b4830450221009f9e6c80a05d3af0425c6169ad09ec48e65d1d96436a64c7724c40576cdf9fe502206227c33d4087b05ff0b5e1f0b447569a439cd9418b82abd80440d43ddde3427301210365db9da3f8a260078a7e8f8b708a1161468fb2323ffda5ec16b261ec1056f455ffffffff0464000000000000001600148bbc95d2709c71607c60ee3f097c1217482f518dc8000000000000001600148bbc95d2709c71607c60ee3f097c1217482f518d2c010000000000001600148bbc95d2709c71607c60ee3f097c1217482f518d28360100000000001976a914ca0d36044e0dc08a22724efa6f6a07b0ec4c79aa88ac00000000' @@ -320,9 +323,10 @@ describe('bitcoin transaction creation and signing test', function () { outputSort: 'targets' }) const signedTx = await signTx({ - psbtBase64, + coin: 'bitcoin', + feeInfo: bitcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: [privateKeyEncoding], - coin: 'bitcoin' + psbtBase64 }) expect(signedTx.hex).to.equal( '02000000013ebc8203037dda39d482bf41ff3be955996c50d9d4f7cfc3d2097a694a7b067d000000006a47304402203d4b4d8f7be9219914e822684ce72001367081101654aaeeaa734e6aa934972e022072154039d101819e8c78fc3a11132e5a46a3538546db68c8a7818128b02de88101210365db9da3f8a260078a7e8f8b708a1161468fb2323ffda5ec16b261ec1056f455ffffffff042c010000000000001600148bbc95d2709c71607c60ee3f097c1217482f518dc8000000000000001600148bbc95d2709c71607c60ee3f097c1217482f518d64000000000000001600148bbc95d2709c71607c60ee3f097c1217482f518d28360100000000001976a914ca0d36044e0dc08a22724efa6f6a07b0ec4c79aa88ac00000000' @@ -375,9 +379,10 @@ describe('bitcoin transaction creation and signing test', function () { }) const { hex: rawtransaction } = await signTx({ - psbtBase64, + coin: 'bitcoin', + feeInfo: bitcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: [privateKeyEncoding], - coin: 'bitcoin' + psbtBase64 }) expect(rawtransaction).to.equal( @@ -412,13 +417,14 @@ describe('bitcoin transaction creation and signing test', function () { }) const { hex: segwitRawTransaction } = await signTx({ - psbtBase64, + coin: 'bitcoin', + feeInfo: bitcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: [ privateKeyEncoding, privateKeyEncoding, privateKeyEncoding ], - coin: 'bitcoin' + psbtBase64 }) expect(segwitRawTransaction).to.equal( @@ -492,13 +498,14 @@ describe('bitcoin transaction creation and signing test', function () { }) const { hex: rawtransaction } = await signTx({ - psbtBase64, + coin: 'bitcoin', + feeInfo: bitcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: [ privateKeyEncoding, privateKeyEncoding, privateKeyEncoding ], - coin: 'bitcoin' + psbtBase64 }) expect(rawtransaction).to.equal( '020000000001033ebc8203037dda39d482bf41ff3be955996c50d9d4f7cfc3d2097a694a7b067d000000006b483045022100c10c70dab0e8e88a67bb013d276b88b3d5a52d3cb3ec53aa7d2e7c4704e89dc602207fabdfa3b55b196da7792de9fe436535501fce2fe76439d5361bd5d9dd69bd0901210365db9da3f8a260078a7e8f8b708a1161468fb2323ffda5ec16b261ec1056f455ffffffffb385ee16c29a8148e7e99187a293e96fcf9a16e4967d3afc8f7838024dfa268b0100000000ffffffff9e5d335ec9133a9e5ed426d08c421273594b82ab9876b5beb66716384688f2e901000000171600148bbc95d2709c71607c60ee3f097c1217482f518dffffffff03c8000000000000001976a9148bbc95d2709c71607c60ee3f097c1217482f518d88acc8000000000000001600148bbc95d2709c71607c60ee3f097c1217482f518dc80000000000000017a9142427d83a84e5793ce6f6efc33020d844dd217dbb8700024730440220008a9738e8acdc002ae4bb415ff7368161057ed9b22fd8b671c5acbb47379a69022045ab99fa73730fa367d3972d41b26b4ef337b34c4e593c4f47800ed4ee1c64fd01210365db9da3f8a260078a7e8f8b708a1161468fb2323ffda5ec16b261ec1056f4550247304402201d4f3ee993cfb468dc41387ac618081c36c49ebc9db528155b51d346382c347802201d1c07201f80df3e6e86195444532b6be86e9a429a7eb5a0ae268df9760a974601210365db9da3f8a260078a7e8f8b708a1161468fb2323ffda5ec16b261ec1056f45500000000' @@ -549,9 +556,10 @@ describe('bitcoin transaction creation and signing test', function () { }) const signedTx = await signTx({ - psbtBase64, + coin: 'bitcoin', + feeInfo: bitcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: [privateKeyEncoding], - coin: 'bitcoin' + psbtBase64 }) const utxos: IUTXO[] = Array(100) @@ -584,9 +592,10 @@ describe('bitcoin transaction creation and signing test', function () { }) const { hex: hexTxMultiSigned } = await signTx({ - psbtBase64: psbtBase64Multi, + coin: 'bitcoin', + feeInfo: bitcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: Array(nOutputs).fill(privateKeyEncoding), - coin: 'bitcoin' + psbtBase64: psbtBase64Multi }) expect(hexTxMultiSigned).to.equal( diff --git a/test/common/utxobased/keymanager/coins/groestlcointransactiontest.spec.ts b/test/common/utxobased/keymanager/coins/groestlcointransactiontest.spec.ts index 9bc8ee5f..f20266dd 100644 --- a/test/common/utxobased/keymanager/coins/groestlcointransactiontest.spec.ts +++ b/test/common/utxobased/keymanager/coins/groestlcointransactiontest.spec.ts @@ -1,6 +1,7 @@ import { expect } from 'chai' import { describe, it } from 'mocha' +import { info as groestlcoin } from '../../../../../src/common/utxobased/info/groestlcoin' import { makeTx, privateKeyEncodingToPubkey, @@ -60,9 +61,10 @@ describe('groestlcoin transaction creation and signing test', function () { }) const { hex: hexTxSigned } = await signTx({ - psbtBase64, + coin: 'groestlcoin', + feeInfo: groestlcoin.engineInfo.defaultFeeInfo, privateKeyEncodings: [privateKeyEncoding], - coin: 'groestlcoin' + psbtBase64 }) expect(hexTxSigned).to.equal( '020000000001013ebc8203037dda39d482bf41ff3be955996c50d9d4f7cfc3d2097a694a7b067d0000000000ffffffff0180380100000000001976a914d9863e608009f46ce023c852c7c209a607f8542b88ac024730440220558f35be4edc22260bf98fe197e39aff6bfc3717be853735be837a30bd2a0f4202207b2429dd031e851b82836e24524689c70a8c8bf4be58f9b4be23bf3e76fa577a0121030f25e157a5ddc119bf370beb688878a3600461eb5c769a5556bdfe225d9a246e00000000' diff --git a/test/utils.ts b/test/utils.ts index a848a155..f7388d70 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -34,7 +34,7 @@ export const makeFakePluginInfo = (): PluginInfo => { defaultFee: 0, feeUpdateInterval: 0, gapLimit: 0, - simpleFeeSettings: { + defaultFeeInfo: { lowFeeFudgeFactor: undefined, standardFeeLowFudgeFactor: undefined, standardFeeHighFudgeFactor: undefined, @@ -45,7 +45,8 @@ export const makeFakePluginInfo = (): PluginInfo => { standardFeeHigh: '3', standardFeeHighAmount: '4', standardFeeLow: '5', - standardFeeLowAmount: '6' + standardFeeLowAmount: '6', + maximumFeeRate: undefined } }, coinInfo: {