Browse Source

fix change address storage for single address wallets

feat/estimateFee-limit
matiu 7 years ago
parent
commit
05982ba166
  1. 2
      lib/server.js
  2. 26
      test/integration/server.js

2
lib/server.js

@ -2156,7 +2156,7 @@ WalletService.prototype.createTx = function(opts, cb) {
self._selectTxInputs(txp, opts.utxosToExclude, next);
},
function(next) {
if (!changeAddress || opts.dryRun) return next();
if (!changeAddress || wallet.singleAddress || opts.dryRun) return next();
self.storage.storeAddressAndWallet(wallet, txp.changeAddress, next);
},
function(next) {

26
test/integration/server.js

@ -4369,6 +4369,32 @@ describe('Wallet service', function() {
});
});
});
it('should not duplicate address on storage after TX creation', function(done) {
helpers.stubUtxos(server, wallet, 2, function() {
var toAddress = '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7';
var opts = {
outputs: [{
amount: 1e8,
toAddress: toAddress,
}],
feePerKb: 100e2,
};
server.createTx(opts, function(err, txp) {
should.not.exist(err);
server.storage.fetchAddresses(wallet.id, function(err, addresses) {
should.not.exist(err);
addresses.length.should.equal(1);
done();
});
});
});
});
it('should not be able to specify custom changeAddress', function(done) {
helpers.stubUtxos(server, wallet, 2, function() {
var toAddress = '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7';

Loading…
Cancel
Save