Skip to content

Commit

Permalink
Merge pull request #16 from alvasw/add_bitcoind_wallet_support
Browse files Browse the repository at this point in the history
Integrate Bitcoind as a wallet backend into Misq
  • Loading branch information
chimp1984 committed Dec 23, 2021
2 parents edb4710 + e103825 commit 3b8b7cc
Show file tree
Hide file tree
Showing 36 changed files with 1,448 additions and 221 deletions.
41 changes: 38 additions & 3 deletions common/src/main/java/network/misq/common/util/FileUtils.java
Expand Up @@ -21,9 +21,8 @@
import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashSet;
import java.util.Objects;
import java.util.Scanner;
Expand Down Expand Up @@ -102,6 +101,42 @@ public static void makeDirIfNotExists(String dirName) throws IOException {
}
}

public static Path createTempDir() throws IOException {
Path tempDirPath = Files.createTempDirectory(null);
recursiveDeleteOnShutdownHook(tempDirPath);
return tempDirPath;
}

public static void recursiveDeleteOnShutdownHook(Path path) {
Runtime.getRuntime().addShutdownHook(new Thread(
() -> {
try {
Files.walkFileTree(path, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file,
@SuppressWarnings("unused") BasicFileAttributes attrs)
throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}

@Override
public FileVisitResult postVisitDirectory(Path dir, IOException e)
throws IOException {
if (e == null) {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
// directory iteration failed
throw e;
}
});
} catch (IOException e) {
throw new RuntimeException("Failed to delete " + path, e);
}
}));
}

public static void makeDirs(String dirPath) throws IOException {
makeDirs(new File(dirPath));
}
Expand Down
15 changes: 14 additions & 1 deletion wallets/build.gradle
Expand Up @@ -4,20 +4,33 @@ plugins {

repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}

apply from: '../buildSrc/misq-version.gradle'
apply from: '../buildSrc/logging-dependencies.gradle'
apply from: '../buildSrc/test-dependencies.gradle'
apply from: '../buildSrc/lombok-dependencies.gradle'

ext {
guavaVersion = '31.0.1-jre'
jsonrpc4jVersion = '1.6.0.bisq.1'
jacksonDatabindVersion = '2.12.0'
}

dependencies {
api platform(project(':platforms:common-platform'))

implementation project(':common')

implementation 'com.google.guava:guava'
implementation ("com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion")
implementation("com.github.bisq-network:jsonrpc4j:$jsonrpc4jVersion") {
exclude(module: 'base64')
exclude(module: 'httpcore-nio')
}
implementation ("com.google.guava:guava:$guavaVersion")
}

test {
useJUnitPlatform()
exclude '**/**Integration*'
Expand Down
17 changes: 17 additions & 0 deletions wallets/src/main/java/network/misq/wallets/AddressType.java
@@ -0,0 +1,17 @@
package network.misq.wallets;

public enum AddressType {
LEGACY("legacy"),
P2SH_SEGWIT("p2sh-segwit"),
BECH32("bech32");

private final String name;

AddressType(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
77 changes: 0 additions & 77 deletions wallets/src/main/java/network/misq/wallets/Bitcoind.java

This file was deleted.

32 changes: 0 additions & 32 deletions wallets/src/main/java/network/misq/wallets/Chain.java

This file was deleted.

66 changes: 0 additions & 66 deletions wallets/src/main/java/network/misq/wallets/Electrum.java

This file was deleted.

42 changes: 0 additions & 42 deletions wallets/src/main/java/network/misq/wallets/Ledger.java

This file was deleted.

18 changes: 18 additions & 0 deletions wallets/src/main/java/network/misq/wallets/NetworkType.java
@@ -0,0 +1,18 @@
package network.misq.wallets;

public enum NetworkType {
MAINNET(8332),
TESTNET(18332),
SIGNET(38332),
REGTEST(18443);

private final int rpcPort;

NetworkType(int rpcPort) {
this.rpcPort = rpcPort;
}

public int getRpcPort() {
return rpcPort;
}
}

0 comments on commit 3b8b7cc

Please sign in to comment.