Rename bdk-kotlin companion project, fix gradle warnings

This commit is contained in:
Steve Myers 2021-06-14 13:59:56 -07:00
parent 333f694d55
commit 5303de9593
8 changed files with 11 additions and 99 deletions

2
.gitignore vendored
View File

@ -2,7 +2,7 @@ target
build build
Cargo.lock Cargo.lock
*.h *.h
/local.properties /bdk-kotlin/local.properties
.gradle .gradle
wallet_db wallet_db
bdk_ffi_test bdk_ffi_test

View File

@ -1,5 +1,5 @@
[package] [package]
name = "bdk_ffi" name = "bdk-ffi"
version = "0.1.0" version = "0.1.0"
authors = ["Steve Myers <steve@notmandatory.org>"] authors = ["Steve Myers <steve@notmandatory.org>"]
edition = "2018" edition = "2018"

View File

@ -1,43 +0,0 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "bdk_ffi.h"
int main (int argc, char const * const argv[])
{
char const * name = "test_wallet";
char const * desc = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)";
char const * change = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)";
// test new_wallet
{
WalletPtr_t * wallet = new_wallet(name, desc, change);
assert(wallet != NULL);
// test sync_wallet
sync_wallet(wallet);
// test new_address
char * address1 = new_address(wallet);
//printf("address1: %s\n", address1);
assert( 0 == strcmp(address1,"tb1qgkhp034fyxeta00h0nne9tzfm0vsxq4prduzxp"));
free_string(address1);
char * address2 = new_address(wallet);
//printf("address2: %s\n", address2);
assert(0 == strcmp(address2,"tb1qd6u9q327sru2ljvwzdtfrdg36sapax7udz97wf"));
free_string(address2);
// test free_wallet
free_wallet(wallet);
// test free_wallet NULL doesn't crash
free_wallet(NULL);
// verify sync_wallet after sync_wallet fails (double free detected, core dumped)
////sync_wallet(&wallet);
}
return EXIT_SUCCESS;
}

View File

@ -1,22 +0,0 @@
buildscript {
ext.kotlin_version = '1.5.10'
repositories {
//google()
mavenCentral()
}
dependencies {
//classpath 'com.android.tools.build:gradle:3.6.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
//google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -1,13 +1,14 @@
# rust # rust
cargo build cargo build
cargo test --features c-headers -- generate_headers cargo test --features c-headers -- generate_headers
export LD_LIBRARY_PATH=`pwd`/target/debug
# cc # cc
cc bdk_ffi_test.c -o bdk_ffi_test -L target/debug -l bdk_ffi -l pthread -l dl -l m export LD_LIBRARY_PATH=`pwd`/target/debug
#valgrind --leak-check=full ./bdk_ffi_test cc cc/bdk_ffi_test.c -o cc/bdk_ffi_test -L target/debug -l bdk_ffi -l pthread -l dl -l m
./bdk_ffi_test #valgrind --leak-check=full cc/bdk_ffi_test
cc/bdk_ffi_test
# jvm # bdk-kotlin
mkdir -p jvm/build/jniLibs/x86_64_linux mkdir -p bdk-kotlin/jar/libs/x86_64_linux
cp target/debug/libbdk_ffi.so jvm/build/jniLibs/x86_64_linux cp target/debug/libbdk_ffi.so bdk-kotlin/jar/libs/x86_64_linux
(cd bdk-kotlin && gradle test)

View File

@ -1,21 +0,0 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

View File

@ -1,3 +0,0 @@
rootProject.name = 'bdk_ffi'
include 'jvm'

View File

@ -7,6 +7,6 @@ mod wallet;
#[test] #[test]
fn generate_headers() -> ::std::io::Result<()> { fn generate_headers() -> ::std::io::Result<()> {
::safer_ffi::headers::builder() ::safer_ffi::headers::builder()
.to_file("bdk_ffi.h")? .to_file("cc/bdk_ffi.h")?
.generate() .generate()
} }