Skip to content

Commit

Permalink
перепроверил и переделал, надо еще доделать
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuilOlegovich committed Nov 24, 2021
1 parent dd11837 commit 47fef25
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 479 deletions.
66 changes: 59 additions & 7 deletions src/main/java/com/samuilolegovich/XRPLedgerApplication.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,82 @@
package com.samuilolegovich;

import com.samuilolegovich.model.*;
import com.samuilolegovich.model.oldCode.SendXRPPayment;

import java.math.BigDecimal;
import java.util.Locale;


public class XRPLedgerApplication {
private static PaymentManagerXRP paymentManagerXRP = null;
private static PaymentManagerXRP paymentManagerXRPTwo = null;
private static PaymentManagerXRP paymentManagerXRPThree = null;
private static PaymentManagerXRP paymentManagerXRPFour = null;

public static void main(String[] args) {


public static void main(String[] args) throws InterruptedException {
// Обязательно стоит установить локаль иначе будет падать с ошибкой парсинга даты
Locale.setDefault(Locale.ENGLISH);

// new TestDtoClasses().run();
// new StartWorkPayment().run();
// new SendXRPPayment().run();
// new RealXRPWallet().run();


startTest();
// startReal();





}


private static void startReal() {
// ----------------------------- REAL -----------------------------
paymentManagerXRP = new PaymentManagerXRP();
paymentManagerXRPTwo = new PaymentManagerXRP();
//
paymentManagerXRP.createNewWallet();
String seed = paymentManagerXRP.getSeed();
System.out.println("SEED\n" + seed + "\n");

System.out.println("----------------------------- TEST ONE -----------------------------");
System.out.println("Test Private Seed\n " + paymentManagerXRP.getPrivateSeed() + "\n");
System.out.println("Test Public Address\n " + paymentManagerXRP.getPublicAddress() + "\n");

paymentManagerXRP.createNewTestWallet();
System.out.println("Test Private Seed\n " + paymentManagerXRP.getTestPrivateSeed() + "\n");
System.out.println("Test Public Address\n " + paymentManagerXRP.getTestPublicAddress() + "\n");
// paymentManagerXRP.sendPayment("ra3GsPkHcLf3TS7asKXqzVAx2wR6mvaFs5", 777, BigDecimal.ONE);

paymentManagerXRPTwo.connectAnExistingTestWallet(paymentManagerXRP.getTestPrivateSeed());
System.out.println("Test Private Seed\n " + paymentManagerXRPTwo.getTestPrivateSeed() + "\n");
System.out.println("Test Public Address\n " + paymentManagerXRPTwo.getTestPublicAddress() + "\n");
paymentManagerXRPTwo.connectAnExistingWallet(paymentManagerXRP.getSeed());

System.out.println("----------------------------- TEST TWO -----------------------------");
System.out.println("Test Private Seed\n " + paymentManagerXRPTwo.getPrivateSeed() + "\n");
System.out.println("Test Public Address\n " + paymentManagerXRPTwo.getPublicAddress() + "\n");
}

private static void startTest() {
// ----------------------------- TEST -----------------------------
paymentManagerXRPThree = new PaymentManagerXRP();
paymentManagerXRPFour = new PaymentManagerXRP();
//
paymentManagerXRPThree.createNewTestWallet();
String seedTest = paymentManagerXRPThree.getTestSeed();
System.out.println("SEED TEST\n" + seedTest + "\n");

System.out.println("----------------------------- TEST ONE -----------------------------");
System.out.println("Test Private Seed\n " + paymentManagerXRPThree.getTestPrivateSeed() + "\n");
System.out.println("Test Public Address\n " + paymentManagerXRPThree.getTestPublicAddress() + "\n");

// paymentManagerXRPThree.sendPayment("ra3GsPkHcLf3TS7asKXqzVAx2wR6mvaFs5", 777, BigDecimal.ONE);

paymentManagerXRPFour.connectAnExistingTestWallet(paymentManagerXRPThree.getTestSeed());

System.out.println("----------------------------- TEST TWO -----------------------------");
System.out.println("Test Private Seed\n " + paymentManagerXRPFour.getTestPrivateSeed() + "\n");
System.out.println("Test Public Address\n " + paymentManagerXRPFour.getTestPublicAddress() + "\n");
}
}

11 changes: 4 additions & 7 deletions src/main/java/com/samuilolegovich/model/Addresses.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.samuilolegovich.model;

import okhttp3.HttpUrl;

public final class Addresses {
// REAL
public final static String FAUCET_CLIENT_HTTP_URL = "https://s.altnet.rippletest.net:51234/";
public final static String XTP_HTTP_URL_ONE = "https://xrplcluster.com";
public final static String XTP_HTTP_URL_TWO = "https://s1.ripple.com:51234/";
public final static String XTP_HTTP_URL_THREE = "https://s1.ripple.com:51234/";
public final static String XTP_HTTP_URL_ONE = "https://s1.ripple.com:51234/";
public final static String XTP_HTTP_URL_TWO = "https://s2.ripple.com:51234/";

// TEST
public final static String FAUCET_CLIENT_HTTP_URL_TEST = "https://s.altnet.rippletest.net:51234/";
public final static String XTP_HTTP_URL_ONE_TEST = "https://s1.ripple.com:51234/";
public final static String FAUCET_CLIENT_HTTP_URL_TEST = "https://faucet.altnet.rippletest.net";
public final static String XTP_HTTP_URL_ONE_TEST = "https://s.altnet.rippletest.net:51234/";
}
15 changes: 10 additions & 5 deletions src/main/java/com/samuilolegovich/model/PaymentManagerXRP.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import com.samuilolegovich.model.realization.TestSocketXRP;
import com.samuilolegovich.model.realization.TestWalletXRP;
import com.samuilolegovich.model.realization.WalletXRP;
import lombok.Builder;

import java.math.BigDecimal;


@Builder

public final class PaymentManagerXRP {
private String testFaucetClientHttpUrl;
private String testHttpUrlConnect;
Expand Down Expand Up @@ -43,7 +42,7 @@ public void sendPayment(String address, Integer tag, BigDecimal numberOfXRP) {
if (wallet == null) {
wallet = new WalletXRP();
setterWallet();
wallet.init();
wallet.createNewWallet();
}
wallet.sendPaymentToAddressXRP(address, tag, numberOfXRP);
}
Expand Down Expand Up @@ -98,9 +97,11 @@ public String getPrivateSeed() {
return wallet.getPrivateKey();
}

public String getSeed() {
return wallet.getSeed();
}

private void setterWallet() {
if (faucetClientHttpUrl != null)
wallet.setFaucetClientHttpUrl(faucetClientHttpUrl);
if (testHttpUrlConnect != null)
wallet.setXrpHttpUrl(httpUrlConnect);
}
Expand Down Expand Up @@ -167,6 +168,10 @@ public String getTestPrivateSeed() {
return testWallet.getPrivateKey();
}

public String getTestSeed() {
return testWallet.getSeed();
}

private void setterTestWallet() {
if (testFaucetClientHttpUrl != null)
testWallet.setFaucetClientHttpUrl(testFaucetClientHttpUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.samuilolegovich.model;
package com.samuilolegovich.model.oldCode;

import okhttp3.HttpUrl;
import org.xrpl.xrpl4j.client.XrplClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.samuilolegovich.model;
package com.samuilolegovich.model.oldCode;

import com.google.common.primitives.UnsignedInteger;
import com.google.common.primitives.UnsignedLong;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.samuilolegovich.model;
package com.samuilolegovich.model.oldCode;

import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.samuilolegovich.model;
package com.samuilolegovich.model.oldCode;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.samuilolegovich.dto.PaymentDto;
Expand Down
Loading

0 comments on commit 47fef25

Please sign in to comment.