Skip to content

Commit

Permalink
ref(draftTx): give names to magic numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Mar 25, 2024
1 parent 936037a commit 7239bdf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions dashwallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1875,10 +1875,20 @@
let totalAvailable = DashApi.getBalance(inputs);
let fees = DashTx.appraise({ inputs: inputs, outputs: [output] });

//let EXTRA_SIG_BYTES_PER_INPUT = 2;
let CHANCE_INPUT_SIGS_HAVE_NO_EXTRA_BYTES = 1 / 4;
let MINIMUM_CHANCE_SIG_MATCHES_TARGET = 1 / 20;

let feeEstimate = fees.min;
let minimumIsUnlikely = inputs.length > 2;
let chanceSignaturesMatchLowestFee = Math.pow(
CHANCE_INPUT_SIGS_HAVE_NO_EXTRA_BYTES,
inputs.length,
);
let minimumIsUnlikely =
chanceSignaturesMatchLowestFee < MINIMUM_CHANCE_SIG_MATCHES_TARGET;
if (minimumIsUnlikely) {
let likelyPadByteSize = 2 * inputs.length;
//let likelyPadByteSize = EXTRA_SIG_BYTES_PER_INPUT * inputs.length;
let likelyPadByteSize = inputs.length;
feeEstimate += likelyPadByteSize;
}

Expand Down

0 comments on commit 7239bdf

Please sign in to comment.