rebased
This commit is contained in:
parent
2581f488fa
commit
60f6300fbc
|
@ -1398,7 +1398,6 @@ WalletService.prototype._selectTxInputs2 = function(txp, utxosToExclude, cb) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function select(utxos) {
|
function select(utxos) {
|
||||||
// TODO: fix for when fee is specified instead of feePerKb
|
|
||||||
var txpAmount = txp.getTotalAmount();
|
var txpAmount = txp.getTotalAmount();
|
||||||
var baseTxpSize = txp.getEstimatedSize();
|
var baseTxpSize = txp.getEstimatedSize();
|
||||||
var baseTxpFee = baseTxpSize * txp.feePerKb / 1000.;
|
var baseTxpFee = baseTxpSize * txp.feePerKb / 1000.;
|
||||||
|
@ -1408,11 +1407,11 @@ WalletService.prototype._selectTxInputs2 = function(txp, utxosToExclude, cb) {
|
||||||
var totalValueInUtxos = _.sum(utxos, 'satoshis');
|
var totalValueInUtxos = _.sum(utxos, 'satoshis');
|
||||||
var netValueInUtxos = totalValueInUtxos - baseTxpFee - (utxos.length * feePerInput);
|
var netValueInUtxos = totalValueInUtxos - baseTxpFee - (utxos.length * feePerInput);
|
||||||
if (totalValueInUtxos < txpAmount) {
|
if (totalValueInUtxos < txpAmount) {
|
||||||
log.debug('Total value in all utxos (' + formatAmount(totalValueInUtxos) + ') is insufficient to cover for txp amount (' + formatAmount(txpAmount) + ')'); // TODO
|
log.debug('Total value in all utxos (' + formatAmount(totalValueInUtxos) + ') is insufficient to cover for txp amount (' + formatAmount(txpAmount) + ')');
|
||||||
return Errors.INSUFFICIENT_FUNDS;
|
return Errors.INSUFFICIENT_FUNDS;
|
||||||
}
|
}
|
||||||
if (netValueInUtxos < txpAmount) {
|
if (netValueInUtxos < txpAmount) {
|
||||||
log.debug('Value after fees in all utxos (' + formatAmount(netValueInUtxos) + ') is insufficient to cover for txp amount (' + formatAmount(txpAmount) + ')'); // TODO
|
log.debug('Value after fees in all utxos (' + formatAmount(netValueInUtxos) + ') is insufficient to cover for txp amount (' + formatAmount(txpAmount) + ')');
|
||||||
return Errors.INSUFFICIENT_FUNDS_FOR_FEE;
|
return Errors.INSUFFICIENT_FUNDS_FOR_FEE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1462,7 +1461,7 @@ WalletService.prototype._selectTxInputs2 = function(txp, utxosToExclude, cb) {
|
||||||
log.debug('Tx amount/input amount:' + formatRatio(amountVsUtxoRatio) + ' (min: ' + formatRatio(Defaults.UTXO_SELECTION_MIN_TX_AMOUNT_VS_UTXO_FACTOR) + ')');
|
log.debug('Tx amount/input amount:' + formatRatio(amountVsUtxoRatio) + ' (min: ' + formatRatio(Defaults.UTXO_SELECTION_MIN_TX_AMOUNT_VS_UTXO_FACTOR) + ')');
|
||||||
|
|
||||||
if (txpSize / 1000. > Defaults.MAX_TX_SIZE_IN_KB) {
|
if (txpSize / 1000. > Defaults.MAX_TX_SIZE_IN_KB) {
|
||||||
log.debug('Breaking because tx size (' + formatSize(txpSize) + ') is too big (max: ' + formatSize(Defaults.MAX_TX_SIZE_IN_KB * 1000.) + ')'); // TODO
|
log.debug('Breaking because tx size (' + formatSize(txpSize) + ') is too big (max: ' + formatSize(Defaults.MAX_TX_SIZE_IN_KB * 1000.) + ')');
|
||||||
error = Errors.TX_MAX_SIZE_EXCEEDED;
|
error = Errors.TX_MAX_SIZE_EXCEEDED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2355,7 +2355,7 @@ describe('Wallet service', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail to create a tx exceeding max size in kb', function(done) {
|
it('should fail to create a tx exceeding max size in kb', function(done) {
|
||||||
log.level = 'debug';
|
// log.level = 'debug';
|
||||||
var _oldDefault = Defaults.MAX_TX_SIZE_IN_KB;
|
var _oldDefault = Defaults.MAX_TX_SIZE_IN_KB;
|
||||||
Defaults.MAX_TX_SIZE_IN_KB = 1;
|
Defaults.MAX_TX_SIZE_IN_KB = 1;
|
||||||
helpers.stubUtxos(server, wallet, _.range(1, 10, 0), function() {
|
helpers.stubUtxos(server, wallet, _.range(1, 10, 0), function() {
|
||||||
|
@ -3186,8 +3186,7 @@ describe('Wallet service', function() {
|
||||||
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||||
amount: 0.8 * 1e8,
|
amount: 0.8 * 1e8,
|
||||||
}],
|
}],
|
||||||
message: 'some message',
|
feePerKb: 100e2,
|
||||||
customData: 'some custom data',
|
|
||||||
};
|
};
|
||||||
server.createTx(txOpts, function(err, tx) {
|
server.createTx(txOpts, function(err, tx) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
|
Loading…
Reference in New Issue