Fix sendCoins. Tested and works in the ATM.

This commit is contained in:
Alexander Garzon 2017-08-24 14:01:32 -04:00
parent 076071376b
commit fc80a51176
3 changed files with 21 additions and 2 deletions

View File

@ -39,6 +39,7 @@ public class Potwallet implements IWallet {
this.publicKey = publicKey; this.publicKey = publicKey;
this.privateKey = privateKey; this.privateKey = privateKey;
this.walletId = walletId; this.walletId = walletId;
api = RestProxyFactory.createProxy(PotwalletAPI.class, "https://api.potwallet.com"); api = RestProxyFactory.createProxy(PotwalletAPI.class, "https://api.potwallet.com");
} }
@ -106,7 +107,7 @@ public class Potwallet implements IWallet {
} }
try{ try{
accessHash = generateHash(privateKey, "https://api.potwallet.com/v1/send", nonce); accessHash = generateHash(privateKey, "https://api.potwallet.com/v1/send", nonce);
PotwalletResponse response = api.sendPots(publicKey, accessHash, nonce, destinationAddress, amount.stripTrailingZeros()); PotwalletResponse response = api.sendPots(publicKey, accessHash, nonce, new PotwalletSendRequest(destinationAddress, amount.stripTrailingZeros()));
if (response != null && response.getMessage() != null && response.getSuccess()) { if (response != null && response.getMessage() != null && response.getSuccess()) {
return new String(response.getMessage()); return new String(response.getMessage());
} }

View File

@ -17,5 +17,5 @@ public interface PotwalletAPI {
@POST @POST
@Path("/send") @Path("/send")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
PotwalletResponse sendPots(@HeaderParam("Access-Public") String publicKey, @HeaderParam("Access-Hash") String accessHash, @HeaderParam("Access-Nonce") String nonce, @PathParam("address") String address, @PathParam("amount") BigDecimal amount) throws IOException; PotwalletResponse sendPots(@HeaderParam("Access-Public") String publicKey, @HeaderParam("Access-Hash") String accessHash, @HeaderParam("Access-Nonce") String nonce, PotwalletSendRequest request) throws IOException;
} }

View File

@ -0,0 +1,18 @@
package com.generalbytes.batm.server.extensions.extra.potcoin.wallets.potwallet;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
public class PotwalletSendRequest {
@JsonProperty("address")
String address;
@JsonProperty("amount")
BigDecimal amount;
public PotwalletSendRequest(String address, BigDecimal amount) {
this.address = address;
this.amount = amount;
}
}