-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Fermat-ORG/fermat
- Loading branch information
Showing
2,740 changed files
with
20,403 additions
and
26,009 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ain/java/com/bitdubai/fermat_bch_api/layer/crypto_network/faucet/FermatFaucetManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.bitdubai.fermat_bch_api.layer.crypto_network.faucet; | ||
|
||
import com.bitdubai.fermat_api.layer.all_definition.enums.BlockchainNetworkType; | ||
import com.bitdubai.fermat_api.layer.all_definition.enums.CryptoCurrency; | ||
import com.bitdubai.fermat_api.layer.all_definition.money.CryptoAddress; | ||
|
||
/** | ||
* Created by rodrigo on 7/26/16. | ||
*/ | ||
public class FermatFaucetManager { | ||
/** | ||
* | ||
* @param blockchainNetworkType | ||
* @param cryptoAddress | ||
* @param amount | ||
* @throws CantGetCoinsFromFaucetException | ||
*/ | ||
public static void giveMeCoins(BlockchainNetworkType blockchainNetworkType, CryptoAddress cryptoAddress, long amount) throws CantGetCoinsFromFaucetException { | ||
if (cryptoAddress.getCryptoCurrency() != CryptoCurrency.FERMAT) | ||
throw new CantGetCoinsFromFaucetException(null, "Coins requested is not Fermat. This faucet only allows FER request.", "Wrong faucet manager selected."); | ||
|
||
|
||
|
||
if (blockchainNetworkType == BlockchainNetworkType.PRODUCTION){ | ||
FermatMainNetFaucetManager mainNetFaucetManager = new FermatMainNetFaucetManager(); | ||
System.out.println("***FermatFaucet***requesting coins to faucet..."); | ||
mainNetFaucetManager.giveMeCoins(cryptoAddress, amount); | ||
} | ||
|
||
//add same behaviour for RegTestNetwork. | ||
|
||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...a/com/bitdubai/fermat_bch_api/layer/crypto_network/faucet/FermatMainNetFaucetManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.bitdubai.fermat_bch_api.layer.crypto_network.faucet; | ||
|
||
import com.bitdubai.fermat_api.layer.all_definition.money.CryptoAddress; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.DataOutputStream; | ||
import java.net.InetSocketAddress; | ||
import java.net.Socket; | ||
import java.net.SocketAddress; | ||
|
||
/** | ||
* Created by rodrigo on 7/26/16. | ||
*/ | ||
public class FermatMainNetFaucetManager { | ||
private final String FAUCET_IP = "52.27.68.19"; | ||
private final int FAUCET_PORT = 4499; | ||
|
||
|
||
/** | ||
* | ||
* @param cryptoAddress | ||
* @param amount | ||
* @throws CantGetCoinsFromFaucetException | ||
*/ | ||
public void giveMeCoins(CryptoAddress cryptoAddress, long amount) throws CantGetCoinsFromFaucetException { | ||
if (cryptoAddress == null) | ||
throw new CantGetCoinsFromFaucetException(null, "Address can't be null", "invalid parameters"); | ||
|
||
|
||
Socket faucetSocket = null; | ||
DataOutputStream os = null; | ||
DataInputStream is = null; | ||
|
||
try { | ||
SocketAddress faucetServer = new InetSocketAddress(FAUCET_IP, FAUCET_PORT); | ||
faucetSocket = new Socket(FAUCET_IP, FAUCET_PORT); | ||
|
||
os = new DataOutputStream(faucetSocket.getOutputStream()); | ||
is = new DataInputStream(faucetSocket.getInputStream()); | ||
|
||
if (faucetSocket != null && os != null && is != null) { | ||
|
||
os.writeBytes(cryptoAddress.getAddress() + "\n"); | ||
os.writeBytes(String.valueOf(amount) + "\n"); | ||
|
||
os.close(); | ||
is.close(); | ||
faucetSocket.close(); | ||
} | ||
} catch (Exception e) { | ||
throw new CantGetCoinsFromFaucetException(e, "error requesting coins to faucet." , "cant connect."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.