Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import bisq.account.accounts.Account;
import bisq.account.accounts.AccountOrigin;
import bisq.account.accounts.crypto.monero.MoneroAccount;
import bisq.account.payment_method.crypto.CryptoPaymentMethod;
import bisq.account.timestamp.KeyType;
import bisq.common.proto.UnresolvableProtobufMessageException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import bisq.account.accounts.AccountPayload;
import bisq.account.accounts.SingleCurrencyAccountPayload;
import bisq.account.accounts.crypto.monero.MoneroAccountPayload;
import bisq.account.payment_method.crypto.CryptoPaymentMethod;
import bisq.common.asset.CryptoAssetRepository;
import bisq.common.proto.UnresolvableProtobufMessageException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.account.accounts.crypto;
package bisq.account.accounts.crypto.monero;

import bisq.account.accounts.AccountOrigin;
import bisq.account.accounts.crypto.CryptoAssetAccount;
import bisq.account.timestamp.KeyType;
import bisq.security.keys.KeyPairProtoUtil;
import lombok.EqualsAndHashCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.account.accounts.crypto;
package bisq.account.accounts.crypto.monero;

import bisq.account.accounts.crypto.CryptoAssetAccountPayload;
import bisq.account.accounts.util.AccountUtils;
import bisq.account.payment_method.crypto.CryptoPaymentMethod;
import bisq.common.asset.CryptoAssetRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.account.accounts.crypto.monero;

import bisq.account.accounts.crypto.monero.knaccc.monero.address.WalletAddress;
import lombok.extern.slf4j.Slf4j;

import static com.google.common.base.Preconditions.checkArgument;

@Slf4j
public class MoneroSubaddressService {

public String generateSubAddress(String mainAddress, String privateViewKey, long accountIndex, long subAddressIndex) {
checkArgument(accountIndex >= 0, "accountIndex must be >= 0, was: %s", accountIndex);
checkArgument(subAddressIndex >= 0, "subAddressIndex must be >= 0, was: %s", subAddressIndex);
checkArgument(accountIndex > 0 || subAddressIndex > 0, "accountIndex and subAddressIndex cannot both be 0 (would represent main address)");
checkArgument(mainAddress != null && !mainAddress.trim().isEmpty(), "mainAddress must not be null or empty");
checkArgument(privateViewKey != null && !privateViewKey.trim().isEmpty(), "privateViewKey must not be null or empty");

try {
WalletAddress walletAddress = new WalletAddress(mainAddress);
long start = System.currentTimeMillis();
String subAddress = walletAddress.getSubaddressBase58(privateViewKey, accountIndex, subAddressIndex);
log.info("Created new subAddress {}. Took {} ms.", subAddress, System.currentTimeMillis() - start);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid logging full cryptocurrency addresses.

Logging the complete subAddress exposes sensitive financial information. Consider logging only a truncated version or omitting it entirely.

🔒 Proposed fix
-            log.info("Created new subAddress {}. Took {} ms.", subAddress, System.currentTimeMillis() - start);
+            log.info("Created new subAddress (prefix: {}...). Took {} ms.", 
+                subAddress.substring(0, Math.min(8, subAddress.length())), 
+                System.currentTimeMillis() - start);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
log.info("Created new subAddress {}. Took {} ms.", subAddress, System.currentTimeMillis() - start);
log.info("Created new subAddress (prefix: {}...). Took {} ms.",
subAddress.substring(0, Math.min(8, subAddress.length())),
System.currentTimeMillis() - start);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@account/src/main/java/bisq/account/accounts/crypto/monero/MoneroSubaddressService.java`
at line 39, The log in MoneroSubaddressService currently prints the full
subAddress which leaks sensitive info; update the logging in the method that
creates new subaddresses (where subAddress is used) to avoid printing the full
address—either omit subAddress entirely or log a masked/truncated form (e.g.,
show only the first N and last M characters or replace middle chars with
ellipsis) and keep the elapsed time as before; locate the log.info call that
references subAddress and replace it with a maskedAddress variable or remove the
address from the message so only non-sensitive details (like timing) are logged.

return subAddress;
} catch (WalletAddress.InvalidWalletAddressException e) {
log.error("WalletAddress.getSubaddressBase58 failed for mainAddress: {}", mainAddress, e);
throw new IllegalArgumentException("Invalid main address or private view key", e);
}
}
}
Loading
Loading