Skip to content

Commit

Permalink
Add some missing @nullable annotations
Browse files Browse the repository at this point in the history
Make 'aesKey' method parameters @nullable where obviously applicable,
for consistency (as it was missed out in a number of places). Also make
the v5-protocol-specific fee bump fields of 'InputsForDepositTxRequest'
@nullable, as expected.
  • Loading branch information
stejbac committed Sep 1, 2024
1 parent 91051b0 commit e7b7e41
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/btc/setup/WalletConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public File directory() {
return directory;
}

public void maybeAddSegwitKeychain(Wallet wallet, KeyParameter aesKey, boolean isBsqWallet) {
public void maybeAddSegwitKeychain(Wallet wallet, @Nullable KeyParameter aesKey, boolean isBsqWallet) {
var nonSegwitAccountPath = isBsqWallet
? BisqKeyChainGroupStructure.BIP44_BSQ_NON_SEGWIT_ACCOUNT_PATH
: BisqKeyChainGroupStructure.BIP44_BTC_NON_SEGWIT_ACCOUNT_PATH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

import org.bouncycastle.crypto.params.KeyParameter;

import javax.annotation.Nullable;

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

public class ClaimTransactionFactory {
Expand All @@ -52,7 +54,7 @@ public Transaction createSignedClaimTransaction(TransactionOutput warningTxOutpu
long miningFee,
byte[] peersMultiSigPubKey,
DeterministicKey myMultiSigKeyPair,
KeyParameter aesKey)
@Nullable KeyParameter aesKey)
throws AddressFormatException, TransactionVerificationException {

Transaction claimTx = createUnsignedClaimTransaction(warningTxOutput, claimDelay, payoutAddress, miningFee);
Expand Down Expand Up @@ -90,7 +92,7 @@ private ECKey.ECDSASignature signClaimTransaction(Transaction claimTx,
byte[] buyerPubKey,
byte[] sellerPubKey,
DeterministicKey myMultiSigKeyPair,
KeyParameter aesKey)
@Nullable KeyParameter aesKey)
throws TransactionVerificationException {

Script redeemScript = WarningTransactionFactory.createRedeemScript(isBuyer, buyerPubKey, sellerPubKey, claimDelay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

import java.util.List;

import javax.annotation.Nullable;

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

public class RedirectionTransactionFactory {
Expand Down Expand Up @@ -82,7 +84,7 @@ public byte[] signRedirectionTransaction(TransactionOutput warningTxOutput,
byte[] buyerPubKey,
byte[] sellerPubKey,
DeterministicKey myMultiSigKeyPair,
KeyParameter aesKey)
@Nullable KeyParameter aesKey)
throws TransactionVerificationException {

Script redeemScript = WarningTransactionFactory.createRedeemScript(!isBuyer, buyerPubKey, sellerPubKey, claimDelay);
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/bisq/core/btc/wallet/WalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static void checkScriptSig(Transaction transaction,
///////////////////////////////////////////////////////////////////////////////////////////

public static void signTx(Wallet wallet,
KeyParameter aesKey,
@Nullable KeyParameter aesKey,
Transaction tx)
throws WalletException, TransactionVerificationException {
for (int i = 0; i < tx.getInputs().size(); i++) {
Expand All @@ -309,7 +309,7 @@ public static void signTx(Wallet wallet,
}

public static void signTransactionInput(Wallet wallet,
KeyParameter aesKey,
@Nullable KeyParameter aesKey,
Transaction tx,
TransactionInput txIn,
int index) {
Expand Down Expand Up @@ -634,7 +634,7 @@ public Coin getDust(Transaction proposedTransaction) {
///////////////////////////////////////////////////////////////////////////////////////////

public void emptyBtcWallet(String toAddress,
KeyParameter aesKey,
@Nullable KeyParameter aesKey,
ResultHandler resultHandler,
ErrorMessageHandler errorMessageHandler)
throws InsufficientMoneyException, AddressFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

import org.bouncycastle.crypto.params.KeyParameter;

import javax.annotation.Nullable;

import static com.google.common.base.Preconditions.checkArgument;
import static org.bitcoinj.script.ScriptOpCodes.*;

Expand Down Expand Up @@ -89,7 +91,7 @@ public byte[] signWarningTransaction(Transaction warningTx,
DeterministicKey myMultiSigKeyPair,
byte[] buyerPubKey,
byte[] sellerPubKey,
KeyParameter aesKey)
@Nullable KeyParameter aesKey)
throws TransactionVerificationException {

Script redeemScript = TradeWalletService.get2of2MultiSigRedeemScript(buyerPubKey, sellerPubKey);
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/trade/TradeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ private OfferAvailabilityModel getOfferAvailabilityModel(Offer offer, boolean is
public void onWithdrawRequest(String toAddress,
Coin amount,
Coin fee,
KeyParameter aesKey,
@Nullable KeyParameter aesKey,
Trade trade,
@Nullable String memo,
ResultHandler resultHandler,
Expand All @@ -688,7 +688,7 @@ public void onWithdrawRequest(String toAddress,
AddressEntry.Context.TRADE_PAYOUT).getAddressString();
FutureCallback<Transaction> callback = new FutureCallback<>() {
@Override
public void onSuccess(@javax.annotation.Nullable Transaction transaction) {
public void onSuccess(@Nullable Transaction transaction) {
if (transaction != null) {
log.debug("onWithdraw onSuccess tx ID:" + transaction.getTxId().toString());
onTradeCompleted(trade);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public final class InputsForDepositTxRequest extends TradeMessage implements Dir
private final int burningManSelectionHeight;

// Added for v5 protocol
@Nullable
private final String takersWarningTxFeeBumpAddress;
@Nullable
private final String takersRedirectTxFeeBumpAddress;

public InputsForDepositTxRequest(String tradeId,
Expand Down Expand Up @@ -116,8 +118,8 @@ public InputsForDepositTxRequest(String tradeId,
@Nullable byte[] hashOfTakersPaymentAccountPayload,
@Nullable String takersPaymentMethodId,
int burningManSelectionHeight,
String takersWarningTxFeeBumpAddress,
String takersRedirectTxFeeBumpAddress) {
@Nullable String takersWarningTxFeeBumpAddress,
@Nullable String takersRedirectTxFeeBumpAddress) {
super(messageVersion, tradeId, uid);
this.senderNodeAddress = senderNodeAddress;
this.tradeAmount = tradeAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@

import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;

import static bisq.desktop.util.FormBuilder.*;
import static com.google.common.base.Preconditions.checkNotNull;

Expand Down Expand Up @@ -457,7 +459,7 @@ private void onWithdraw() {
.actionButtonText(Res.get("shared.yes"))
.onAction(() -> doWithdraw(sendersAmount, fee, new FutureCallback<>() {
@Override
public void onSuccess(@javax.annotation.Nullable Transaction transaction) {
public void onSuccess(@Nullable Transaction transaction) {
if (transaction != null) {
String key = "showTransactionSent";
if (DontShowAgainLookup.showAgain(key)) {
Expand Down Expand Up @@ -561,12 +563,13 @@ private void doWithdraw(Coin amount, Coin fee, FutureCallback<Transaction> callb
}
}

private void sendFunds(Coin amount, Coin fee, KeyParameter aesKey, FutureCallback<Transaction> callback) {
private void sendFunds(Coin amount, Coin fee, @Nullable KeyParameter aesKey, FutureCallback<Transaction> callback) {
try {
String memo = withdrawMemoTextField.getText();
if (memo.isEmpty()) {
memo = null;
}
//noinspection unused
Transaction transaction = btcWalletService.sendFundsForMultipleAddresses(fromAddresses,
withdrawToTextField.getText(),
amount,
Expand Down Expand Up @@ -705,8 +708,7 @@ private void setSelectColumnCellFactory() {
public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
WithdrawalListItem> column) {
return new TableCell<>() {

CheckBox checkBox = new AutoTooltipCheckBox();
final CheckBox checkBox = new AutoTooltipCheckBox();

@Override
public void updateItem(final WithdrawalListItem item, boolean empty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;

import static bisq.desktop.util.FormBuilder.addInputTextField;
import static bisq.desktop.util.FormBuilder.addMultilineLabel;
import static bisq.desktop.util.FormBuilder.addTopLabelTextField;
Expand Down Expand Up @@ -142,7 +144,7 @@ private void addContent() {
GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}

private void doEmptyWallet(KeyParameter aesKey) {
private void doEmptyWallet(@Nullable KeyParameter aesKey) {
if (GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, walletsSetup)) {
if (!openOfferManager.getObservableList().isEmpty()) {
UserThread.runAfter(() ->
Expand All @@ -156,7 +158,7 @@ private void doEmptyWallet(KeyParameter aesKey) {
}
}

private void doEmptyWallet2(KeyParameter aesKey) {
private void doEmptyWallet2(@Nullable KeyParameter aesKey) {
emptyWalletButton.setDisable(true);
openOfferManager.removeAllOpenOffers(() -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void onFiatPaymentReceived(ResultHandler resultHandler, ErrorMessageHandl
public void onWithdrawRequest(String toAddress,
Coin amount,
Coin fee,
KeyParameter aesKey,
@Nullable KeyParameter aesKey,
@Nullable String memo,
ResultHandler resultHandler,
FaultHandler faultHandler) {
Expand Down

0 comments on commit e7b7e41

Please sign in to comment.