Skip to content

Commit

Permalink
0.24.3 update
Browse files Browse the repository at this point in the history
* include extra baton/receiver sats in mint/genesis change calculation
  • Loading branch information
jcramer committed Feb 6, 2020
1 parent c777b92 commit dcb48f8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
27 changes: 16 additions & 11 deletions lib/slp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit dcb48f8

Please sign in to comment.