breaking change to UnspentOuts hostedMoneroAPIClient method callback args: removed redundant unusedOutputs and switched over to mandatory return of per byte fee - prefers per b in API response with fallback to per kb for deploy rollover - per kb can be removed in the future

pull/63/head 1.1.2
Paul Shapiro 6 years ago
parent eb9db411f6
commit 789c1fa71b

@ -445,9 +445,21 @@ function Parsed_UnspentOuts__sync(
}
}
// console.log("Unspent outs: " + JSON.stringify(finalized_unspentOutputs));
var final__per_byte_fee__string;
if (typeof data.per_byte_fee !== 'undefined' && data.per_byte_fee) {
final__per_byte_fee__string = data.per_byte_fee // (is already string)
} else { // per_byte_fee not yet deployed - fall back to per_kb_fee
if (typeof data.per_kb_fee == 'undefined' || !data.per_kb_fee) {
throw "Expected data.per_kb_fee or data.per_byte_fee"
}
final__per_byte_fee__string = (new JSBigInt(data.per_kb_fee)).divide(1024).toString() // scale from kib to b and convert back to string
}
if (typeof final__per_byte_fee__string == 'undefined' || !final__per_byte_fee__string) {
throw "Unable to derive per_byte_fee string"
}
const returnValuesByKey = {
unspentOutputs: finalized_unspentOutputs,
per_kb_fee: data.per_kb_fee, // String
per_byte_fee__string: final__per_byte_fee__string, // String
};
return returnValuesByKey;
}

@ -165,16 +165,16 @@ function SendFunds( // TODO: migrate this to take a map of args
wallet__private_keys.spend,
mixin,
sweeping,
function(err, returned_unspentOuts, returned_unusedOuts, dynamic_feePerKB_JSBigInt)
function(err, returned_unusedOuts, per_byte_fee__string)
{
if (err) {
__trampolineFor_err_withErr(err);
return;
}
console.log("Received dynamic per kb fee", monero_amount_format_utils.formatMoneySymbol(dynamic_feePerKB_JSBigInt));
console.log("Received dynamic per kb fee", monero_amount_format_utils.formatMoneySymbol(new JSBigInt(per_byte_fee__string)));
{ // save some values for re-enterable function
unspent_outs = returned_unusedOuts; // TODO: which one should be used? delete the other
fee_per_b__string = dynamic_feePerKB_JSBigInt.divide(1024).toString() // TODO: soon deprecate per kib fee
fee_per_b__string = per_byte_fee__string;
}
__reenterable_constructAndSendTx(
null, // for the first try - passedIn_attemptAt_network_minimumFee

@ -86,15 +86,14 @@ class APIClient
fn(err)
return
}
const per_kb_fee__String = returnValuesByKey.per_kb_fee
if (per_kb_fee__String == null || per_kb_fee__String == "" || typeof per_kb_fee__String === 'undefined') {
throw "Unexpected / missing per_kb_fee"
const per_byte_fee__string = returnValuesByKey.per_byte_fee__string
if (per_byte_fee__string == null || per_byte_fee__string == "" || typeof per_byte_fee__string === 'undefined') {
throw "Unexpected / missing per_byte_fee__string"
}
fn(
err, // no error
returnValuesByKey.unspentOutputs,
returnValuesByKey.unspentOutputs, // TODO: remove this - it was the unused 'unusedOutputs'
new JSBigInt(per_kb_fee__String)
returnValuesByKey.per_byte_fee__string
)
}
)
@ -221,7 +220,8 @@ class Fetch
]
} // NOTE: we'd have more in the real reply - and even the api response parser doesn't care about those values right now
],
per_kb_fee: parseInt("24658"/*for str search*/) * 1024 // scale the per b we know up to per kib (so it can be scaled back down - interrim until all clients are ready for per b fee)
per_byte_fee: "24658"
/*deprecated*/// per_kb_fee: parseInt("24658"/*for str search*/) * 1024 // scale the per b we know up to per kib (so it can be scaled back down - interrim until all clients are ready for per b fee)
})
} else if (url.indexOf("get_random_outs") !== -1) {
resolve({
@ -286,16 +286,7 @@ describe("sendingFunds tests", function()
},
function(err)
{
console.error("SendFunds err:", err)
assert.notEqual(
err,
null
);
assert.notEqual(
err,
undefined
);
// ^-- I'm not confident these are tripping
throw "SendFunds err:" + err // TODO: how to assert err msg not nil? didn't works
}
)
});

Loading…
Cancel
Save