Skip to content

Commit

Permalink
Bugfix/fee estimate rounding (#210)
Browse files Browse the repository at this point in the history
* fix fee extimate rounding issue

* re fee rounding

* Apply formatting changes

---------

Co-authored-by: 2qx <2qx@users.noreply.github.com>
  • Loading branch information
2qx and 2qx authored May 5, 2024
1 parent aec78e8 commit dcc9c4f
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 28 deletions.
4 changes: 2 additions & 2 deletions demo/min/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainnet-cash/demo-min",
"version": "2.3.12",
"version": "2.3.13",
"private": true,
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"publish:public": "echo 'noop'"
},
"dependencies": {
"@mainnet-cash/contract": "2.3.12"
"@mainnet-cash/contract": "2.3.13"
},
"devDependencies": {
"webpack": "5.58.1",
Expand Down
4 changes: 2 additions & 2 deletions demo/react-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-next",
"version": "2.3.12",
"version": "2.3.13",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -15,7 +15,7 @@
"@types/react-dom": "18.0.10",
"eslint": "8.32.0",
"eslint-config-next": "13.1.2",
"mainnet-js": "2.3.12",
"mainnet-js": "2.3.13",
"next": "13.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
6 changes: 3 additions & 3 deletions demo/vue-nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"rollup-plugin-node-polyfills": "^0.2.1"
},
"dependencies": {
"mainnet-js": "2.3.12",
"@mainnet-cash/indexeddb-storage": "2.3.12"
"mainnet-js": "2.3.13",
"@mainnet-cash/indexeddb-storage": "2.3.13"
},
"version": "2.3.12"
"version": "2.3.13"
}
6 changes: 3 additions & 3 deletions demo/vue-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-vite",
"version": "2.3.12",
"version": "2.3.13",
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only",
Expand All @@ -13,8 +13,8 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"mainnet-js": "2.3.12",
"@mainnet-cash/indexeddb-storage": "2.3.12",
"mainnet-js": "2.3.13",
"@mainnet-cash/indexeddb-storage": "2.3.13",
"vue": "^3.2.37",
"vue-router": "^4.1.2"
},
Expand Down
4 changes: 2 additions & 2 deletions demo/vue3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainnet-cash/demo",
"version": "2.3.12",
"version": "2.3.13",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand All @@ -13,7 +13,7 @@
"dependencies": {
"core-js": "^3.6.5",
"electrum-cash": "^2.0.8",
"mainnet-js": "2.3.12",
"mainnet-js": "2.3.13",
"register-service-worker": "^1.7.1",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"**/jest-runner/**"
]
},
"version": "2.3.12",
"version": "2.3.13",
"homepage": "https://mainnet.cash",
"scripts": {
"api:validate": "docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v6.2.1 validate -i /local/swagger/v1/api.yml",
Expand Down
4 changes: 2 additions & 2 deletions packages/contract/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "@mainnet-cash/contract",
"version": "2.3.12",
"version": "2.3.13",
"module": "dist/module/index.js",
"types": "dist/module/index.d.ts",
"exports": {
Expand All @@ -14,7 +14,7 @@
"assert": "^2.1.0",
"cashc": "^0.8.0",
"cashscript": "^0.8.0",
"mainnet-js": "2.3.12",
"mainnet-js": "2.3.13",
"pako": "^2.1.0",
"util": "^0.12.5"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/indexeddb-storage/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "@mainnet-cash/indexeddb-storage",
"version": "2.3.12",
"version": "2.3.13",
"module": "dist/module/index.js",
"types": "dist/module/index.d.ts",
"exports": {
Expand All @@ -11,7 +11,7 @@
"author": "readcash",
"dependencies": {
"dexie": "^3.2.4",
"mainnet-js": "2.3.12"
"mainnet-js": "2.3.13"
},
"devDependencies": {
"fake-indexeddb": "^3.1.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/mainnet-cash/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ info:
url: https://github.com/mainnet-cash/mainnet-js/blob/master/LICENSE
termsOfService: https://mainnet.cash/terms/
title: Mainnet Cash
version: 2.3.12
version: 2.3.13
externalDocs:
description: Find out more about mainnet-js
url: https://mainnet.cash
Expand Down
8 changes: 4 additions & 4 deletions packages/mainnet-cash/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "mainnet-cash",
"version": "2.3.12",
"version": "2.3.13",
"description": "A developer friendly bitcoin cash wallet api This API is currently in active development, breaking changes may be made prior to official release of version 1. **Important:** This library is in active development ",
"module": "index.js",
"scripts": {
Expand All @@ -17,8 +17,8 @@
"license": "MIT",
"private": true,
"dependencies": {
"@mainnet-cash/contract": "2.3.12",
"@mainnet-cash/postgresql-storage": "2.3.12",
"@mainnet-cash/contract": "2.3.13",
"@mainnet-cash/postgresql-storage": "2.3.13",
"body-parser": "^1.19.0",
"camelcase": "^5.3.1",
"connect-timeout": "^1.9.0",
Expand All @@ -28,7 +28,7 @@
"express-openapi-validator": "3.17.2",
"express-rate-limit": "^5.2.3",
"js-yaml": "^3.3.0",
"mainnet-js": "2.3.12",
"mainnet-js": "2.3.13",
"ono": "^5.0.1",
"openapi-sampler": "^1.0.0-beta.15",
"patch-package": "^6.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/mainnet-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"url": "https://github.com/mainnet-cash/mainnet-js/issues"
},
"name": "mainnet-js",
"version": "2.3.12",
"version": "2.3.13",
"homepage": "https://mainnet.cash",
"module": "dist/module/index.js",
"browser": {
Expand Down
6 changes: 4 additions & 2 deletions packages/mainnet-js/src/transaction/Wif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ export async function getFeeAmountSimple({
sendRequests.reduce((prev, curr) => prev + outputSize(curr), 0) +
(discardChange ? 0 : outputSizeP2pkh);

return (inputTotalSize + outputTotalSize + 16) * relayFeePerByteInSatoshi;
return Math.ceil(
(inputTotalSize + outputTotalSize + 16) * relayFeePerByteInSatoshi
);
}

// precise fee estimation
Expand Down Expand Up @@ -520,7 +522,7 @@ export async function getFeeAmount({
changeAddress: "",
});

return draftTransaction.length * relayFeePerByteInSatoshi + 1;
return Math.ceil(draftTransaction.length * relayFeePerByteInSatoshi + 1);
} else {
throw Error(
"The available inputs in the wallet cannot satisfy this send request"
Expand Down
4 changes: 2 additions & 2 deletions packages/postgresql-storage/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "@mainnet-cash/postgresql-storage",
"version": "2.3.12",
"version": "2.3.13",
"module": "dist/module/index.js",
"types": "dist/module/index.d.ts",
"exports": {
Expand All @@ -11,7 +11,7 @@
"author": "readcash",
"dependencies": {
"axios": "^0.21.1",
"mainnet-js": "2.3.12",
"mainnet-js": "2.3.13",
"parse-database-url": "^0.3.0",
"pg": "^8.11.3",
"pg-format": "^1.0.4"
Expand Down
2 changes: 1 addition & 1 deletion swagger/v1/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ info:
url: https://github.com/mainnet-cash/mainnet-js/blob/master/LICENSE
termsOfService: https://mainnet.cash/terms/
title: Mainnet Cash
version: 2.3.12
version: 2.3.13
externalDocs:
description: Find out more about mainnet-js
url: https://mainnet.cash
Expand Down

0 comments on commit dcc9c4f

Please sign in to comment.