Merge pull request #696 from matiu/bug/sigle-address-dups

fix change address storage for single address wallets
This commit is contained in:
Ivan Socolsky 2017-09-04 09:27:33 -03:00 committed by GitHub
commit d25e21b0d5
2 changed files with 27 additions and 1 deletions

View File

@ -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) {

View File

@ -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';