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 23, 2024
1 parent 2fc3b0b commit 1277879
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 64 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Monero Java Library

A Java library for creating Monero applications using RPC and JNI bindings to [monero v0.18.3.3 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.3.3).
A Java library for creating Monero applications using RPC and JNI bindings to [monero v0.18.3.4 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.3.4).

* Supports wallet and daemon RPC clients.
* Supports client-side wallets using JNI bindings.
Expand Down
29 changes: 13 additions & 16 deletions docs/monero-spec.drawio

Large diffs are not rendered by default.

Binary file modified docs/monero-spec.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions src/main/java/monero/daemon/MoneroDaemonRpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ private static MoneroSubmitTxResult convertRpcSubmitTxResult(Map<String, Object>
else if (key.equals("status") || key.equals("untrusted")) {} // handled elsewhere
else if (key.equals("top_hash")) result.setTopBlockHash("".equals(val) ? null : (String) val);
else if (key.equals("tx_extra_too_big")) result.setIsTxExtraTooBig((Boolean) val);
else if (key.equals("nonzero_unlock_time")) {} // ignored
else LOGGER.warning("ignoring unexpected field in submit tx hex result: " + key + ": " + val);
}
return result;
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/monero/wallet/MoneroWalletRpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,6 @@ public List<MoneroTxWallet> createTxs(MoneroTxConfig config) {
params.put("account_index", accountIdx);
params.put("subaddr_indices", subaddressIndices);
params.put("payment_id", config.getPaymentId());
params.put("unlock_time", config.getUnlockTime());
params.put("do_not_relay", !Boolean.TRUE.equals(config.getRelay()));
params.put("priority", config.getPriority() == null ? null : config.getPriority().ordinal());
params.put("get_tx_hex", true);
Expand Down Expand Up @@ -1253,7 +1252,6 @@ public MoneroTxWallet sweepOutput(MoneroTxConfig config) {
params.put("account_index", config.getAccountIndex());
params.put("subaddr_indices", config.getSubaddressIndices());
params.put("key_image", config.getKeyImage());
params.put("unlock_time", config.getUnlockTime());
params.put("do_not_relay", !Boolean.TRUE.equals(config.getRelay()));
params.put("priority", config.getPriority() == null ? null : config.getPriority().ordinal());
params.put("payment_id", config.getPaymentId());
Expand Down Expand Up @@ -2231,7 +2229,6 @@ private List<MoneroTxWallet> rpcSweepAccount(MoneroTxConfig config) {
params.put("subaddr_indices", config.getSubaddressIndices());
params.put("address", config.getDestinations().get(0).getAddress());
params.put("priority", config.getPriority() == null ? null : config.getPriority().ordinal());
params.put("unlock_time", config.getUnlockTime());
params.put("payment_id", config.getPaymentId());
params.put("do_not_relay", !relay);
params.put("below_amount", config.getBelowAmount());
Expand Down Expand Up @@ -2263,7 +2260,7 @@ private List<MoneroTxWallet> rpcSweepAccount(MoneroTxConfig config) {
MoneroDestination destination = new MoneroDestination(config.getDestinations().get(0).getAddress(), transfer.getAmount());
transfer.setDestinations(Arrays.asList(destination));
tx.setPaymentId(config.getPaymentId());
if (tx.getUnlockTime() == null) tx.setUnlockTime(config.getUnlockTime() == null ? BigInteger.valueOf(0) : config.getUnlockTime());
if (tx.getUnlockTime() == null) tx.setUnlockTime(BigInteger.valueOf(0));
if (tx.getRelay()) {
if (tx.getLastRelayedTimestamp() == null) tx.setLastRelayedTimestamp(System.currentTimeMillis()); // TODO (monero-wallet-rpc): provide timestamp on response; unconfirmed timestamps vary
if (tx.isDoubleSpendSeen() == null) tx.setIsDoubleSpendSeen(false);
Expand Down Expand Up @@ -2788,7 +2785,7 @@ private static MoneroTxWallet initSentTxWallet(MoneroTxConfig config, MoneroTxWa
}
tx.setOutgoingTransfer(transfer);
tx.setPaymentId(config.getPaymentId());
if (tx.getUnlockTime() == null) tx.setUnlockTime(config.getUnlockTime() == null ? BigInteger.valueOf(0) : config.getUnlockTime());
if (tx.getUnlockTime() == null) tx.setUnlockTime(BigInteger.valueOf(0));
if (tx.getRelay()) {
if (tx.getLastRelayedTimestamp() == null) tx.setLastRelayedTimestamp(System.currentTimeMillis()); // TODO (monero-wallet-rpc): provide timestamp on response; unconfirmed timestamps vary
if (tx.isDoubleSpendSeen() == null) tx.setIsDoubleSpendSeen(false);
Expand Down
36 changes: 0 additions & 36 deletions src/main/java/monero/wallet/model/MoneroTxConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class MoneroTxConfig {
private BigInteger fee;
private Integer accountIndex;
private List<Integer> subaddressIndices;
private BigInteger unlockTime;
private Boolean canSplit;
private Boolean relay;
private String note;
Expand All @@ -47,7 +46,6 @@ public MoneroTxConfig() {
this.fee = config.fee;
this.accountIndex = config.accountIndex;
if (config.subaddressIndices != null) this.subaddressIndices = new ArrayList<Integer>(config.subaddressIndices);
this.unlockTime = config.unlockTime;
this.canSplit = config.canSplit;
this.relay = config.relay;
this.note = config.note;
Expand Down Expand Up @@ -214,36 +212,6 @@ public MoneroTxConfig setSubaddressIndices(Integer... subaddressIndices) {
if (asList.size() == 1 && asList.get(0) == null) asList = null; // ...null becomes [null] so change to null
return setSubaddressIndices(asList);
}

/**
* Get the minimum height for the transaction to unlock. The transaction
* will unlock on the maximum of the returned unlock time and the
* confirmation height + 10.
*
* @return the minimum height or timestamp for the transaction to unlock
*/
public BigInteger getUnlockTime() {
return unlockTime;
}

/**
* Set the minimum height or timestamp for the transaction to unlock. The transaction
* will unlock on the maximum of the given unlock time and the confirmation
* height + 10.
*
* @param unlockTime the minimum height or timestamp for the transaction to unlock
* @return this configuration for chaining
*/
@JsonProperty("unlockTime")
public MoneroTxConfig setUnlockTime(BigInteger unlockTime) {
this.unlockTime = unlockTime;
return this;
}

public MoneroTxConfig setUnlockTime(Long unlockTime) {
this.unlockTime = unlockTime == null ? null : BigInteger.valueOf(unlockTime);
return this;
}

public Boolean getCanSplit() {
return canSplit;
Expand Down Expand Up @@ -331,7 +299,6 @@ public int hashCode() {
result = prime * result + ((subaddressIndices == null) ? 0 : subaddressIndices.hashCode());
result = prime * result + ((subtractFeeFrom == null) ? 0 : subtractFeeFrom.hashCode());
result = prime * result + ((sweepEachSubaddress == null) ? 0 : sweepEachSubaddress.hashCode());
result = prime * result + ((unlockTime == null) ? 0 : unlockTime.hashCode());
return result;
}

Expand Down Expand Up @@ -381,9 +348,6 @@ public boolean equals(Object obj) {
if (sweepEachSubaddress == null) {
if (other.sweepEachSubaddress != null) return false;
} else if (!sweepEachSubaddress.equals(other.sweepEachSubaddress)) return false;
if (unlockTime == null) {
if (other.unlockTime != null) return false;
} else if (!unlockTime.equals(other.unlockTime)) return false;
return true;
}
}
6 changes: 1 addition & 5 deletions src/test/java/TestMoneroWalletCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -4302,7 +4302,6 @@ public void testUpdateLockedSameAccount() {
.setAddress(wallet.getPrimaryAddress())
.setAmount(TestUtils.MAX_FEE)
.setAccountIndex(0)
.setUnlockTime(daemon.getHeight() + 3l)
.setCanSplit(false)
.setRelay(true);
testSendAndUpdateTxs(config);
Expand All @@ -4316,7 +4315,6 @@ public void testUpdateLockedSameAccountSplit() {
.setAccountIndex(0)
.setAddress(wallet.getPrimaryAddress())
.setAmount(TestUtils.MAX_FEE)
.setUnlockTime(daemon.getHeight() + 3l)
.setCanSplit(true)
.setRelay(true);
testSendAndUpdateTxs(config);
Expand All @@ -4330,7 +4328,6 @@ public void testUpdateLockedDifferentAccounts() {
.setAccountIndex(0)
.setAddress(wallet.getSubaddress(1, 0).getAddress())
.setAmount(TestUtils.MAX_FEE)
.setUnlockTime(daemon.getHeight() + 3l)
.setCanSplit(false)
.setRelay(true);
testSendAndUpdateTxs(config);
Expand All @@ -4345,7 +4342,6 @@ public void testUpdateLockedDifferentAccountsSplit() {
.setAddress(wallet.getSubaddress(1, 0).getAddress())
.setAmount(TestUtils.MAX_FEE)
.setAccountIndex(0)
.setUnlockTime(daemon.getHeight() + 3l)
.setRelay(true);
testSendAndUpdateTxs(config);
}
Expand Down Expand Up @@ -5733,7 +5729,7 @@ protected void testTxWallet(MoneroTxWallet tx, TxContext ctx) {
assertEquals(false, tx.isConfirmed());
testTransfer(tx.getOutgoingTransfer(), ctx);
assertEquals(MoneroUtils.RING_SIZE, (int) tx.getRingSize());
assertEquals(config.getUnlockTime() != null ? config.getUnlockTime() : BigInteger.valueOf(0), tx.getUnlockTime());
assertEquals(BigInteger.valueOf(0), tx.getUnlockTime());
assertNull(tx.getBlock());
assertTrue(tx.getKey().length() > 0);
assertNotNull(tx.getFullHex());
Expand Down

0 comments on commit 1277879

Please sign in to comment.