@bitpay-labs/bitcore-wallet-service 11.10.10 → 11.10.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/externalservices/simplex.ts +15 -33
- package/src/lib/blockchainexplorers/v8/client.ts +14 -0
- package/src/lib/blockchainexplorers/v8.ts +12 -1
- package/src/lib/chain/btc/index.ts +5 -0
- package/src/lib/chain/eth/index.ts +4 -0
- package/src/lib/chain/index.ts +4 -0
- package/src/lib/chain/sol/index.ts +6 -0
- package/src/lib/chain/xrp/index.ts +5 -0
- package/src/lib/common/utils.ts +52 -1
- package/src/lib/routes/middleware/authTssRequest.ts +1 -1
- package/src/lib/routes/services.ts +1 -14
- package/src/lib/routes/walletdata.ts +11 -0
- package/src/lib/server.ts +44 -2
- package/src/types/chain.d.ts +1 -0
- package/test/chain/sol.test.ts +48 -0
- package/test/chain/xrp.test.ts +30 -0
- package/test/expressapp.test.ts +26 -0
- package/test/integration/externalservices/simplex.test.ts +141 -19
- package/test/integration/server.test.ts +94 -0
- package/test/integration/tss.test.ts +67 -0
- package/test/v8.test.ts +32 -0
- package/ts_build/package.json +3 -3
- package/ts_build/src/externalservices/simplex.d.ts +1 -1
- package/ts_build/src/externalservices/simplex.d.ts.map +1 -1
- package/ts_build/src/externalservices/simplex.js +11 -27
- package/ts_build/src/externalservices/simplex.js.map +1 -1
- package/ts_build/src/lib/blockchainexplorers/v8/client.d.ts +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.d.ts.map +1 -1
- package/ts_build/src/lib/blockchainexplorers/v8/client.js +13 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.js.map +1 -1
- package/ts_build/src/lib/blockchainexplorers/v8.d.ts +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8.d.ts.map +1 -1
- package/ts_build/src/lib/blockchainexplorers/v8.js +10 -0
- package/ts_build/src/lib/blockchainexplorers/v8.js.map +1 -1
- package/ts_build/src/lib/chain/btc/index.d.ts +2 -1
- package/ts_build/src/lib/chain/btc/index.d.ts.map +1 -1
- package/ts_build/src/lib/chain/btc/index.js +3 -0
- package/ts_build/src/lib/chain/btc/index.js.map +1 -1
- package/ts_build/src/lib/chain/eth/index.d.ts +1 -0
- package/ts_build/src/lib/chain/eth/index.d.ts.map +1 -1
- package/ts_build/src/lib/chain/eth/index.js +3 -0
- package/ts_build/src/lib/chain/eth/index.js.map +1 -1
- package/ts_build/src/lib/chain/index.d.ts +1 -0
- package/ts_build/src/lib/chain/index.d.ts.map +1 -1
- package/ts_build/src/lib/chain/index.js +3 -0
- package/ts_build/src/lib/chain/index.js.map +1 -1
- package/ts_build/src/lib/chain/sol/index.d.ts +1 -0
- package/ts_build/src/lib/chain/sol/index.d.ts.map +1 -1
- package/ts_build/src/lib/chain/sol/index.js +5 -0
- package/ts_build/src/lib/chain/sol/index.js.map +1 -1
- package/ts_build/src/lib/chain/xrp/index.d.ts +1 -0
- package/ts_build/src/lib/chain/xrp/index.d.ts.map +1 -1
- package/ts_build/src/lib/chain/xrp/index.js +4 -0
- package/ts_build/src/lib/chain/xrp/index.js.map +1 -1
- package/ts_build/src/lib/common/index.d.ts +2 -0
- package/ts_build/src/lib/common/index.d.ts.map +1 -1
- package/ts_build/src/lib/common/utils.d.ts +4 -0
- package/ts_build/src/lib/common/utils.d.ts.map +1 -1
- package/ts_build/src/lib/common/utils.js +33 -0
- package/ts_build/src/lib/common/utils.js.map +1 -1
- package/ts_build/src/lib/routes/middleware/authTssRequest.js +1 -1
- package/ts_build/src/lib/routes/middleware/authTssRequest.js.map +1 -1
- package/ts_build/src/lib/routes/services.d.ts.map +1 -1
- package/ts_build/src/lib/routes/services.js +1 -13
- package/ts_build/src/lib/routes/services.js.map +1 -1
- package/ts_build/src/lib/routes/walletdata.d.ts.map +1 -1
- package/ts_build/src/lib/routes/walletdata.js +12 -0
- package/ts_build/src/lib/routes/walletdata.js.map +1 -1
- package/ts_build/src/lib/server.d.ts +1 -0
- package/ts_build/src/lib/server.d.ts.map +1 -1
- package/ts_build/src/lib/server.js +32 -1
- package/ts_build/src/lib/server.js.map +1 -1
- package/ts_build/test/chain/sol.test.d.ts +2 -0
- package/ts_build/test/chain/sol.test.d.ts.map +1 -0
- package/ts_build/test/chain/sol.test.js +78 -0
- package/ts_build/test/chain/sol.test.js.map +1 -0
- package/ts_build/test/chain/xrp.test.js +28 -0
- package/ts_build/test/chain/xrp.test.js.map +1 -1
- package/ts_build/test/expressapp.test.js +25 -0
- package/ts_build/test/expressapp.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/simplex.test.js +130 -15
- package/ts_build/test/integration/externalservices/simplex.test.js.map +1 -1
- package/ts_build/test/integration/server.test.js +80 -0
- package/ts_build/test/integration/server.test.js.map +1 -1
- package/ts_build/test/integration/tss.test.js +57 -0
- package/ts_build/test/integration/tss.test.js.map +1 -1
- package/ts_build/test/v8.test.js +30 -0
- package/ts_build/test/v8.test.js.map +1 -1
|
@@ -48,6 +48,7 @@ const config_1 = __importDefault(require("../../src/config"));
|
|
|
48
48
|
const server_1 = require("../../src/lib/server");
|
|
49
49
|
const storage_1 = require("../../src/lib/storage");
|
|
50
50
|
const common_1 = require("../../src/lib/common");
|
|
51
|
+
const logger_1 = __importDefault(require("../../src/lib/logger"));
|
|
51
52
|
const Model = __importStar(require("../../src/lib/model"));
|
|
52
53
|
const tsskeygen_1 = require("../../src/lib/model/tsskeygen");
|
|
53
54
|
const bchaddresstranslator_1 = require("../../src/lib/bchaddresstranslator");
|
|
@@ -8109,6 +8110,73 @@ describe('Wallet service', function () {
|
|
|
8109
8110
|
result.nonce.should.be.a('number');
|
|
8110
8111
|
result.nonce.should.equal(5);
|
|
8111
8112
|
});
|
|
8113
|
+
describe('prePublishRaw binding (isPrePublishRawBound)', function () {
|
|
8114
|
+
const ATTACKER_ADDR = '0x1111111111111111111111111111111111111111';
|
|
8115
|
+
it('accepts prePublishRaw when only the mutable field (nonce) changed', async function () {
|
|
8116
|
+
blockchainExplorer.getTransactionCount = sinon_1.default.stub().callsArgWith(1, null, '42');
|
|
8117
|
+
const created = await helpers_1.default.createAndPublishTx(server, {
|
|
8118
|
+
outputs: [{ toAddress: ETH_ADDR, amount: 8000 }],
|
|
8119
|
+
feePerKb: 123e2, from: fromAddr, deferNonce: true
|
|
8120
|
+
}, TestData.copayers[0].privKey_1H_0);
|
|
8121
|
+
await util_1.default.promisify(server.prepareTx).call(server, { txProposalId: created.id });
|
|
8122
|
+
const withNonce = await util_1.default.promisify(server.getTx).call(server, { txProposalId: created.id });
|
|
8123
|
+
should.exist(withNonce.prePublishRaw);
|
|
8124
|
+
withNonce.nonce.should.equal(42);
|
|
8125
|
+
index_1.ChainService.isPrePublishRawBound(withNonce).should.equal(true);
|
|
8126
|
+
});
|
|
8127
|
+
it('rejects prePublishRaw when the destination was tampered', async function () {
|
|
8128
|
+
const created = await helpers_1.default.createAndPublishTx(server, {
|
|
8129
|
+
outputs: [{ toAddress: ETH_ADDR, amount: 8000 }],
|
|
8130
|
+
feePerKb: 123e2, from: fromAddr, deferNonce: true
|
|
8131
|
+
}, TestData.copayers[0].privKey_1H_0);
|
|
8132
|
+
const txp = await util_1.default.promisify(server.getTx).call(server, { txProposalId: created.id });
|
|
8133
|
+
should.exist(txp.prePublishRaw);
|
|
8134
|
+
index_1.ChainService.isPrePublishRawBound(txp).should.equal(true);
|
|
8135
|
+
txp.outputs[0].toAddress = ATTACKER_ADDR;
|
|
8136
|
+
index_1.ChainService.isPrePublishRawBound(txp).should.equal(false);
|
|
8137
|
+
});
|
|
8138
|
+
it('rejects a prePublishRaw that holds no usable raw tx', async function () {
|
|
8139
|
+
const created = await helpers_1.default.createAndPublishTx(server, {
|
|
8140
|
+
outputs: [{ toAddress: ETH_ADDR, amount: 8000 }],
|
|
8141
|
+
feePerKb: 123e2, from: fromAddr, deferNonce: true
|
|
8142
|
+
}, TestData.copayers[0].privKey_1H_0);
|
|
8143
|
+
const txp = await util_1.default.promisify(server.getTx).call(server, { txProposalId: created.id });
|
|
8144
|
+
const warn = sinon_1.default.spy(logger_1.default, 'warn');
|
|
8145
|
+
try {
|
|
8146
|
+
for (const prePublishRaw of [[], [''], ['', '']]) {
|
|
8147
|
+
txp.prePublishRaw = prePublishRaw;
|
|
8148
|
+
index_1.ChainService.isPrePublishRawBound(txp).should.equal(false);
|
|
8149
|
+
}
|
|
8150
|
+
warn.called.should.equal(false);
|
|
8151
|
+
}
|
|
8152
|
+
finally {
|
|
8153
|
+
warn.restore();
|
|
8154
|
+
}
|
|
8155
|
+
});
|
|
8156
|
+
it('rejects the publishTx fallback when the stored proposal was tampered', async function () {
|
|
8157
|
+
blockchainExplorer.getTransactionCount = sinon_1.default.stub().callsArgWith(1, null, '7');
|
|
8158
|
+
const created = await util_1.default.promisify(server.createTx).call(server, {
|
|
8159
|
+
outputs: [{ toAddress: ETH_ADDR, amount: 8000 }],
|
|
8160
|
+
feePerKb: 123e2, from: fromAddr, deferNonce: true
|
|
8161
|
+
});
|
|
8162
|
+
const publishOpts = helpers_1.default.getProposalSignatureOpts(created, TestData.copayers[0].privKey_1H_0);
|
|
8163
|
+
await util_1.default.promisify(server.publishTx).call(server, publishOpts);
|
|
8164
|
+
await util_1.default.promisify(server.prepareTx).call(server, { txProposalId: created.id });
|
|
8165
|
+
const stored = await util_1.default.promisify(server.storage.fetchTx).call(server.storage, wallet.id, created.id);
|
|
8166
|
+
should.exist(stored.prePublishRaw);
|
|
8167
|
+
stored.outputs[0].toAddress = ATTACKER_ADDR;
|
|
8168
|
+
await util_1.default.promisify(server.storage.storeTx).call(server.storage, wallet.id, stored);
|
|
8169
|
+
let err;
|
|
8170
|
+
try {
|
|
8171
|
+
await util_1.default.promisify(server.publishTx).call(server, publishOpts);
|
|
8172
|
+
}
|
|
8173
|
+
catch (e) {
|
|
8174
|
+
err = e;
|
|
8175
|
+
}
|
|
8176
|
+
should.exist(err);
|
|
8177
|
+
err.message.should.contain('Invalid proposal signature');
|
|
8178
|
+
});
|
|
8179
|
+
});
|
|
8112
8180
|
});
|
|
8113
8181
|
describe('#prepareTx XRP (deferred nonce)', function () {
|
|
8114
8182
|
const XRP_ADDR = 'rDzTZxa7NwD9vmNf5dvTbW4FQDNSRsfPv6';
|
|
@@ -8185,6 +8253,18 @@ describe('Wallet service', function () {
|
|
|
8185
8253
|
});
|
|
8186
8254
|
signed.status.should.equal('accepted');
|
|
8187
8255
|
});
|
|
8256
|
+
it('rejects prePublishRaw binding when an XRP destination was tampered', async function () {
|
|
8257
|
+
const ATTACKER_XRP = 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe';
|
|
8258
|
+
const created = await helpers_1.default.createAndPublishTx(server, {
|
|
8259
|
+
outputs: [{ toAddress: XRP_ADDR, amount: 8000 }],
|
|
8260
|
+
feePerKb: 123e2, from: fromAddr, deferNonce: true
|
|
8261
|
+
}, TestData.copayers[0].privKey_1H_0);
|
|
8262
|
+
const txp = await util_1.default.promisify(server.getTx).call(server, { txProposalId: created.id });
|
|
8263
|
+
should.exist(txp.prePublishRaw);
|
|
8264
|
+
index_1.ChainService.isPrePublishRawBound(txp).should.equal(true);
|
|
8265
|
+
txp.outputs[0].toAddress = ATTACKER_XRP;
|
|
8266
|
+
index_1.ChainService.isPrePublishRawBound(txp).should.equal(false);
|
|
8267
|
+
});
|
|
8188
8268
|
});
|
|
8189
8269
|
describe('#signTx nonce override', function () {
|
|
8190
8270
|
const ETH_ADDR = '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A';
|