Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

0.2 hibernate #39

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
language: java

jdk:
- oraclejdk8
before-install:
- echo before-install
- pip install --user codecov
install: true
script:
- mvn clean install
- oraclejdk8

notifications:
slack:
secure: "H6eYpuLQatCsKXkgQisjVAx33BiZbA9FZ6KVrdYttjEpaNCH7yZu1/4jcWsLbjwyWi6xbbUYMIYtrjkXbgavFVlhiJ5yAD1KpeVdtMytW1W67oCXGGbG5keHVAXkzxExAQdHzSaoLhERdh0i+STePZu4SuK/ZzmGlfVNZ+pr1EuTdJJ/3Qz1D8nR7Xa+DIW+KZGu4iSRqwQwanl/shhyKZWRkqAB/GTJbeGVMB6Fyogi5xI/YXzFovQaqIcF0zcag0Sv7ja8XiCIlAahkYCAT82wdfM5Fg9VHjVAnUnsFhoADRS2OWr4684rZxBy/lox7RugKRQMUS4J3f2vT9MHN3hvGyfkCAsDxZ/c8lMZIPqv3pUtc4G0S73oTOzslLbGxsZT01nprVg6ZPSYHdpl7/TOfd+71Fr5sd2PnZZH7qGFWkmbDzYuMoGXwML7TV7II84sB9qhq4F8zTNrGdSxsCx1Xcb1nq+pRest7tN3wuRkP6rwIub9jClea4XJb8jOZZ+q5eTT8eBmEkUJGsrMgn2Ynz3he3CbXFVJfoCLfuvxjtTrDNIaZEaQDnkP6iN+wMF2b1JEBOQI+hStNE7/PNQTe+12FL5vrW1r9ocGyeps92xBopohS3Pd0rcgfKKRhm3EHUI2/1WBXlPQLY5ImLLfNYhNKho8mGbuS1DbysQ="
after_sucess:
- codecov

after_success:
- bash <(curl -s https://codecov.io/bash)

2 changes: 1 addition & 1 deletion thunder-clientgui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<dependency>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-core</artifactId>
<version>0.13.1</version>
<version>0.14.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void initialize () throws SQLException {
balanceClient.setText(Coin.valueOf(channel.channelStatus.amountClient).toFriendlyString());
balanceServer.setText(Coin.valueOf(channel.channelStatus.amountServer).toFriendlyString());

labelOpen.setText(new Date(((long) channel.getTimestampOpen()) * 1000).toString());
labelOpen.setText(new Date(((long) channel.timestampOpen) * 1000).toString());

txOpen.setText(Tools.bytesToHex(channel.anchorTx.bitcoinSerialize()));

Expand Down
58 changes: 14 additions & 44 deletions thunder-clientgui/src/main/java/wallettemplate/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import network.thunder.core.ThunderContext;
import network.thunder.core.communication.ServerObject;
import network.thunder.core.database.DBHandler;
import network.thunder.core.database.InMemoryDBHandler;
import network.thunder.core.database.HibernateHandler;
import network.thunder.core.etc.Constants;
import network.thunder.core.helper.callback.results.NullResultCommand;
import network.thunder.core.helper.wallet.MockWallet;
import org.bitcoinj.core.*;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.Wallet;
import wallettemplate.controls.NotificationBarPane;
import wallettemplate.utils.GuiUtils;
import wallettemplate.utils.TextFieldValidator;
Expand All @@ -25,7 +25,6 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static wallettemplate.utils.GuiUtils.*;
Expand All @@ -42,7 +41,7 @@ public class Main extends Application {
public static Wallet wallet;

public static ThunderContext thunderContext;
public static DBHandler dbHandler = new InMemoryDBHandler();
public static DBHandler dbHandler = new HibernateHandler();
public static ServerObject node = new ServerObject();

private StackPane uiStack;
Expand Down Expand Up @@ -84,46 +83,17 @@ private void realStart (Stage mainWindow) throws IOException {
wallet = walletAppKit.wallet();
wallet.allowSpendingUnconfirmedTransactions();
wallet.reset();
wallet.addEventListener(new WalletEventListener() {
@Override
public void onCoinsReceived (Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
System.out.println("wallet = " + wallet);
System.out.println("tx = " + tx);
System.out.println("prevBalance = " + prevBalance);
System.out.println("newBalance = " + newBalance);
}

@Override
public void onCoinsSent (Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
System.out.println("wallet = " + wallet);
System.out.println("tx = " + tx);
System.out.println("prevBalance = " + prevBalance);
System.out.println("newBalance = " + newBalance);
}

@Override
public void onReorganize (Wallet wallet) {

}

@Override
public void onTransactionConfidenceChanged (Wallet wallet, Transaction tx) {

}

@Override
public void onWalletChanged (Wallet wallet) {
}

@Override
public void onScriptsChanged (Wallet wallet, List<Script> scripts, boolean isAddingScripts) {

}

@Override
public void onKeysAdded (List<ECKey> keys) {

}
wallet.addCoinsReceivedEventListener((Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) -> {
System.out.println("wallet = " + wallet);
System.out.println("tx = " + tx);
System.out.println("prevBalance = " + prevBalance);
System.out.println("newBalance = " + newBalance);
});
wallet.addCoinsSentEventListener((Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) -> {
System.out.println("wallet = " + wallet);
System.out.println("tx = " + tx);
System.out.println("prevBalance = " + prevBalance);
System.out.println("newBalance = " + newBalance);
});
System.out.println(wallet.getKeyChainSeed());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import network.thunder.core.helper.callback.results.NullResultCommand;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.DownloadProgressTracker;
import org.bitcoinj.core.listeners.DownloadProgressTracker;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.utils.MonetaryFormat;
import org.fxmisc.easybind.EasyBind;
Expand Down Expand Up @@ -259,7 +259,7 @@ public PaymentWrapper fromString (String string) {
@Override
public String toString (Channel channel) {
return Coin.valueOf(channel.channelStatus.amountServer).toFriendlyString() +
" with " + model.getHostname(Main.dbHandler.getIPObjects(), channel.nodeKeyClient);
" with " + model.getHostname(Main.dbHandler.getIPObjects(), channel.nodeKeyClient.getPubKey());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ void initialize () {

public void update () {

PaymentRequest paymentRequest = Main.thunderContext.receivePayment(getAmount());
if(amount.getText().equals("")) {
amount.setText("0");
}


try {
PaymentRequest paymentRequest = Main.thunderContext.receivePayment(getAmount());

byte[] payload = paymentRequest.getPayload();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import javafx.scene.control.TextField;
import network.thunder.core.etc.Constants;
import org.bitcoinj.core.*;
import org.bitcoinj.wallet.SendRequest;
import org.bitcoinj.wallet.Wallet;
import org.spongycastle.crypto.params.KeyParameter;
import wallettemplate.controls.BitcoinAddressValidator;
import wallettemplate.utils.TextFieldValidator;
Expand Down Expand Up @@ -47,11 +49,11 @@ public void send (ActionEvent event) {
try {
Coin amount = Coin.parseCoin(amountEdit.getText());
Address destination = new Address(Constants.getNetwork(), address.getText());
Wallet.SendRequest req;
SendRequest req;
if (amount.equals(Main.wallet.getBalance())) {
req = Wallet.SendRequest.emptyWallet(destination);
req = SendRequest.emptyWallet(destination);
} else {
req = Wallet.SendRequest.to(destination, amount);
req = SendRequest.to(destination, amount);
}
req.ensureMinRequiredFee = true;
req.feePerKb = Coin.valueOf(5000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import javafx.scene.control.TextField;
import network.thunder.core.communication.layer.high.payments.PaymentSecret;
import network.thunder.core.etc.Tools;
import org.bitcoinj.core.Wallet;
import org.bitcoinj.wallet.Wallet;
import org.spongycastle.crypto.params.KeyParameter;
import wallettemplate.utils.GuiUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import network.thunder.core.etc.Tools;
import network.thunder.core.helper.events.LNEventListener;
import org.bitcoinj.core.*;
import org.bitcoinj.core.listeners.DownloadProgressTracker;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.Wallet;
import wallettemplate.Main;

import java.util.Arrays;
Expand Down Expand Up @@ -65,42 +67,10 @@ public void run () {
}).start();
}
});
Main.wallet.addEventListener(new WalletEventListener() {
@Override
public void onCoinsReceived (Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
update();
}

@Override
public void onCoinsSent (Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
update();
}

@Override
public void onReorganize (Wallet wallet) {

}

@Override
public void onTransactionConfidenceChanged (Wallet wallet, Transaction tx) {
update();
}

@Override
public void onWalletChanged (Wallet wallet) {
update();
}

@Override
public void onScriptsChanged (Wallet wallet, List<Script> scripts, boolean isAddingScripts) {

}

@Override
public void onKeysAdded (List<ECKey> keys) {

}
});
Main.wallet.addCoinsReceivedEventListener((Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) -> update());
Main.wallet.addCoinsSentEventListener((Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) -> update());
Main.wallet.addTransactionConfidenceEventListener((Wallet w, Transaction tx) -> update());
Main.wallet.addChangeEventListener((Wallet w) -> update());
}

public void update () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static void blurOut (Node node) {
GaussianBlur blur = new GaussianBlur(0.0);
node.setEffect(blur);
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
KeyValue kv = new KeyValue(blur.radiusProperty(), 0.0);
KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
timeline.getKeyFrames().add(kf);
timeline.play();
Expand Down
24 changes: 13 additions & 11 deletions thunder-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,13 @@
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/java</source>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -113,7 +103,7 @@
<dependency>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-core</artifactId>
<version>0.13.1</version>
<version>0.14.2</version>
<scope>compile</scope>
</dependency>

Expand Down Expand Up @@ -177,6 +167,18 @@
<version>${kotlin.version}</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.0.Final</version>
</dependency>

<!-- http://mvnrepository.com/artifact/org.hsqldb/hsqldb -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.3</version>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import network.thunder.core.communication.layer.high.payments.PaymentSecret;
import network.thunder.core.communication.layer.high.payments.messages.OnionObject;
import network.thunder.core.database.DBHandler;
import network.thunder.core.database.InMemoryDBHandler;
import network.thunder.core.database.HibernateHandler;
import network.thunder.core.etc.Configuration;
import network.thunder.core.etc.Constants;
import network.thunder.core.etc.Tools;
Expand All @@ -23,7 +23,7 @@
import network.thunder.core.helper.events.LNEventHelperImpl;
import network.thunder.core.helper.wallet.MockWallet;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Wallet;
import org.bitcoinj.wallet.Wallet;
import org.bouncycastle.jce.provider.BouncyCastleProvider;

import java.io.IOException;
Expand Down Expand Up @@ -54,7 +54,7 @@ public static void main (String[] args) throws Exception {
nodesToBuildChannelWith.add(Tools.hexStringToByteArray(s));
}

DBHandler dbHandler = new InMemoryDBHandler();
DBHandler dbHandler = new HibernateHandler();
Wallet wallet = new MockWallet(Constants.getNetwork());

LNEventHelper eventHelper = new LNEventHelperImpl();
Expand Down Expand Up @@ -98,7 +98,7 @@ public static void main (String[] args) throws Exception {
paymentData.onionObject = onionObject;

LNPaymentHelper paymentHelper = contextFactory.getPaymentHelper();
paymentHelper.relayPayment(null, paymentData);
paymentHelper.makePayment(paymentData);

while (true) {
Thread.sleep(100000);
Expand Down
Loading