Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanity check of github actions #54

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 2 additions & 80 deletions dashwallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,8 @@
err.code = "INCONCEIVABLE";
throw err;
}
txInfoRaw.inputs.sort(DashTx.sortInputs);
txInfoRaw.outputs.sort(DashTx.sortOutputs);

let dashTx = DashTx.create();
let keys;
Expand Down Expand Up @@ -1542,13 +1544,11 @@
}

let payAddresses = addrsInfo.addresses.slice(0);
fauxTxos.sort(Wallet.sortInputs);
for (let output of outputs) {
output = Object.assign(output, {
address: payAddresses.pop(),
});
}
outputs.sort(Wallet.sortOutputs);

for (let output of outputs) {
//@ts-ignore TODO bad export
Expand Down Expand Up @@ -3085,84 +3085,6 @@
return usable;
}

/**
* Sort deterministic by Tx, VOut, Addr (all Asc), and Sats (Dsc)
*
* Note: it's important that it's deterministic (or random)
* to maintain the cash-like quality transfer - rather than
* by payee and change, which leaks more information to bad actors.
*
* TODO move to DashTx
*
* @param {CoreUtxo} a
* @param {CoreUtxo} b
* @returns Number
*/
Wallet.sortInputs = function (a, b) {
// Ascending TxID (Lexicographical)
if (a.txId > b.txId) {
return 1;
}
if (a.txId < b.txId) {
return -1;
}

// Ascending Vout (Numerical)
let indexDiff = a.outputIndex - b.outputIndex;
if (indexDiff !== 0) {
return indexDiff;
}

// Ascending Address (Lexicographical)
if (a.address > b.address) {
return 1;
}
if (a.address < b.address) {
return -1;
}

// Descending Sats (Numberical)
return b.satoshis - a.satoshis;
};

/**
* Sort deterministic by Addr (all Asc), and Sats (Dsc)
*
* Note: it's important that it's deterministic (or random)
* to maintain the cash-like quality transfer - rather than
* by payee and change, which leaks more information to bad actors.
*
* TODO move to DashTx
*
* @param {TxOutput} a
* @param {TxOutput} b
* @returns Number
*/
Wallet.sortOutputs = function (a, b) {
if (a.pubKeyHash && b.pubKeyHash) {
// Ascending PKH (Lexicographical)
if (a.pubKeyHash > b.pubKeyHash) {
return 1;
}
if (a.pubKeyHash < b.pubKeyHash) {
return -1;
}
}

if (a.address && b.address) {
// Ascending Address (Lexicographical)
if (a.address > b.address) {
return 1;
}
if (a.address < b.address) {
return -1;
}
}

// Descending Sats (Numberical)
return b.satoshis - a.satoshis;
};

/**
* Sort DenomInfos first by lowest face value first
* @param {DenomInfo} a
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"bin": {},
"files": [
"index.js",
"lib/",
"dashwallet.js"
],
"scripts": {
Expand Down
Loading