diff --git a/modules/ecash-coinselect/README.md b/modules/ecash-coinselect/README.md --- a/modules/ecash-coinselect/README.md +++ b/modules/ecash-coinselect/README.md @@ -37,4 +37,12 @@ - Improvements from [diff review](https://reviews.bitcoinabc.org/D14526) +2.0.2-3 + +- Dep upgrades + +2.0.4 + +- Add support for utxo format from in-node chronik-client [diff](https://reviews.bitcoinabc.org/D15518) + ## License [MIT](LICENSE) diff --git a/modules/ecash-coinselect/package-lock.json b/modules/ecash-coinselect/package-lock.json --- a/modules/ecash-coinselect/package-lock.json +++ b/modules/ecash-coinselect/package-lock.json @@ -1,12 +1,12 @@ { "name": "ecash-coinselect", - "version": "2.0.1", + "version": "2.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ecash-coinselect", - "version": "2.0.1", + "version": "2.0.4", "license": "MIT", "dependencies": { "eslint-plugin-header": "^3.1.1", diff --git a/modules/ecash-coinselect/package.json b/modules/ecash-coinselect/package.json --- a/modules/ecash-coinselect/package.json +++ b/modules/ecash-coinselect/package.json @@ -1,6 +1,6 @@ { "name": "ecash-coinselect", - "version": "2.0.3", + "version": "2.0.4", "description": "An unspent transaction output (UTXO) selection module for eCash.", "main": "src/utxo.js", "scripts": { diff --git a/modules/ecash-coinselect/src/utils.js b/modules/ecash-coinselect/src/utils.js --- a/modules/ecash-coinselect/src/utils.js +++ b/modules/ecash-coinselect/src/utils.js @@ -11,7 +11,12 @@ * @returns {bool} true if this utxo is a valid SLP utxo */ function isToken(utxo) { - return typeof utxo.slpToken !== 'undefined'; + return ( + // NNG chronik-client + typeof utxo.slpToken !== 'undefined' || + // in-node chronik-client + typeof utxo.token !== 'undefined' + ); } /** diff --git a/modules/ecash-coinselect/test/coinSelect.test.js b/modules/ecash-coinselect/test/coinSelect.test.js --- a/modules/ecash-coinselect/test/coinSelect.test.js +++ b/modules/ecash-coinselect/test/coinSelect.test.js @@ -168,7 +168,7 @@ coinSelect(stubChronikUtxos, [{ value: 5600 }], 1); }, Error('Insufficient funds')); }); - it('ignores slp utxos', function () { + it('ignores slp utxos from NNG chronik-client', function () { // Make all utxos slp utxos const stubChronikUtxos = [ { value: '1000', slpToken: {} }, @@ -180,4 +180,16 @@ coinSelect(stubChronikUtxos, [{ value: 900 }], 1); }, Error('Insufficient funds')); }); + it('ignores slp utxos from in-node chronik-client', function () { + // Make all utxos slp utxos + const stubChronikUtxos = [ + { value: '1000', token: {} }, + { value: '2000', token: {} }, + { value: '3000', token: {} }, + ]; + // The wallet now has insufficient funds to send an eCash tx, as slp utxos will be ignored + assert.throws(() => { + coinSelect(stubChronikUtxos, [{ value: 900 }], 1); + }, Error('Insufficient funds')); + }); }); diff --git a/modules/ecash-coinselect/test/utils.test.js b/modules/ecash-coinselect/test/utils.test.js --- a/modules/ecash-coinselect/test/utils.test.js +++ b/modules/ecash-coinselect/test/utils.test.js @@ -38,10 +38,13 @@ sumValues(badValueUtxosString); }, new assert.AssertionError({ message: `Input must be an object with 'value' as a key and an integer representing the amount in satoshis as a value`, actual: false, expected: true, operator: '==' })); }); - it(`isToken() returns true for a stub SLP utxo, i.e. an object with key 'slpToken'`, function () { - assert.strictEqual(isToken({ slpToken: {} }), true); + it(`isToken() returns true for a stub SLP utxo from NNG chronik-client, i.e. an object with key 'slpToken'`, function () { + assert.equal(isToken({ slpToken: {} }), true); + }); + it(`isToken() returns true for a stub SLP utxo from in-node chronik-client, i.e. an object with key 'token'`, function () { + assert.equal(isToken({ token: {} }), true); }); it(`isToken() returns false for a stub non-SLP utxo, i.e. an object without key 'slpToken'`, function () { - assert.strictEqual(isToken({}), false); + assert.equal(isToken({}), false); }); });