@bitpay-labs/bitcore-wallet-service 11.11.0 → 11.11.2
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/Dockerfile +1 -1
- package/package.json +5 -5
- package/src/config.ts +0 -20
- package/src/externalservices/banxa.ts +51 -10
- package/src/externalservices/changelly.ts +54 -6
- package/src/externalservices/moonpay.ts +85 -19
- package/src/externalservices/oneInch.ts +13 -5
- package/src/externalservices/ramp.ts +42 -8
- package/src/externalservices/sardine.ts +51 -10
- package/src/externalservices/simplex.ts +58 -11
- package/src/externalservices/thorswap.ts +46 -11
- package/src/externalservices/transak.ts +53 -11
- package/src/lib/chain/btc/index.ts +3 -2
- package/src/lib/chain/eth/index.ts +134 -117
- package/src/lib/chain/sol/index.ts +1 -1
- package/src/lib/chain/xrp/index.ts +1 -1
- package/src/lib/routes/services.ts +0 -12
- package/src/lib/routes/wallets.ts +3 -1
- package/src/lib/server.ts +136 -91
- package/src/lib/storage.ts +90 -20
- package/src/types/externalservices.d.ts +0 -1
- package/test/chain/eth.test.ts +70 -0
- package/test/chain/sol.test.ts +1 -1
- package/test/chain/xrp.test.ts +1 -1
- package/test/expressapp.test.ts +144 -0
- package/test/integration/addressReads.test.ts +503 -0
- package/test/integration/bcmonitor.test.ts +44 -0
- package/test/integration/externalservices/banxa.test.ts +95 -5
- package/test/integration/externalservices/changelly.test.ts +118 -6
- package/test/integration/externalservices/coinGecko.test.ts +4 -0
- package/test/integration/externalservices/moonpay.test.ts +178 -9
- package/test/integration/externalservices/oneInch.test.ts +28 -1
- package/test/integration/externalservices/ramp.test.ts +126 -4
- package/test/integration/externalservices/sardine.test.ts +95 -5
- package/test/integration/externalservices/simplex.test.ts +95 -5
- package/test/integration/externalservices/thorswap.test.ts +81 -5
- package/test/integration/externalservices/transak.test.ts +98 -6
- package/test/integration/helpers.ts +1 -1
- package/test/integration/server.test.ts +254 -136
- package/test/integration/walletReads.test.ts +488 -0
- package/ts_build/package.json +3 -3
- package/ts_build/src/config.d.ts.map +1 -1
- package/ts_build/src/config.js +0 -4
- package/ts_build/src/config.js.map +1 -1
- package/ts_build/src/externalservices/banxa.d.ts.map +1 -1
- package/ts_build/src/externalservices/banxa.js +51 -10
- package/ts_build/src/externalservices/banxa.js.map +1 -1
- package/ts_build/src/externalservices/changelly.d.ts.map +1 -1
- package/ts_build/src/externalservices/changelly.js +54 -6
- package/ts_build/src/externalservices/changelly.js.map +1 -1
- package/ts_build/src/externalservices/moonpay.d.ts.map +1 -1
- package/ts_build/src/externalservices/moonpay.js +85 -19
- package/ts_build/src/externalservices/moonpay.js.map +1 -1
- package/ts_build/src/externalservices/oneInch.d.ts.map +1 -1
- package/ts_build/src/externalservices/oneInch.js +13 -5
- package/ts_build/src/externalservices/oneInch.js.map +1 -1
- package/ts_build/src/externalservices/ramp.d.ts.map +1 -1
- package/ts_build/src/externalservices/ramp.js +42 -8
- package/ts_build/src/externalservices/ramp.js.map +1 -1
- package/ts_build/src/externalservices/sardine.d.ts.map +1 -1
- package/ts_build/src/externalservices/sardine.js +51 -10
- package/ts_build/src/externalservices/sardine.js.map +1 -1
- package/ts_build/src/externalservices/simplex.d.ts.map +1 -1
- package/ts_build/src/externalservices/simplex.js +55 -11
- package/ts_build/src/externalservices/simplex.js.map +1 -1
- package/ts_build/src/externalservices/thorswap.d.ts.map +1 -1
- package/ts_build/src/externalservices/thorswap.js +45 -11
- package/ts_build/src/externalservices/thorswap.js.map +1 -1
- package/ts_build/src/externalservices/transak.d.ts.map +1 -1
- package/ts_build/src/externalservices/transak.js +53 -11
- package/ts_build/src/externalservices/transak.js.map +1 -1
- package/ts_build/src/lib/chain/btc/index.d.ts.map +1 -1
- package/ts_build/src/lib/chain/btc/index.js +3 -2
- package/ts_build/src/lib/chain/btc/index.js.map +1 -1
- package/ts_build/src/lib/chain/eth/index.d.ts +8 -1
- package/ts_build/src/lib/chain/eth/index.d.ts.map +1 -1
- package/ts_build/src/lib/chain/eth/index.js +114 -102
- package/ts_build/src/lib/chain/eth/index.js.map +1 -1
- package/ts_build/src/lib/chain/sol/index.js +1 -1
- package/ts_build/src/lib/chain/sol/index.js.map +1 -1
- package/ts_build/src/lib/chain/xrp/index.js +1 -1
- package/ts_build/src/lib/chain/xrp/index.js.map +1 -1
- package/ts_build/src/lib/routes/services.d.ts.map +1 -1
- package/ts_build/src/lib/routes/services.js +0 -10
- package/ts_build/src/lib/routes/services.js.map +1 -1
- package/ts_build/src/lib/routes/wallets.d.ts.map +1 -1
- package/ts_build/src/lib/routes/wallets.js +2 -1
- package/ts_build/src/lib/routes/wallets.js.map +1 -1
- package/ts_build/src/lib/server.d.ts +1 -3
- package/ts_build/src/lib/server.d.ts.map +1 -1
- package/ts_build/src/lib/server.js +128 -96
- package/ts_build/src/lib/server.js.map +1 -1
- package/ts_build/src/lib/storage.d.ts +17 -10
- package/ts_build/src/lib/storage.d.ts.map +1 -1
- package/ts_build/src/lib/storage.js +73 -20
- package/ts_build/src/lib/storage.js.map +1 -1
- package/ts_build/test/chain/eth.test.js +59 -0
- package/ts_build/test/chain/eth.test.js.map +1 -1
- package/ts_build/test/chain/sol.test.js +1 -1
- package/ts_build/test/chain/sol.test.js.map +1 -1
- package/ts_build/test/chain/xrp.test.js +1 -1
- package/ts_build/test/chain/xrp.test.js.map +1 -1
- package/ts_build/test/expressapp.test.js +132 -0
- package/ts_build/test/expressapp.test.js.map +1 -1
- package/ts_build/test/integration/addressReads.test.d.ts +2 -0
- package/ts_build/test/integration/addressReads.test.d.ts.map +1 -0
- package/ts_build/test/integration/addressReads.test.js +465 -0
- package/ts_build/test/integration/addressReads.test.js.map +1 -0
- package/ts_build/test/integration/bcmonitor.test.js +40 -0
- package/ts_build/test/integration/bcmonitor.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/banxa.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/banxa.test.js +93 -5
- package/ts_build/test/integration/externalservices/banxa.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/changelly.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/changelly.test.js +111 -6
- package/ts_build/test/integration/externalservices/changelly.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/coinGecko.test.js +4 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/moonpay.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/moonpay.test.js +169 -9
- package/ts_build/test/integration/externalservices/moonpay.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/oneInch.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/oneInch.test.js +26 -1
- package/ts_build/test/integration/externalservices/oneInch.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/ramp.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/ramp.test.js +115 -4
- package/ts_build/test/integration/externalservices/ramp.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/sardine.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/sardine.test.js +94 -5
- package/ts_build/test/integration/externalservices/sardine.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/simplex.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/simplex.test.js +89 -5
- package/ts_build/test/integration/externalservices/simplex.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/thorswap.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/thorswap.test.js +76 -5
- package/ts_build/test/integration/externalservices/thorswap.test.js.map +1 -1
- package/ts_build/test/integration/externalservices/transak.test.d.ts.map +1 -1
- package/ts_build/test/integration/externalservices/transak.test.js +93 -6
- package/ts_build/test/integration/externalservices/transak.test.js.map +1 -1
- package/ts_build/test/integration/helpers.js +1 -1
- package/ts_build/test/integration/helpers.js.map +1 -1
- package/ts_build/test/integration/server.test.js +225 -124
- package/ts_build/test/integration/server.test.js.map +1 -1
- package/ts_build/test/integration/walletReads.test.d.ts +2 -0
- package/ts_build/test/integration/walletReads.test.d.ts.map +1 -0
- package/ts_build/test/integration/walletReads.test.js +436 -0
- package/ts_build/test/integration/walletReads.test.js.map +1 -0
- package/src/externalservices/wyre.ts +0 -131
- package/test/integration/externalservices/wyre.test.ts +0 -270
- package/ts_build/src/externalservices/wyre.d.ts +0 -7
- package/ts_build/src/externalservices/wyre.d.ts.map +0 -1
- package/ts_build/src/externalservices/wyre.js +0 -144
- package/ts_build/src/externalservices/wyre.js.map +0 -1
- package/ts_build/test/integration/externalservices/wyre.test.d.ts +0 -2
- package/ts_build/test/integration/externalservices/wyre.test.d.ts.map +0 -1
- package/ts_build/test/integration/externalservices/wyre.test.js +0 -281
- package/ts_build/test/integration/externalservices/wyre.test.js.map +0 -1
|
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const chai = __importStar(require("chai"));
|
|
40
40
|
require("chai/register-should");
|
|
41
41
|
const util_1 = __importDefault(require("util"));
|
|
42
|
+
const assert_1 = __importDefault(require("assert"));
|
|
42
43
|
const sinon_1 = __importDefault(require("sinon"));
|
|
43
44
|
const http_1 = __importDefault(require("http"));
|
|
44
45
|
const request_1 = __importDefault(require("request"));
|
|
@@ -2669,28 +2670,21 @@ describe('Wallet service', function () {
|
|
|
2669
2670
|
should.exist(address);
|
|
2670
2671
|
utxo.path.should.equal(address.path);
|
|
2671
2672
|
utxo.publicKeys.should.deep.equal(address.publicKeys);
|
|
2673
|
+
utxo.isChange.should.equal(false);
|
|
2672
2674
|
done();
|
|
2673
2675
|
});
|
|
2674
2676
|
});
|
|
2675
2677
|
});
|
|
2676
2678
|
});
|
|
2677
|
-
it('should
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
const address = addresses.find(a => a.address === utxo.address);
|
|
2687
|
-
should.exist(address);
|
|
2688
|
-
utxo.path.should.equal(address.path);
|
|
2689
|
-
utxo.publicKeys.should.deep.equal(address.publicKeys);
|
|
2690
|
-
done();
|
|
2691
|
-
});
|
|
2692
|
-
});
|
|
2693
|
-
});
|
|
2679
|
+
it('should identify UTXOs for change addresses', async function () {
|
|
2680
|
+
const address = await util_1.default.promisify(server.createAddress).call(server, { isChange: true });
|
|
2681
|
+
await helpers_1.default.stubUtxos(server, wallet, [1], { addresses: [address] });
|
|
2682
|
+
const utxos = await util_1.default.promisify(server.getUtxos).call(server, {});
|
|
2683
|
+
utxos.length.should.equal(1);
|
|
2684
|
+
utxos[0].address.should.equal(address.address);
|
|
2685
|
+
utxos[0].path.should.equal(address.path);
|
|
2686
|
+
utxos[0].publicKeys.should.deep.equal(address.publicKeys);
|
|
2687
|
+
utxos[0].isChange.should.equal(true);
|
|
2694
2688
|
});
|
|
2695
2689
|
it('should return empty UTXOs for specific addresses if network mismatch', function (done) {
|
|
2696
2690
|
helpers_1.default.stubUtxos(server, wallet, [1, 2, 3]).then(function (utxos) {
|
|
@@ -4542,7 +4536,6 @@ describe('Wallet service', function () {
|
|
|
4542
4536
|
toAddress: addressStr,
|
|
4543
4537
|
amount: ts,
|
|
4544
4538
|
}],
|
|
4545
|
-
gasPrice: 1,
|
|
4546
4539
|
feeLevel: level,
|
|
4547
4540
|
from: fromAddr,
|
|
4548
4541
|
}, flags);
|
|
@@ -5705,36 +5698,35 @@ describe('Wallet service', function () {
|
|
|
5705
5698
|
coin: 'eth',
|
|
5706
5699
|
}));
|
|
5707
5700
|
});
|
|
5708
|
-
it('should allow to create a TX with fee and no inputs', function (
|
|
5709
|
-
|
|
5710
|
-
server.createAddress(
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
});
|
|
5701
|
+
it('should allow to create a TX with fee and no inputs', async function () {
|
|
5702
|
+
const feeLevels = sinon_1.default.stub(server, 'getFeeLevels').callsArgWith(1, new Error('Unexpected fee estimation'));
|
|
5703
|
+
await util_1.default.promisify(server.createAddress).call(server, {});
|
|
5704
|
+
await helpers_1.default.stubUtxos(server, wallet, [1, 2]);
|
|
5705
|
+
const amount = 0.8 * 1e8;
|
|
5706
|
+
for (const fee of [252000000000000, '252000000000000']) {
|
|
5707
|
+
const txOpts = {
|
|
5708
|
+
outputs: [{
|
|
5709
|
+
toAddress: '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A',
|
|
5710
|
+
amount: amount,
|
|
5711
|
+
}],
|
|
5712
|
+
message: 'some message',
|
|
5713
|
+
customData: 'some custom data',
|
|
5714
|
+
fee,
|
|
5715
|
+
};
|
|
5716
|
+
const tx = await util_1.default.promisify(server.createTx).call(server, txOpts);
|
|
5717
|
+
should.exist(tx);
|
|
5718
|
+
tx.outputs.should.deep.equal([{
|
|
5719
|
+
toAddress: '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A',
|
|
5720
|
+
gasLimit: 21000,
|
|
5721
|
+
amount: amount,
|
|
5722
|
+
}]);
|
|
5723
|
+
tx.fee.should.equal(Number(fee));
|
|
5724
|
+
tx.gasPrice.should.equal(12000000000);
|
|
5725
|
+
(tx.gasPrice * tx.outputs[0].gasLimit).should.equal(Number(fee));
|
|
5726
|
+
const [raw] = tx.getRawTx();
|
|
5727
|
+
CWC.ethers.Transaction.from(raw).gasPrice.should.equal(12000000000n);
|
|
5728
|
+
}
|
|
5729
|
+
feeLevels.called.should.be.false;
|
|
5738
5730
|
});
|
|
5739
5731
|
it('should allow to create a TX with multiple outputs and set the correct fee', function (done) {
|
|
5740
5732
|
helpers_1.default.stubFeeLevels({});
|
|
@@ -5799,6 +5791,147 @@ describe('Wallet service', function () {
|
|
|
5799
5791
|
});
|
|
5800
5792
|
});
|
|
5801
5793
|
});
|
|
5794
|
+
describe('#createTX EVM gas overrides', function () {
|
|
5795
|
+
let server;
|
|
5796
|
+
let wallet;
|
|
5797
|
+
const destination = '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A';
|
|
5798
|
+
const makeOpts = (overrides = {}) => ({
|
|
5799
|
+
outputs: [{ toAddress: destination, amount: 1000000, gasLimit: 100000 }],
|
|
5800
|
+
nonce: 1,
|
|
5801
|
+
...overrides
|
|
5802
|
+
});
|
|
5803
|
+
beforeEach(async function () {
|
|
5804
|
+
({ server, wallet } = await helpers_1.default.createAndJoinWallet(1, 1, { coin: 'eth' }));
|
|
5805
|
+
await util_1.default.promisify(server.createAddress).call(server, {});
|
|
5806
|
+
await helpers_1.default.stubUtxos(server, wallet, [1]);
|
|
5807
|
+
});
|
|
5808
|
+
for (const scenario of [
|
|
5809
|
+
{ name: 'type 0', fees: { gasPrice: 3000000000 }, tokenAddress: undefined },
|
|
5810
|
+
{ name: 'type 0 token', fees: { gasPrice: 3000000000 }, tokenAddress: TOKENS[0] },
|
|
5811
|
+
{ name: 'type 2 native', fees: { txType: 2, maxGasFee: 3000000000, priorityGasFee: 1000000000 }, tokenAddress: undefined },
|
|
5812
|
+
{ name: 'type 2 token', fees: { txType: 2, maxGasFee: 3000000000, priorityGasFee: 1000000000 }, tokenAddress: TOKENS[0] }
|
|
5813
|
+
]) {
|
|
5814
|
+
it(`should preserve ${scenario.name} overrides through publication, signing and broadcast`, async function () {
|
|
5815
|
+
const feeLevels = sinon_1.default.stub(server, 'getFeeLevels').callsArgWith(1, new Error('Unexpected fee estimation'));
|
|
5816
|
+
const maxFee = sinon_1.default.stub(server, 'estimateFee').rejects(new Error('Unexpected fee estimation'));
|
|
5817
|
+
const priorityFee = sinon_1.default.stub(server, 'estimatePriorityFee').rejects(new Error('Unexpected fee estimation'));
|
|
5818
|
+
const txp = await util_1.default.promisify(server.createTx).call(server, makeOpts({
|
|
5819
|
+
...scenario.fees, tokenAddress: scenario.tokenAddress, feeLevel: 'economy'
|
|
5820
|
+
}));
|
|
5821
|
+
await util_1.default.promisify(server.publishTx).call(server, helpers_1.default.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0));
|
|
5822
|
+
await util_1.default.promisify(server.signTx).call(server, {
|
|
5823
|
+
txProposalId: txp.id,
|
|
5824
|
+
signatures: helpers_1.default.clientSign(txp, TestData.copayers[0].xPrivKey_44H_0H_0H)
|
|
5825
|
+
});
|
|
5826
|
+
const accepted = await util_1.default.promisify(server.getTx).call(server, { txProposalId: txp.id });
|
|
5827
|
+
accepted.status.should.equal('accepted');
|
|
5828
|
+
const signedRaw = accepted.getRawTx();
|
|
5829
|
+
helpers_1.default.stubBroadcast(accepted.txid);
|
|
5830
|
+
await util_1.default.promisify(server.broadcastTx).call(server, { txProposalId: txp.id });
|
|
5831
|
+
blockchainExplorer.broadcast.calledOnce.should.be.true;
|
|
5832
|
+
blockchainExplorer.broadcast.firstCall.args[0].should.deep.equal(signedRaw);
|
|
5833
|
+
const stored = await util_1.default.promisify(server.getTx).call(server, { txProposalId: txp.id });
|
|
5834
|
+
stored.status.should.equal('broadcasted');
|
|
5835
|
+
stored.txid.should.equal(accepted.txid);
|
|
5836
|
+
should.not.exist(stored.feeLevel);
|
|
5837
|
+
stored.fee.should.equal(300000000000000);
|
|
5838
|
+
for (const [key, value] of Object.entries(scenario.fees)) {
|
|
5839
|
+
stored[key].should.equal(value);
|
|
5840
|
+
}
|
|
5841
|
+
const [raw] = stored.getRawTx();
|
|
5842
|
+
const tx = CWC.ethers.Transaction.from(raw);
|
|
5843
|
+
tx.isSigned().should.be.true;
|
|
5844
|
+
tx.type.should.equal(scenario.fees.txType || 0);
|
|
5845
|
+
if (scenario.fees.txType === 2) {
|
|
5846
|
+
tx.maxFeePerGas.should.equal(3000000000n);
|
|
5847
|
+
tx.maxPriorityFeePerGas.should.equal(1000000000n);
|
|
5848
|
+
}
|
|
5849
|
+
else {
|
|
5850
|
+
tx.gasPrice.should.equal(3000000000n);
|
|
5851
|
+
}
|
|
5852
|
+
feeLevels.called.should.be.false;
|
|
5853
|
+
maxFee.called.should.be.false;
|
|
5854
|
+
priorityFee.called.should.be.false;
|
|
5855
|
+
});
|
|
5856
|
+
}
|
|
5857
|
+
it('should preserve a zero priority fee estimated for ARB', async function () {
|
|
5858
|
+
({ server, wallet } = await helpers_1.default.createAndJoinWallet(1, 1, { coin: 'arb' }));
|
|
5859
|
+
await util_1.default.promisify(server.createAddress).call(server, {});
|
|
5860
|
+
sinon_1.default.replace(blockchainExplorer, 'getBalance', sinon_1.default.stub().callsArgWith(1, null, { confirmed: 1e18, unconfirmed: 0, balance: 1e18 }));
|
|
5861
|
+
helpers_1.default.stubFeeLevels({});
|
|
5862
|
+
sinon_1.default.stub(server, 'estimateFee').resolves(3000000000);
|
|
5863
|
+
sinon_1.default.stub(server, 'estimatePriorityFee').resolves(0);
|
|
5864
|
+
const txp = await util_1.default.promisify(server.createTx).call(server, makeOpts({ txType: 2 }));
|
|
5865
|
+
txp.priorityGasFee.should.equal(0);
|
|
5866
|
+
const [raw] = txp.getRawTx();
|
|
5867
|
+
CWC.ethers.Transaction.from(raw).maxPriorityFeePerGas.should.equal(0n);
|
|
5868
|
+
});
|
|
5869
|
+
it('should preserve automatic type 2 fee estimation without overrides', async function () {
|
|
5870
|
+
helpers_1.default.stubFeeLevels({});
|
|
5871
|
+
sinon_1.default.stub(server, 'estimateFee').resolves(4500000000);
|
|
5872
|
+
sinon_1.default.stub(server, 'estimatePriorityFee').resolves(1000000000);
|
|
5873
|
+
const txp = await util_1.default.promisify(server.createTx).call(server, makeOpts({ txType: 2 }));
|
|
5874
|
+
txp.feeLevel.should.equal('normal');
|
|
5875
|
+
txp.gasPrice.should.equal(1000000000);
|
|
5876
|
+
txp.fee.should.equal(100000000000000);
|
|
5877
|
+
txp.maxGasFee.should.equal(4500000000);
|
|
5878
|
+
txp.priorityGasFee.should.equal(1000000000);
|
|
5879
|
+
const [raw] = txp.getRawTx();
|
|
5880
|
+
const tx = CWC.ethers.Transaction.from(raw);
|
|
5881
|
+
tx.maxFeePerGas.should.equal(4500000000n);
|
|
5882
|
+
tx.maxPriorityFeePerGas.should.equal(1000000000n);
|
|
5883
|
+
});
|
|
5884
|
+
it('should enforce the existing MATIC minimum for explicit priority fees', async function () {
|
|
5885
|
+
({ server, wallet } = await helpers_1.default.createAndJoinWallet(1, 1, { coin: 'matic' }));
|
|
5886
|
+
await util_1.default.promisify(server.createAddress).call(server, {});
|
|
5887
|
+
sinon_1.default.replace(blockchainExplorer, 'getBalance', sinon_1.default.stub().callsArgWith(1, null, { confirmed: 1e18, unconfirmed: 0, balance: 1e18 }));
|
|
5888
|
+
const fees = { txType: 2, maxGasFee: 40000000000, priorityGasFee: 30000000000 };
|
|
5889
|
+
await assert_1.default.rejects(util_1.default.promisify(server.createTx).call(server, makeOpts({ ...fees, priorityGasFee: fees.priorityGasFee - 1 })), {
|
|
5890
|
+
message: 'priorityGasFee must be at least 30000000000 wei for matic'
|
|
5891
|
+
});
|
|
5892
|
+
const txp = await util_1.default.promisify(server.createTx).call(server, makeOpts(fees));
|
|
5893
|
+
const [raw] = txp.getRawTx();
|
|
5894
|
+
CWC.ethers.Transaction.from(raw).maxPriorityFeePerGas.should.equal(30000000000n);
|
|
5895
|
+
txp.fee.should.equal(fees.maxGasFee * 100000);
|
|
5896
|
+
});
|
|
5897
|
+
it('should reject invalid or conflicting gas overrides', async function () {
|
|
5898
|
+
const requests = [
|
|
5899
|
+
...[
|
|
5900
|
+
{ key: 'gasPrice', values: [0, 1.5, '1000', Number.MAX_SAFE_INTEGER + 1] },
|
|
5901
|
+
{ key: 'maxGasFee', values: [0] },
|
|
5902
|
+
{ key: 'priorityGasFee', values: [0] }
|
|
5903
|
+
].flatMap(({ key, values }) => values.map(value => ({
|
|
5904
|
+
params: { [key]: value }, message: `${key} must be a positive safe integer in wei`
|
|
5905
|
+
}))),
|
|
5906
|
+
{ params: { gasPrice: 1000, txType: 2 }, message: 'gasPrice requires a type 0 transaction' },
|
|
5907
|
+
{ params: { maxGasFee: 1000 }, message: 'maxGasFee and priorityGasFee require a type 2 transaction' },
|
|
5908
|
+
{ params: { priorityGasFee: 1000, txType: 0 }, message: 'maxGasFee and priorityGasFee require a type 2 transaction' },
|
|
5909
|
+
{ params: { maxGasFee: 1000, txType: 2 }, message: 'maxGasFee and priorityGasFee must be supplied together' },
|
|
5910
|
+
{ params: { priorityGasFee: 1000, txType: 2 }, message: 'maxGasFee and priorityGasFee must be supplied together' },
|
|
5911
|
+
{ params: { gasPrice: 1000, feePerKb: 1000 }, message: 'Gas fee overrides cannot be combined with feePerKb or fee' },
|
|
5912
|
+
{ params: { gasPrice: 1000, fee: 1000 }, message: 'Gas fee overrides cannot be combined with feePerKb or fee' },
|
|
5913
|
+
{ params: { gasPrice: 1000, sendMax: true }, message: 'Gas fee overrides are not supported with sendMax' },
|
|
5914
|
+
{ params: { txType: 2, maxGasFee: 1000, priorityGasFee: 2000 }, message: 'priorityGasFee must not exceed maxGasFee' }
|
|
5915
|
+
];
|
|
5916
|
+
for (const { params, message } of requests) {
|
|
5917
|
+
await assert_1.default.rejects(util_1.default.promisify(server.createTx).call(server, makeOpts(params)), { message });
|
|
5918
|
+
}
|
|
5919
|
+
await assert_1.default.rejects(util_1.default.promisify(server._validateAndSanitizeTxOpts).call(server, { ...wallet, chain: 'btc' }, makeOpts({ gasPrice: 1000 })), {
|
|
5920
|
+
message: 'Gas fee overrides are only supported for EVM chains'
|
|
5921
|
+
});
|
|
5922
|
+
});
|
|
5923
|
+
for (const tokenAddress of [undefined, TOKENS[0]]) {
|
|
5924
|
+
it(`should reserve the overridden fee for ${tokenAddress ? 'token' : 'native'} proposals`, async function () {
|
|
5925
|
+
helpers_1.default.stubFeeLevels({});
|
|
5926
|
+
await helpers_1.default.stubUtxos(server, wallet, [0.0002]);
|
|
5927
|
+
const defaultTxp = await util_1.default.promisify(server.createTx).call(server, makeOpts({ tokenAddress }));
|
|
5928
|
+
defaultTxp.fee.should.equal(100000000000000);
|
|
5929
|
+
await assert_1.default.rejects(util_1.default.promisify(server.createTx).call(server, makeOpts({
|
|
5930
|
+
txType: 2, maxGasFee: 3000000000, priorityGasFee: 1000000000, tokenAddress
|
|
5931
|
+
})), { code: tokenAddress ? 'INSUFFICIENT_ETH_FEE' : 'INSUFFICIENT_FUNDS_FOR_FEE' });
|
|
5932
|
+
});
|
|
5933
|
+
}
|
|
5934
|
+
});
|
|
5802
5935
|
describe('cashAddr backwards compat', function () {
|
|
5803
5936
|
it('should create a BCH tx proposal with cashaddr outputs (w/o prefix) and return Copay addr', function (done) {
|
|
5804
5937
|
const copayAddr = 'CPrtPWbp8cCftTQu5fzuLG5zPJNDHMMf8X';
|
|
@@ -7154,39 +7287,27 @@ describe('Wallet service', function () {
|
|
|
7154
7287
|
}],
|
|
7155
7288
|
},
|
|
7156
7289
|
];
|
|
7157
|
-
function checkTx(txOpts, x
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
if (++copayerM == x.m) {
|
|
7167
|
-
return cb(txp);
|
|
7168
|
-
}
|
|
7169
|
-
else {
|
|
7170
|
-
return sign(copayerM, tx, cb);
|
|
7171
|
-
}
|
|
7172
|
-
});
|
|
7290
|
+
async function checkTx(txOpts, x) {
|
|
7291
|
+
const tx = await helpers_1.default.createAndPublishTx(server, txOpts, TestData.copayers[0].privKey_1H_0);
|
|
7292
|
+
let txp;
|
|
7293
|
+
for (let copayerM = 0; copayerM < x.m; copayerM++) {
|
|
7294
|
+
const authServer = await helpers_1.default.getAuthServer(wallet.copayers[copayerM].id);
|
|
7295
|
+
const signatures = helpers_1.default.clientSign(tx, TestData.copayers[copayerM].xPrivKey_44H_0H_0H);
|
|
7296
|
+
txp = await util_1.default.promisify(authServer.signTx).call(authServer, {
|
|
7297
|
+
txProposalId: tx.id,
|
|
7298
|
+
signatures: signatures,
|
|
7173
7299
|
});
|
|
7174
7300
|
}
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
feeRate.should.be.below(x.requiredFeeRate * 1.5);
|
|
7185
|
-
return cb(feeRate);
|
|
7186
|
-
});
|
|
7187
|
-
});
|
|
7301
|
+
should.exist(txp.raw);
|
|
7302
|
+
txp.status.should.equal('accepted');
|
|
7303
|
+
const t = index_1.ChainService.getBitcoreTx(txp);
|
|
7304
|
+
(txp.raw.length / 2).should.equal(t.size);
|
|
7305
|
+
const feeRate = t.getFee() / (x.fromSegwit ? t.vsize : t.size) * 1000;
|
|
7306
|
+
console.log(`Wire Size: ${t.size} vSize: ${t.vsize} (Segwit: ${x.fromSegwit}, SegwitVersion: ${x.segwitVersion || 0}) Fee:${t.getFee()} ActualRate:${Math.round(feeRate)} RequiredRate:${x.requiredFeeRate}`);
|
|
7307
|
+
feeRate.should.not.be.below(x.requiredFeeRate);
|
|
7308
|
+
feeRate.should.be.below(x.requiredFeeRate * 1.5);
|
|
7309
|
+
return feeRate;
|
|
7188
7310
|
}
|
|
7189
|
-
;
|
|
7190
7311
|
for (let i = 0; i < cases.length; i++) {
|
|
7191
7312
|
const x = cases[i];
|
|
7192
7313
|
x.i = i;
|
|
@@ -7214,7 +7335,7 @@ describe('Wallet service', function () {
|
|
|
7214
7335
|
else {
|
|
7215
7336
|
Object.assign(txOpts, { feePerKb: x.requiredFeeRate });
|
|
7216
7337
|
}
|
|
7217
|
-
const fee1 = await
|
|
7338
|
+
const fee1 = await checkTx(txOpts, x);
|
|
7218
7339
|
should.exist(fee1);
|
|
7219
7340
|
if (x.i == 8) {
|
|
7220
7341
|
await helpers_1.default.beforeEach();
|
|
@@ -7222,7 +7343,7 @@ describe('Wallet service', function () {
|
|
|
7222
7343
|
({ server, wallet } = await helpers_1.default.createAndJoinWallet(x.m, x.n, { useNativeSegwit: x.fromSegwit }));
|
|
7223
7344
|
await helpers_1.default.stubUtxos(server, wallet, x.utxos);
|
|
7224
7345
|
txOpts.payProUrl = null;
|
|
7225
|
-
const fee2 = await
|
|
7346
|
+
const fee2 = await checkTx(txOpts, x);
|
|
7226
7347
|
console.log(`## Fee PayPro: ${fee1} vs ${fee2}`);
|
|
7227
7348
|
fee1.should.be.above(fee2);
|
|
7228
7349
|
}
|
|
@@ -7291,43 +7412,31 @@ describe('Wallet service', function () {
|
|
|
7291
7412
|
}]
|
|
7292
7413
|
},
|
|
7293
7414
|
];
|
|
7294
|
-
function checkTx(txOpts, x
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
if (++copayerM == x.m) {
|
|
7304
|
-
return cb(txp);
|
|
7305
|
-
}
|
|
7306
|
-
else {
|
|
7307
|
-
return sign(copayerM, tx, cb);
|
|
7308
|
-
}
|
|
7309
|
-
});
|
|
7415
|
+
async function checkTx(txOpts, x) {
|
|
7416
|
+
const tx = await helpers_1.default.createAndPublishTx(server, txOpts, TestData.copayers[0].privKey_1H_0);
|
|
7417
|
+
let txp;
|
|
7418
|
+
for (let copayerM = 0; copayerM < x.m; copayerM++) {
|
|
7419
|
+
const authServer = await helpers_1.default.getAuthServer(wallet.copayers[copayerM].id);
|
|
7420
|
+
const signatures = helpers_1.default.clientSign(tx, TestData.copayers[copayerM].xPrivKey_44H_0H_0H);
|
|
7421
|
+
txp = await util_1.default.promisify(authServer.signTx).call(authServer, {
|
|
7422
|
+
txProposalId: tx.id,
|
|
7423
|
+
signatures: signatures,
|
|
7310
7424
|
});
|
|
7311
7425
|
}
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
}
|
|
7326
|
-
return cb(actualFeeRate);
|
|
7327
|
-
});
|
|
7328
|
-
});
|
|
7426
|
+
should.exist(txp.raw);
|
|
7427
|
+
txp.status.should.equal('accepted');
|
|
7428
|
+
const t = index_1.ChainService.getBitcoreTx(txp);
|
|
7429
|
+
const vSize = x.vSize || t._estimateSize();
|
|
7430
|
+
const actualSize = txp.raw.length / 2;
|
|
7431
|
+
const actualFeeRate = t.getFee() / (x.fromSegwit ? vSize : actualSize) * 1000;
|
|
7432
|
+
console.log(`Wire Size:${actualSize} vSize: ${vSize} (Segwit: ${x.fromSegwit}) Fee: ${t.getFee()} ActualRate:${Math.round(actualFeeRate)} RequiredRate:${x.requiredFeeRate}`);
|
|
7433
|
+
t.getFee().should.be.gte(CWC.BitcoreLibDoge.Transaction.DUST_AMOUNT);
|
|
7434
|
+
if (t.getFee() > CWC.BitcoreLibDoge.Transaction.DUST_AMOUNT) {
|
|
7435
|
+
actualFeeRate.should.not.be.below(x.requiredFeeRate);
|
|
7436
|
+
actualFeeRate.should.be.below(x.requiredFeeRate * 1.5);
|
|
7437
|
+
}
|
|
7438
|
+
return actualFeeRate;
|
|
7329
7439
|
}
|
|
7330
|
-
;
|
|
7331
7440
|
for (let i = 0; i < cases.length; i++) {
|
|
7332
7441
|
const x = cases[i];
|
|
7333
7442
|
x.i = i;
|
|
@@ -7355,7 +7464,7 @@ describe('Wallet service', function () {
|
|
|
7355
7464
|
else {
|
|
7356
7465
|
Object.assign(txOpts, { feePerKb: x.requiredFeeRate });
|
|
7357
7466
|
}
|
|
7358
|
-
const fee1 = await
|
|
7467
|
+
const fee1 = await checkTx(txOpts, x);
|
|
7359
7468
|
should.exist(fee1);
|
|
7360
7469
|
if (x.i == 8) {
|
|
7361
7470
|
await helpers_1.default.beforeEach();
|
|
@@ -7363,7 +7472,7 @@ describe('Wallet service', function () {
|
|
|
7363
7472
|
({ server, wallet } = await helpers_1.default.createAndJoinWallet(x.m, x.n, { useNativeSegwit: x.fromSegwit }));
|
|
7364
7473
|
await helpers_1.default.stubUtxos(server, wallet, x.utxos);
|
|
7365
7474
|
txOpts.payProUrl = null;
|
|
7366
|
-
const fee2 = await
|
|
7475
|
+
const fee2 = await checkTx(txOpts, x);
|
|
7367
7476
|
console.log(`## Fee PayPro: ${fee1} vs ${fee2}`);
|
|
7368
7477
|
fee1.should.be.above(fee2);
|
|
7369
7478
|
}
|
|
@@ -10661,10 +10770,6 @@ describe('Wallet service', function () {
|
|
|
10661
10770
|
simplex: {
|
|
10662
10771
|
disabled: false,
|
|
10663
10772
|
removed: false
|
|
10664
|
-
},
|
|
10665
|
-
wyre: {
|
|
10666
|
-
disabled: false,
|
|
10667
|
-
removed: false
|
|
10668
10773
|
}
|
|
10669
10774
|
},
|
|
10670
10775
|
sellCrypto: {
|
|
@@ -10750,10 +10855,6 @@ describe('Wallet service', function () {
|
|
|
10750
10855
|
transak: {
|
|
10751
10856
|
disabled: false,
|
|
10752
10857
|
removed: false
|
|
10753
|
-
},
|
|
10754
|
-
wyre: {
|
|
10755
|
-
disabled: false,
|
|
10756
|
-
removed: false
|
|
10757
10858
|
}
|
|
10758
10859
|
},
|
|
10759
10860
|
sellCrypto: {
|