From dcb48f84b21f118632ca2769a30a96b04f591a57 Mon Sep 17 00:00:00 2001 From: James Cramer Date: Thu, 6 Feb 2020 14:31:13 -0500 Subject: [PATCH] 0.24.3 update * include extra baton/receiver sats in mint/genesis change calculation --- lib/slp.ts | 27 ++++++++++++++++----------- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/slp.ts b/lib/slp.ts index a4ae6561..1f369ec7 100644 --- a/lib/slp.ts +++ b/lib/slp.ts @@ -230,7 +230,7 @@ export class Slp { if (config.batonReceiverSatoshis === undefined) { config.batonReceiverSatoshis = new BigNumber(546); - } + } // Make sure we're not spending any token or baton UTXOs config.input_utxos.forEach((txo) => { @@ -276,7 +276,10 @@ export class Slp { config.slpGenesisOpReturn.length, config.input_utxos.length, config.batonReceiverAddress, - config.bchChangeReceiverAddress); + config.bchChangeReceiverAddress) + + (config.mintReceiverSatoshis.gt(546) ? config.mintReceiverSatoshis.toNumber() - 546 : 0) + + (config.batonReceiverSatoshis.gt(546) ? config.batonReceiverSatoshis.toNumber() - 546 : 0); + const bchChangeAfterFeeSatoshis: BigNumber = satoshis.minus(genesisCost); // Genesis OpReturn @@ -558,15 +561,17 @@ export class Slp { satoshis = satoshis.plus(baton_utxo.satoshis); }); - const mintCost = this.calculateGenesisCost - ( - config.slpMintOpReturn.length, - config.input_baton_utxos.length, - config.batonReceiverAddress, - config.bchChangeReceiverAddress, - ) - + - (config.extraFee ? config.extraFee : 0); + const mintCost = this.calculateGenesisCost( + config.slpMintOpReturn.length, + config.input_baton_utxos.length, + config.batonReceiverAddress, + config.bchChangeReceiverAddress) + + + (config.extraFee ? config.extraFee : 0) + + + (config.batonReceiverSatoshis.gt(546) ? config.batonReceiverSatoshis.toNumber() - 546 : 0) + + + (config.mintReceiverSatoshis.gt(546) ? config.mintReceiverSatoshis.toNumber() - 546 : 0); // BCH change const bchChangeAfterFeeSatoshis = satoshis.minus(mintCost); diff --git a/package-lock.json b/package-lock.json index 358de2c1..902c855b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "slpjs", - "version": "0.24.2", + "version": "0.24.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a818bcae..463be108 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slpjs", - "version": "0.24.2", + "version": "0.24.3", "description": "Simple Ledger Protocol (SLP) JavaScript Library", "main": "index.js", "files": [