Skip to content

Commit

Permalink
update to monero-project v0.18.3.4, remove tx unlock time config
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Aug 28, 2024
1 parent e89e3e4 commit 3ab52fb
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -355,7 +355,7 @@ if (BUILD_MONERO_WALLET_FULL_WASM)
boost_system
boost_thread
boost_serialization
#boost_filesystem
boost_filesystem
boost_regex
#boost_atomic
#
Expand Down
2 changes: 1 addition & 1 deletion bin/build_boost_emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/main/ts/wallet/MoneroWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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");
Expand All @@ -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);
Expand All @@ -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");
Expand Down
11 changes: 4 additions & 7 deletions src/main/ts/wallet/MoneroWalletRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<MoneroTxConfig>, tx, copyDestinations) {
if (!tx) tx = new MoneroTxWallet();
let relay = config.getRelay() === true;
tx.setIsOutgoing(true);
Expand All @@ -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);
Expand Down
14 changes: 0 additions & 14 deletions src/main/ts/wallet/model/MoneroTxConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/TestMoneroWalletCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 3ab52fb

Please sign in to comment.