fix change address storage for single address wallets
This commit is contained in:
parent
b74318862e
commit
05982ba166
|
@ -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) {
|
||||
|
|
|
@ -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…
Reference in New Issue