Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate "SendRequest" classes #184

Closed
wants to merge 1 commit into from
Closed
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 @@ -7,7 +7,7 @@
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlAccessorType(XmlAccessType.FIELD)
public class BitcoinSendRequest {
public class BitcoinySendRequest {

@Schema(description = "Bitcoin BIP32 extended private key", example = "tprv___________________________________________________________________________________________________________")
public String xprv58;
Expand All @@ -17,13 +17,13 @@ public class BitcoinSendRequest {

@Schema(description = "Amount of BTC to send", type = "number")
@XmlJavaTypeAdapter(value = org.qortal.api.AmountTypeAdapter.class)
public long bitcoinAmount;
public long coinAmount;

@Schema(description = "Transaction fee per byte (optional). Default is 0.00000100 BTC (100 sats) per byte", example = "0.00000100", type = "number")
@XmlJavaTypeAdapter(value = org.qortal.api.AmountTypeAdapter.class)
public Long feePerByte;

public BitcoinSendRequest() {
public BitcoinySendRequest() {
}

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Transaction;
import org.qortal.api.ApiError;
import org.qortal.api.ApiErrors;
import org.qortal.api.ApiExceptionFactory;
import org.qortal.api.Security;
import org.qortal.api.model.crosschain.AddressRequest;
import org.qortal.api.model.crosschain.BitcoinSendRequest;
import org.qortal.api.model.crosschain.BitcoinySendRequest;
import org.qortal.crosschain.AddressInfo;
import org.qortal.crosschain.Bitcoin;
import org.qortal.crosschain.ForeignBlockchainException;
Expand Down Expand Up @@ -200,7 +199,7 @@ public List<AddressInfo> getBitcoinAddressInfos(@HeaderParam(Security.API_KEY_HE
content = @Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(
implementation = BitcoinSendRequest.class
implementation = BitcoinySendRequest.class
)
)
),
Expand All @@ -212,10 +211,10 @@ public List<AddressInfo> getBitcoinAddressInfos(@HeaderParam(Security.API_KEY_HE
)
@ApiErrors({ApiError.INVALID_PRIVATE_KEY, ApiError.INVALID_CRITERIA, ApiError.INVALID_ADDRESS, ApiError.FOREIGN_BLOCKCHAIN_BALANCE_ISSUE, ApiError.FOREIGN_BLOCKCHAIN_NETWORK_ISSUE})
@SecurityRequirement(name = "apiKey")
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, BitcoinSendRequest bitcoinSendRequest) {
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, BitcoinySendRequest bitcoinSendRequest) {
Security.checkApiCallAllowed(request);

if (bitcoinSendRequest.bitcoinAmount <= 0)
if (bitcoinSendRequest.coinAmount <= 0)
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);

if (bitcoinSendRequest.feePerByte != null && bitcoinSendRequest.feePerByte <= 0)
Expand All @@ -231,7 +230,7 @@ public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, B

Transaction spendTransaction = bitcoin.buildSpend(bitcoinSendRequest.xprv58,
bitcoinSendRequest.receivingAddress,
bitcoinSendRequest.bitcoinAmount,
bitcoinSendRequest.coinAmount,
bitcoinSendRequest.feePerByte);

if (spendTransaction == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.qortal.api.ApiExceptionFactory;
import org.qortal.api.Security;
import org.qortal.api.model.crosschain.AddressRequest;
import org.qortal.api.model.crosschain.DigibyteSendRequest;
import org.qortal.api.model.crosschain.BitcoinySendRequest;
import org.qortal.crosschain.AddressInfo;
import org.qortal.crosschain.Digibyte;
import org.qortal.crosschain.ForeignBlockchainException;
Expand Down Expand Up @@ -199,7 +199,7 @@ public List<AddressInfo> getDigibyteAddressInfos(@HeaderParam(Security.API_KEY_H
content = @Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(
implementation = DigibyteSendRequest.class
implementation = BitcoinySendRequest.class
)
)
),
Expand All @@ -211,10 +211,10 @@ public List<AddressInfo> getDigibyteAddressInfos(@HeaderParam(Security.API_KEY_H
)
@ApiErrors({ApiError.INVALID_PRIVATE_KEY, ApiError.INVALID_CRITERIA, ApiError.INVALID_ADDRESS, ApiError.FOREIGN_BLOCKCHAIN_BALANCE_ISSUE, ApiError.FOREIGN_BLOCKCHAIN_NETWORK_ISSUE})
@SecurityRequirement(name = "apiKey")
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, DigibyteSendRequest digibyteSendRequest) {
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, BitcoinySendRequest digibyteSendRequest) {
Security.checkApiCallAllowed(request);

if (digibyteSendRequest.digibyteAmount <= 0)
if (digibyteSendRequest.coinAmount <= 0)
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);

if (digibyteSendRequest.feePerByte != null && digibyteSendRequest.feePerByte <= 0)
Expand All @@ -230,7 +230,7 @@ public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, D

Transaction spendTransaction = digibyte.buildSpend(digibyteSendRequest.xprv58,
digibyteSendRequest.receivingAddress,
digibyteSendRequest.digibyteAmount,
digibyteSendRequest.coinAmount,
digibyteSendRequest.feePerByte);

if (spendTransaction == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.qortal.api.ApiExceptionFactory;
import org.qortal.api.Security;
import org.qortal.api.model.crosschain.AddressRequest;
import org.qortal.api.model.crosschain.DogecoinSendRequest;
import org.qortal.api.model.crosschain.BitcoinySendRequest;
import org.qortal.crosschain.AddressInfo;
import org.qortal.crosschain.Dogecoin;
import org.qortal.crosschain.ForeignBlockchainException;
Expand Down Expand Up @@ -199,7 +199,7 @@ public List<AddressInfo> getDogecoinAddressInfos(@HeaderParam(Security.API_KEY_H
content = @Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(
implementation = DogecoinSendRequest.class
implementation = BitcoinySendRequest.class
)
)
),
Expand All @@ -211,10 +211,10 @@ public List<AddressInfo> getDogecoinAddressInfos(@HeaderParam(Security.API_KEY_H
)
@ApiErrors({ApiError.INVALID_PRIVATE_KEY, ApiError.INVALID_CRITERIA, ApiError.INVALID_ADDRESS, ApiError.FOREIGN_BLOCKCHAIN_BALANCE_ISSUE, ApiError.FOREIGN_BLOCKCHAIN_NETWORK_ISSUE})
@SecurityRequirement(name = "apiKey")
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, DogecoinSendRequest dogecoinSendRequest) {
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, BitcoinySendRequest dogecoinSendRequest) {
Security.checkApiCallAllowed(request);

if (dogecoinSendRequest.dogecoinAmount <= 0)
if (dogecoinSendRequest.coinAmount <= 0)
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);

if (dogecoinSendRequest.feePerByte != null && dogecoinSendRequest.feePerByte <= 0)
Expand All @@ -230,7 +230,7 @@ public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, D

Transaction spendTransaction = dogecoin.buildSpend(dogecoinSendRequest.xprv58,
dogecoinSendRequest.receivingAddress,
dogecoinSendRequest.dogecoinAmount,
dogecoinSendRequest.coinAmount,
dogecoinSendRequest.feePerByte);

if (spendTransaction == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.qortal.api.ApiExceptionFactory;
import org.qortal.api.Security;
import org.qortal.api.model.crosschain.AddressRequest;
import org.qortal.api.model.crosschain.LitecoinSendRequest;
import org.qortal.api.model.crosschain.BitcoinySendRequest;
import org.qortal.crosschain.AddressInfo;
import org.qortal.crosschain.ForeignBlockchainException;
import org.qortal.crosschain.Litecoin;
Expand Down Expand Up @@ -199,7 +199,7 @@ public List<AddressInfo> getLitecoinAddressInfos(@HeaderParam(Security.API_KEY_H
content = @Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(
implementation = LitecoinSendRequest.class
implementation = BitcoinySendRequest.class
)
)
),
Expand All @@ -211,10 +211,10 @@ public List<AddressInfo> getLitecoinAddressInfos(@HeaderParam(Security.API_KEY_H
)
@ApiErrors({ApiError.INVALID_PRIVATE_KEY, ApiError.INVALID_CRITERIA, ApiError.INVALID_ADDRESS, ApiError.FOREIGN_BLOCKCHAIN_BALANCE_ISSUE, ApiError.FOREIGN_BLOCKCHAIN_NETWORK_ISSUE})
@SecurityRequirement(name = "apiKey")
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, LitecoinSendRequest litecoinSendRequest) {
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, BitcoinySendRequest litecoinSendRequest) {
Security.checkApiCallAllowed(request);

if (litecoinSendRequest.litecoinAmount <= 0)
if (litecoinSendRequest.coinAmount <= 0)
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);

if (litecoinSendRequest.feePerByte != null && litecoinSendRequest.feePerByte <= 0)
Expand All @@ -230,7 +230,7 @@ public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, L

Transaction spendTransaction = litecoin.buildSpend(litecoinSendRequest.xprv58,
litecoinSendRequest.receivingAddress,
litecoinSendRequest.litecoinAmount,
litecoinSendRequest.coinAmount,
litecoinSendRequest.feePerByte);

if (spendTransaction == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.qortal.api.ApiExceptionFactory;
import org.qortal.api.Security;
import org.qortal.api.model.crosschain.AddressRequest;
import org.qortal.api.model.crosschain.RavencoinSendRequest;
import org.qortal.api.model.crosschain.BitcoinySendRequest;
import org.qortal.crosschain.AddressInfo;
import org.qortal.crosschain.ForeignBlockchainException;
import org.qortal.crosschain.Ravencoin;
Expand Down Expand Up @@ -199,7 +199,7 @@ public List<AddressInfo> getRavencoinAddressInfos(@HeaderParam(Security.API_KEY_
content = @Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(
implementation = RavencoinSendRequest.class
implementation = BitcoinySendRequest.class
)
)
),
Expand All @@ -211,10 +211,10 @@ public List<AddressInfo> getRavencoinAddressInfos(@HeaderParam(Security.API_KEY_
)
@ApiErrors({ApiError.INVALID_PRIVATE_KEY, ApiError.INVALID_CRITERIA, ApiError.INVALID_ADDRESS, ApiError.FOREIGN_BLOCKCHAIN_BALANCE_ISSUE, ApiError.FOREIGN_BLOCKCHAIN_NETWORK_ISSUE})
@SecurityRequirement(name = "apiKey")
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, RavencoinSendRequest ravencoinSendRequest) {
public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, BitcoinySendRequest ravencoinSendRequest) {
Security.checkApiCallAllowed(request);

if (ravencoinSendRequest.ravencoinAmount <= 0)
if (ravencoinSendRequest.coinAmount <= 0)
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);

if (ravencoinSendRequest.feePerByte != null && ravencoinSendRequest.feePerByte <= 0)
Expand All @@ -230,7 +230,7 @@ public String sendBitcoin(@HeaderParam(Security.API_KEY_HEADER) String apiKey, R

Transaction spendTransaction = ravencoin.buildSpend(ravencoinSendRequest.xprv58,
ravencoinSendRequest.receivingAddress,
ravencoinSendRequest.ravencoinAmount,
ravencoinSendRequest.coinAmount,
ravencoinSendRequest.feePerByte);

if (spendTransaction == null)
Expand Down
Loading