Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 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 or JNI bindings to [monero v0.18.5.3 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.5.3).
A Java library for creating Monero applications using RPC or JNI bindings to [monero v0.18.5.4 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.5.4).

* Supports wallet and daemon RPC clients.
* Supports client-side wallets using JNI bindings.
Expand Down Expand Up @@ -97,15 +97,15 @@ walletFull.close(true);

#### For Gradle, add to build.gradle:

`compile 'io.github.woodser:monero-java:0.8.63'`
`compile 'io.github.woodser:monero-java:0.8.64'`

#### For Maven, add to pom.xml:

```xml
<dependency>
<groupId>io.github.woodser</groupId>
<artifactId>monero-java</artifactId>
<version>0.8.63</version>
<version>0.8.64</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions docs/monero-spec.drawio

Large diffs are not rendered by default.

Binary file modified docs/monero-spec.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.woodser</groupId>
<artifactId>monero-java</artifactId>
<version>0.8.63</version>
<version>0.8.64</version>
<name>Monero Java Library</name>
<description>A Java library for using Monero</description>
<url>https://github.com/woodser/monero-java</url>
Expand Down
2 changes: 1 addition & 1 deletion src/main/cpp/monero_jni_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ JNIEXPORT void JNICALL Java_monero_wallet_MoneroWalletFull_setTxNotesJni(JNIEnv*
jstring jstr = (jstring) env->GetObjectArrayElement(jtx_notes, idx);
const char* _str = jstr ? env->GetStringUTFChars(jstr, NULL) : nullptr;
string str = string(_str ? _str : "");
env->ReleaseStringUTFChars(jstr, _str);
if (_str) env->ReleaseStringUTFChars(jstr, _str);
env->DeleteLocalRef(jstr);
notes.push_back(str);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/monero/common/MoneroUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class MoneroUtils {
* @return the version of this monero-java library
*/
public static String getVersion() {
return "0.8.63";
return "0.8.64";
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/monero/wallet/MoneroWalletRpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -1668,9 +1668,11 @@ public List<String> getTxNotes(List<String> txHashes) {

@Override
public void setTxNotes(List<String> txHashes, List<String> notes) {
List<String> rpcNotes = new ArrayList<String>();
for (String note : notes) rpcNotes.add(note == null ? "" : note); // wallet rpc rejects json null; the full wallet clears the note
Map<String, Object> params = new HashMap<String, Object>();
params.put("txids", txHashes);
params.put("notes", notes);
params.put("notes", rpcNotes);
rpc.sendJsonRequest("set_tx_notes", params);
}

Expand Down
30 changes: 21 additions & 9 deletions src/test/java/TestMoneroWalletCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -2238,20 +2238,18 @@ public void testCheckSpendProof() {
@Test
public void testGetReserveProofWallet() {
assumeTrue(TEST_NON_RELAYS);

TestUtils.WALLET_TX_TRACKER.waitForTxsToClearWallets(wallet); // proof excludes unconfirmed change and incoming funds

// get proof of entire wallet
String signature = wallet.getReserveProofWallet("Test message");

// check proof of entire wallet
MoneroCheckReserve check = wallet.checkReserveProof(wallet.getPrimaryAddress(), "Test message", signature);
assertTrue(check.isGood());
testCheckReserve(check);
BigInteger balance = wallet.getBalance();
if (!balance.equals(check.getTotalAmount())) { // TODO monero-wallet-rpc: this check fails with unconfirmed txs
List<MoneroTxWallet> unconfirmedTxs = wallet.getTxs(new MoneroTxQuery().setInTxPool(true));
assertTrue(unconfirmedTxs.size() > 0, "Reserve amount must equal balance unless wallet has unconfirmed txs");
}

BigInteger reserve = check.getTotalAmount().subtract(check.getUnconfirmedSpentAmount()); // TODO monero-project: compare total directly once failed txs stop unspending confirmed inputs
assertEquals(wallet.getBalance(), reserve);

// test different wallet address
String differentAddress = TestUtils.getExternalWalletAddress();
try {
Expand Down Expand Up @@ -2376,6 +2374,10 @@ public void testSetTxNote() {
for (int i = 0; i < txs.size(); i++) {
assertEquals(wallet.getTxNote(txs.get(i).getHash()), uuid + i);
}

// null clears the note
wallet.setTxNote(txs.get(0).getHash(), null);
assertEquals("", wallet.getTxNote(txs.get(0).getHash()));
}

// Can get and set multiple transaction notes
Expand All @@ -2390,7 +2392,7 @@ public void testSetTxNotes() {
assertTrue(txs.size() >= 3, "Test requires 3 or more wallet transactions; run send tests");
List<String> txHashes = new ArrayList<String>();
List<String> txNotes = new ArrayList<String>();
for (int i = 0; i < txHashes.size(); i++) {
for (int i = 0; i < txs.size(); i++) {
txHashes.add(txs.get(i).getHash());
txNotes.add(uuid + i);
}
Expand All @@ -2402,6 +2404,16 @@ public void testSetTxNotes() {
assertEquals(uuid + i, txNotes.get(i));
}

// clear notes in a mixed batch without changing the caller's list
txNotes.set(0, null);
txNotes.set(1, "");
txNotes.set(2, "null");
List<String> expectedNotes = new ArrayList<String>(txNotes);
expectedNotes.set(0, "");
wallet.setTxNotes(txHashes, Collections.unmodifiableList(txNotes));
assertNull(txNotes.get(0));
assertEquals(expectedNotes, wallet.getTxNotes(txHashes));

// TODO: test that get transaction has note
}

Expand Down
13 changes: 13 additions & 0 deletions src/test/java/TestMoneroWalletFull.java
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,7 @@ private class WalletSyncTester extends SyncProgressTester {
private BigInteger incomingTotal;
private BigInteger outgoingTotal;
private Boolean onNewBlockAfterDone;
private boolean testedTxNote;
private BigInteger prevBalance;
private BigInteger prevUnlockedBalance;

Expand Down Expand Up @@ -1446,6 +1447,17 @@ public void onOutputReceived(MoneroOutputWallet output) {
assertNull(output.getTx().getInputs());
assertEquals(1, output.getTx().getOutputs().size());
assertTrue(output.getTx().getOutputs().get(0) == output);

// can read and write tx notes from a sync callback
String txHash = output.getTx().getHash();
String previousNote = wallet.getTxNote(txHash);
try {
wallet.setTxNote(txHash, "sync callback");
assertEquals("sync callback", wallet.getTxNote(txHash));
testedTxNote = true;
} finally {
wallet.setTxNote(txHash, previousNote);
}

// extra is not sent over the jni bridge
assertNull(output.getTx().getExtra());
Expand Down Expand Up @@ -1487,6 +1499,7 @@ public void onDone(long chainHeight) {
assertNotNull(walletTesterPrevHeight);
assertNotNull(prevOutputReceived);
assertNotNull(prevOutputSpent);
assertTrue(testedTxNote);
BigInteger expectedBalance = incomingTotal.subtract(outgoingTotal);

// output notifications do not include pool fees or outgoing amount
Expand Down
Loading