diff --git a/CMakeLists.txt b/CMakeLists.txt index be76ab84e..71ddc31c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ set_target_properties( set(BOOST ${CMAKE_SOURCE_DIR}/build/boost) include_directories("${BOOST}") -include_directories("${BOOST}/include") # must exist already - run bin/build-boost-emscripten.sh +include_directories("${BOOST}/include") # must exist already - run bin/build_boost_emscripten.sh add_library(boost_chrono STATIC IMPORTED) set_target_properties( @@ -355,7 +355,7 @@ if (BUILD_MONERO_WALLET_FULL_WASM) boost_system boost_thread boost_serialization - #boost_filesystem + boost_filesystem boost_regex #boost_atomic # diff --git a/bin/build_boost_emscripten.sh b/bin/build_boost_emscripten.sh index 150615e47..1005bbd53 100755 --- a/bin/build_boost_emscripten.sh +++ b/bin/build_boost_emscripten.sh @@ -85,7 +85,7 @@ export NO_BZIP2=1 #bc it's supplied by emscripten but b2 will fail to find it ./bootstrap.sh \ - --with-libraries=system,thread,chrono,serialization,regex \ + --with-libraries=system,thread,chrono,serialization,regex,filesystem \ 2>&1 if [ $? != 0 ]; then diff --git a/external/monero-cpp b/external/monero-cpp index 3d7c01a8a..7d91986f5 160000 --- a/external/monero-cpp +++ b/external/monero-cpp @@ -1 +1 @@ -Subproject commit 3d7c01a8a85cad7794966d2f9aba0875be95cd3a +Subproject commit 7d91986f59bfd5cde8c3d57ea37e073920a14da2 diff --git a/src/main/ts/wallet/MoneroWallet.ts b/src/main/ts/wallet/MoneroWallet.ts index ceee4ae1a..aca72eee8 100644 --- a/src/main/ts/wallet/MoneroWallet.ts +++ b/src/main/ts/wallet/MoneroWallet.ts @@ -1465,7 +1465,7 @@ export default class MoneroWallet { } } - protected static normalizeTxQuery(query) { + protected static normalizeTxQuery(query): MoneroTxQuery { if (query instanceof MoneroTxQuery) query = query.copy(); else if (Array.isArray(query)) query = new MoneroTxQuery().setHashes(query); else { @@ -1478,7 +1478,7 @@ export default class MoneroWallet { return query; } - protected static normalizeTransferQuery(query) { + protected static normalizeTransferQuery(query): MoneroTransferQuery { query = new MoneroTransferQuery(query); if (query.getTxQuery() !== undefined) { let txQuery = query.getTxQuery().copy(); @@ -1490,7 +1490,7 @@ export default class MoneroWallet { return query; } - protected static normalizeOutputQuery(query) { + protected static normalizeOutputQuery(query): MoneroOutputQuery { query = new MoneroOutputQuery(query); if (query.getTxQuery() !== undefined) { let txQuery = query.getTxQuery().copy(); @@ -1502,7 +1502,7 @@ export default class MoneroWallet { return query; } - protected static normalizeCreateTxsConfig(config) { + protected static normalizeCreateTxsConfig(config): MoneroTxConfig { if (config === undefined || !(config instanceof Object)) throw new MoneroError("Must provide MoneroTxConfig or equivalent JS object"); config = new MoneroTxConfig(config); assert(config.getDestinations() && config.getDestinations().length > 0, "Must provide destinations"); @@ -1511,7 +1511,7 @@ export default class MoneroWallet { return config; } - protected static normalizeSweepOutputConfig(config) { + protected static normalizeSweepOutputConfig(config): MoneroTxConfig { if (config === undefined || !(config instanceof Object)) throw new MoneroError("Must provide MoneroTxConfig or equivalent JS object"); config = new MoneroTxConfig(config); assert.equal(config.getSweepEachSubaddress(), undefined); @@ -1522,7 +1522,7 @@ export default class MoneroWallet { return config; } - protected static normalizeSweepUnlockedConfig(config) { + protected static normalizeSweepUnlockedConfig(config): MoneroTxConfig { if (config === undefined || !(config instanceof Object)) throw new MoneroError("Must provide MoneroTxConfig or equivalent JS object"); config = new MoneroTxConfig(config); if (config.getDestinations() === undefined || config.getDestinations().length != 1) throw new MoneroError("Must provide exactly one destination to sweep to"); diff --git a/src/main/ts/wallet/MoneroWalletRpc.ts b/src/main/ts/wallet/MoneroWalletRpc.ts index 0147e7428..d84ef6747 100644 --- a/src/main/ts/wallet/MoneroWalletRpc.ts +++ b/src/main/ts/wallet/MoneroWalletRpc.ts @@ -905,7 +905,6 @@ export default class MoneroWalletRpc extends MoneroWallet { params.account_index = accountIdx; params.subaddr_indices = subaddressIndices; params.payment_id = configNormalized.getPaymentId(); - if (configNormalized.getUnlockTime() !== undefined) params.unlock_time = configNormalized.getUnlockTime().toString() params.do_not_relay = configNormalized.getRelay() !== true; assert(configNormalized.getPriority() === undefined || configNormalized.getPriority() >= 0 && configNormalized.getPriority() <= 3); params.priority = configNormalized.getPriority(); @@ -961,7 +960,6 @@ export default class MoneroWalletRpc extends MoneroWallet { params.account_index = config.getAccountIndex(); params.subaddr_indices = config.getSubaddressIndices(); params.key_image = config.getKeyImage(); - if (config.getUnlockTime() !== undefined) params.unlock_time = config.getUnlockTime(); params.do_not_relay = config.getRelay() !== true; assert(config.getPriority() === undefined || config.getPriority() >= 0 && config.getPriority() <= 3); params.priority = config.getPriority(); @@ -1756,7 +1754,7 @@ export default class MoneroWalletRpc extends MoneroWallet { return resp.result.signed_key_images.map(rpcImage => new MoneroKeyImage(rpcImage.key_image, rpcImage.signature)); } - protected async rpcSweepAccount(config) { + protected async rpcSweepAccount(config: MoneroTxConfig) { // validate config if (config === undefined) throw new MoneroError("Must provide sweep config"); @@ -1786,7 +1784,6 @@ export default class MoneroWalletRpc extends MoneroWallet { params.address = config.getDestinations()[0].getAddress(); assert(config.getPriority() === undefined || config.getPriority() >= 0 && config.getPriority() <= 3); params.priority = config.getPriority(); - if (config.getUnlockTime() !== undefined) params.unlock_time = config.getUnlockTime(); params.payment_id = config.getPaymentId(); params.do_not_relay = !relay; params.below_amount = config.getBelowAmount(); @@ -1818,7 +1815,7 @@ export default class MoneroWalletRpc extends MoneroWallet { transfer.setDestinations([destination]); tx.setOutgoingTransfer(transfer); tx.setPaymentId(config.getPaymentId()); - if (tx.getUnlockTime() === undefined) tx.setUnlockTime(config.getUnlockTime() === undefined ? 0 : config.getUnlockTime()); + if (tx.getUnlockTime() === undefined) tx.setUnlockTime(0n); if (tx.getRelay()) { if (tx.getLastRelayedTimestamp() === undefined) tx.setLastRelayedTimestamp(+new Date().getTime()); // TODO (monero-wallet-rpc): provide timestamp on response; unconfirmed timestamps vary if (tx.getIsDoubleSpendSeen() === undefined) tx.setIsDoubleSpendSeen(false); @@ -1926,7 +1923,7 @@ export default class MoneroWalletRpc extends MoneroWallet { * @param {boolean} copyDestinations - copies config destinations if true * @return {MoneroTxWallet} is the initialized send tx */ - protected static initSentTxWallet(config, tx, copyDestinations) { + protected static initSentTxWallet(config: Partial, tx, copyDestinations) { if (!tx) tx = new MoneroTxWallet(); let relay = config.getRelay() === true; tx.setIsOutgoing(true); @@ -1949,7 +1946,7 @@ export default class MoneroWalletRpc extends MoneroWallet { } tx.setOutgoingTransfer(transfer); tx.setPaymentId(config.getPaymentId()); - if (tx.getUnlockTime() === undefined) tx.setUnlockTime(config.getUnlockTime() === undefined ? 0 : config.getUnlockTime()); + if (tx.getUnlockTime() === undefined) tx.setUnlockTime(0n); if (config.getRelay()) { if (tx.getLastRelayedTimestamp() === undefined) tx.setLastRelayedTimestamp(+new Date().getTime()); // TODO (monero-wallet-rpc): provide timestamp on response; unconfirmed timestamps vary if (tx.getIsDoubleSpendSeen() === undefined) tx.setIsDoubleSpendSeen(false); diff --git a/src/main/ts/wallet/model/MoneroTxConfig.ts b/src/main/ts/wallet/model/MoneroTxConfig.ts index 4b8eddd58..4502ba4d9 100644 --- a/src/main/ts/wallet/model/MoneroTxConfig.ts +++ b/src/main/ts/wallet/model/MoneroTxConfig.ts @@ -38,9 +38,6 @@ export default class MoneroTxConfig { /** Payment ID for the transaction. */ paymentId: string; - /** Minimum height or timestamp for the transaction to unlock (default 0). */ - unlockTime: bigint; - /** Miner fee (calculated automatically). */ fee: bigint; @@ -102,7 +99,6 @@ export default class MoneroTxConfig { // deserialize bigints if (this.amount !== undefined && typeof this.amount !== "bigint") this.amount = BigInt(this.amount); if (this.fee !== undefined && typeof this.fee !== "bigint") this.fee = BigInt(this.fee); - if (this.unlockTime !== undefined && typeof this.unlockTime !== "bigint") this.unlockTime = BigInt(this.unlockTime); if (this.belowAmount !== undefined && typeof this.belowAmount !== "bigint") this.belowAmount = BigInt(this.belowAmount); // copy destinations @@ -138,7 +134,6 @@ export default class MoneroTxConfig { for (let destination of this.getDestinations()) json.destinations.push(destination.toJson()); } if (this.getFee()) json.fee = this.getFee().toString(); - if (this.getUnlockTime()) json.unlockTime = this.getUnlockTime().toString(); if (this.getBelowAmount()) json.belowAmount = this.getBelowAmount().toString(); return json; } @@ -277,15 +272,6 @@ export default class MoneroTxConfig { return this; } - getUnlockTime(): bigint { - return this.unlockTime; - } - - setUnlockTime(unlockTime: bigint): MoneroTxConfig { - this.unlockTime = unlockTime; - return this; - } - getRelay(): boolean { return this.relay; } diff --git a/src/test/TestMoneroWalletCommon.ts b/src/test/TestMoneroWalletCommon.ts index 2c73583be..724409c86 100644 --- a/src/test/TestMoneroWalletCommon.ts +++ b/src/test/TestMoneroWalletCommon.ts @@ -2979,25 +2979,25 @@ export default class TestMoneroWalletCommon { // TODO: test sending to multiple accounts if (testConfig.testRelays && testConfig.testNotifications) it("Can update a locked tx sent from/to the same account as blocks are added to the chain", async function() { - let config = new MoneroTxConfig({accountIndex: 0, address: await that.wallet.getPrimaryAddress(), amount: TestUtils.MAX_FEE, unlockTime: BigInt(await that.daemon.getHeight() + 3), canSplit: false, relay: true}); + let config = new MoneroTxConfig({accountIndex: 0, address: await that.wallet.getPrimaryAddress(), amount: TestUtils.MAX_FEE, canSplit: false, relay: true}); await testSendAndUpdateTxs(config); }); if (testConfig.testRelays && testConfig.testNotifications && !testConfig.liteMode) it("Can update split locked txs sent from/to the same account as blocks are added to the chain", async function() { - let config = new MoneroTxConfig({accountIndex: 0, address: await that.wallet.getPrimaryAddress(), amount: TestUtils.MAX_FEE, unlockTime: BigInt(await that.daemon.getHeight() + 3), canSplit: true, relay: true}); + let config = new MoneroTxConfig({accountIndex: 0, address: await that.wallet.getPrimaryAddress(), amount: TestUtils.MAX_FEE, canSplit: true, relay: true}); await testSendAndUpdateTxs(config); }); if (testConfig.testRelays && testConfig.testNotifications && !testConfig.liteMode) it("Can update a locked tx sent from/to different accounts as blocks are added to the chain", async function() { - let config = new MoneroTxConfig({accountIndex: 0, address: (await that.wallet.getSubaddress(1, 0)).getAddress(), amount: TestUtils.MAX_FEE, unlockTime: BigInt(await that.daemon.getHeight() + 3), canSplit: false, relay: true}); + let config = new MoneroTxConfig({accountIndex: 0, address: (await that.wallet.getSubaddress(1, 0)).getAddress(), amount: TestUtils.MAX_FEE, canSplit: false, relay: true}); await testSendAndUpdateTxs(config); }); if (testConfig.testRelays && testConfig.testNotifications && !testConfig.liteMode) it("Can update locked, split txs sent from/to different accounts as blocks are added to the chain", async function() { - let config = new MoneroTxConfig({accountIndex: 0, address: (await that.wallet.getSubaddress(1, 0)).getAddress(), amount: TestUtils.MAX_FEE, unlockTime: BigInt(await that.daemon.getHeight() + 3), relay: true}); + let config = new MoneroTxConfig({accountIndex: 0, address: (await that.wallet.getSubaddress(1, 0)).getAddress(), amount: TestUtils.MAX_FEE, relay: true}); await testSendAndUpdateTxs(config); }); @@ -4540,11 +4540,11 @@ export default class TestMoneroWalletCommon { else assert(found); // test common attributes - let config = ctx.config; + let config = ctx.config as MoneroTxConfig; assert.equal(tx.getIsConfirmed(), false); await testTransfer(tx.getOutgoingTransfer(), ctx); assert.equal(tx.getRingSize(), MoneroUtils.RING_SIZE); - assert.equal(tx.getUnlockTime().toString(), (config.getUnlockTime() ? config.getUnlockTime() : BigInt(0)).toString()); + assert.equal(tx.getUnlockTime().toString(), BigInt(0).toString()); assert.equal(tx.getBlock(), undefined); assert(tx.getKey().length > 0); assert.equal(typeof tx.getFullHex(), "string");