diff --git a/README.md b/README.md
index 41677adab..e890fe3b8 100644
--- a/README.md
+++ b/README.md
@@ -105,6 +105,9 @@ Adds Sovrin's token functionality to HyperLedger's Indy-SDK.
1. cargo test
+### How to build Libsovtoken from source
+* [Windows](doc/build-guides/windows-build.md)
+
## How To Contribute
diff --git a/devops/Makefile b/devops/Makefile
index 0ed194cfd..5f1427b62 100644
--- a/devops/Makefile
+++ b/devops/Makefile
@@ -45,7 +45,7 @@ FPM_P_VENDOR := Sovrin
FPM_P_DESCRIPTION := libsovtoken written in Rust
FPM_P_NAME = $(PACKAGE_NAME)
FPM_P_VERSION ?= $(SRC_VERSION)
-FPM_P_DEPENDS = libindy(>=1.8.2)
+FPM_P_DEPENDS = libindy(>=1.8.3~1099)
FPM_P_OUTPUT_DIR = $(LIB_TARGET_DIR)
FPM_ARGS = $(LIB_DYNAMIC)=/usr/lib/
diff --git a/devops/aws-codebuild/Jenkinsfile.cd b/devops/aws-codebuild/Jenkinsfile.cd
index f00bcff61..fa56b61d2 100644
--- a/devops/aws-codebuild/Jenkinsfile.cd
+++ b/devops/aws-codebuild/Jenkinsfile.cd
@@ -15,6 +15,8 @@ String srcVersion
gitHubUserCredId = env.GITHUB_BOT_USER ?: 'sovbot-github'
sovrinPackagingRepo = env.SOVRIN_PACKAGING_REPO ?: 'https://github.com/sovrin-foundation/sovrin-packaging'
sovrinPackagingBranch = env.SOVRIN_PACKAGING_BRANCH ?: 'master'
+LIBINDY_STREAM = "master"
+LIBINDY_VERSION = "1.8.3-1099"
def downloadPackagingUtils() {
git branch: sovrinPackagingBranch, credentialsId: gitHubUserCredId, url: sovrinPackagingRepo
@@ -24,7 +26,8 @@ def downloadPackagingUtils() {
// TODO set proper labels
def nodeLabels = [
codeBuild: env.LIBSOVTOKEN_CODEBUILD_NODE_LABEL ?: 'codebuild',
- macos: env.LIBSOVTOKEN_MACOS_NODE_LABEL ?: 'macos',
+ macos : env.LIBSOVTOKEN_MACOS_NODE_LABEL ?: 'macos',
+ windows : env.LIBSOVTOKEN_WINDOWS_NODE_LABEL ?: 'win2016',
]
def codeBuildPipelines = {
@@ -160,11 +163,11 @@ def codeBuildPipelines = {
stage('Set release parameters') {
logger.info("Finding Release version")
// def releaseVersion = env.BRANCH_NAME == 'stable' ? '' : "${lastRevision ? lastRevision[0] + 1: 1}.$BUILD_NUMBER"
- def releaseVersion = env.BRANCH_NAME == 'stable' ? '' : "$BUILD_NUMBER"
+ def releaseVersion = env.BRANCH_NAME == 'stable' ? '' : "$BUILD_NUMBER"
logger.info("Release version for sovrin repo: $releaseVersion")
// debPVersion = utils.packageVersion('deb', srcVersion, releaseVersion, env.BRANCH_NAME == 'master')
- debPVersion = env.BRANCH_NAME == 'stable' ? "$srcVersion": "$srcVersion~$releaseVersion"
+ debPVersion = env.BRANCH_NAME == 'stable' ? "$srcVersion" : "$srcVersion~$releaseVersion"
logger.info("Package version for sovrin repo: $debPVersion")
// TODO crate and rpm
@@ -253,11 +256,11 @@ def codeBuildPipelines = {
}
Map builds = [
- xenial: xenialBuild,
- android: [
- build: androidBuild,
- nodeLabel: "$nodeLabels.codeBuild"
- ]
+ xenial : xenialBuild,
+ android: [
+ build : androidBuild,
+ nodeLabel: "$nodeLabels.codeBuild"
+ ]
]
builds.failFast = false
@@ -277,21 +280,21 @@ def macOSPipeline = {
echo "===================== Checks for XCode and Rust environment ========================"
INSTALLED_XCODE_VERSION = sh(script: '''xcodebuild -version | head -1 | cut -d' ' -f2''', returnStdout: true)
echo "INSTALLED_XCODE_VERSION = ${INSTALLED_XCODE_VERSION} and xcodeMinVersion = ${xcodeMinVersion}"
- if ( INSTALLED_XCODE_VERSION <= xcodeMinVersion ) {
+ if (INSTALLED_XCODE_VERSION <= xcodeMinVersion) {
msg = "The XCode version must be greater or equal ${xcodeMinVersion}"
echo "${msg}"
error(msg)
}
RUST_HOME_EXIST = sh(script: "test -d ${RUST_PATH} && echo '1' || echo '0' ", returnStdout: true).trim()
- if ( RUST_HOME_EXIST == '0' ) {
+ if (RUST_HOME_EXIST == '0') {
msg = "Rust home dir does not exist. Make sure that rust is installed in the ${RUST_PATH}."
echo "${msg}"
error(msg)
}
RUSTC_VERSION = sh(script: "${RUST_PATH}/rustc --version || echo '0' ", returnStdout: true).trim()
- if ( RUSTC_VERSION == '0' ) {
+ if (RUSTC_VERSION == '0') {
msg = "rustc does not exist. Make sure that rust is installed in the ${RUST_PATH}."
echo "${msg}"
error(msg)
@@ -354,18 +357,125 @@ def macosUpload = {
}
}
-pipelineWrapper({
+def windowsOSPipeline = {
+ stage("Windows Testing") {
+ def ws_path = "workspace/${env.JOB_NAME}".replace(' ', '_')
+ ws(ws_path) {
+ try {
+ stage('Checkout sources from SCM') {
+ checkout scm
+ }
+
+ stage('Setup dependencies') {
+ setupRust()
+
+ bat 'wget -O prebuilt.zip "https://repo.sovrin.org/windows/libindy/deps/indy-sdk-deps.zip"'
+ bat 'unzip prebuilt.zip -d prebuilt'
+
+ String mainVersion = LIBINDY_VERSION.split('-').first()
+ bat "wget -O indy.zip \"https://repo.sovrin.org/windows/libindy/$LIBINDY_STREAM/$LIBINDY_VERSION/libindy_${mainVersion}.zip\""
+ bat 'unzip indy.zip -d indy'
+ }
+
+ stage('Run Indy pool') {
+ bat "docker -H $INDY_SDK_SERVER_IP build --build-arg pool_ip=$INDY_SDK_SERVER_IP -f devops/indy-pool/Dockerfile -t indy_pool devops/indy-pool/"
+ bat "docker -H $INDY_SDK_SERVER_IP run -d --network host --name indy_pool -p 9701-9708:9701-9708 indy_pool"
+ }
+
+ stage('Testing') {
+ dir('libsovtoken') {
+ echo "Libsovtoken Testing: Build"
+ withEnv([
+ "OPENSSL_DIR=$WORKSPACE\\prebuilt",
+ "SODIUM_LIB_DIR=$WORKSPACE\\prebuilt\\lib",
+ "LIBINDY_DIR=$WORKSPACE\\indy\\lib",
+ "PATH=$WORKSPACE\\prebuilt\\lib;$WORKSPACE\\indy\\lib;$PATH",
+ "RUST_BACKTRACE=1"
+ ]) {
+ bat "cargo build --release"
+ bat "cargo test --release --no-run"
+
+ echo "Libsovtoken Testing: Run tests"
+ withEnv([
+ "RUST_TEST_THREADS=1",
+ "RUST_LOG=debug",
+ "TEST_POOL_IP=$INDY_SDK_SERVER_IP"
+ ]) {
+ bat "cargo test --release"
+ }
+ }
+
+ stash includes: 'target/release/*.dll,target/release/*.dll.lib', name: 'windowsArtifact'
+ }
+ }
+ } finally {
+ try {
+ bat "docker -H $INDY_SDK_SERVER_IP stop indy_pool"
+ } catch (ignore) {
+ }
+ try {
+ bat "docker -H $INDY_SDK_SERVER_IP rm indy_pool"
+ } catch (ignore) {
+ }
+ cleanWs()
+ }
+ }
+ cleanWs()
+ }
+}
+
+def windowsUpload = {
+ stage('Upload libsovtoken package to Sovrin repo') {
+
+ if (!srcVersion) {
+ stage('Resolve current source version') {
+ srcVersion = utils.srcVersion(projectType: 'rust')
+ logger.info("Current source version: $srcVersion")
+ }
+ }
+
+ sh 'chmod -R 777 devops/windows'
+
+ unstash name: "windowsArtifact"
+
+ withCredentials([file(credentialsId: 'SovrinRepoSSHKey', variable: 'repo_key')]) {
+ withEnv([
+ "SOVRIN_REPO_HOST=$SOVRIN_REPO_HOST",
+ ]) {
+ def suffix = getSuffix()
+ sh "devops/windows/win-zip-and-upload.sh $srcVersion '${repo_key}' $env.BRANCH_NAME $suffix"
+ }
+ }
+ }
+}
+
+def getSuffix() {
+ if (env.BRANCH_NAME == 'master') {
+ return "-$env.BUILD_NUMBER"
+ } else if (env.BRANCH_NAME == 'stable') {
+ return ""
+ } else {
+ error "Invalid branch ${env.BRANCH_NAME}"
+ }
+}
+
+
+ pipelineWrapper({
//put code build containers inside a vpc under our dev account
env.USE_VPC_CONFIG = true
Map builds = [
codeBuild: [
- build: codeBuildPipelines,
+ build : codeBuildPipelines,
nodeLabel: "$nodeLabels.codeBuild"
],
- macos: [
- build: macOSPipeline,
+ macos : [
+ build : macOSPipeline,
nodeLabel: "$nodeLabels.macos"
+ ],
+ windows : [
+ build : windowsOSPipeline,
+ nodeLabel: "$nodeLabels.windows"
]
]
builds.failFast = false
@@ -375,13 +485,17 @@ pipelineWrapper({
}
Map publish = [
- macosPublish: [
- build: macosUpload,
+ macosPublish : [
+ build : macosUpload,
+ nodeLabel: "$nodeLabels.codeBuild"
+ ],
+ windowsPublish: [
+ build : windowsUpload,
nodeLabel: "$nodeLabels.codeBuild"
]
]
- stage ('Publish') {
+ stage('Publish') {
utils.parallel publish
}
}, { err ->
@@ -394,4 +508,8 @@ pipelineWrapper({
notifier.email()
}
}
-})
\ No newline at end of file
+})
+
+def setupRust() {
+ shell("rustup default 1.32.0")
+}
\ No newline at end of file
diff --git a/devops/aws-codebuild/Jenkinsfile.ci b/devops/aws-codebuild/Jenkinsfile.ci
index e7818dae0..4957696e0 100644
--- a/devops/aws-codebuild/Jenkinsfile.ci
+++ b/devops/aws-codebuild/Jenkinsfile.ci
@@ -1,29 +1,97 @@
#!groovy
def sovLibrary = library(identifier: 'sovrin-aws-codebuild@master', retriever: modernSCM(
- github(credentialsId: 'sovbot-github', repoOwner: 'sovrin-foundation', repository: 'aws-codebuild-pipeline-plugin')
+ github(credentialsId: 'sovbot-github', repoOwner: 'sovrin-foundation', repository: 'aws-codebuild-pipeline-plugin')
)).com.sovrin.pipeline
logger = sovLibrary.Logger.new(this)
notifier = sovLibrary.Notifier.new(this)
logger.setGlobalLevel('TRACE')
+LIBINDY_STREAM = "master"
+LIBINDY_VERSION = "1.8.3-1099"
def nodeLabels = [
codeBuild: env.LIBSOVTOKEN_CODEBUILD_NODE_LABEL ?: 'codebuild',
macos: env.LIBSOVTOKEN_MACOS_NODE_LABEL ?: 'macos',
+ windows: env.LIBSOVTOKEN_WINDOWS_NODE_LABEL ?: 'win2016',
]
+def windowsOSPipeline = {
+ stage("Windows Testing") {
+ def ws_path = "workspace/${env.JOB_NAME}".replace(' ', '_')
+ ws(ws_path) {
+ try {
+ stage('Checkout sources from SCM') {
+ checkout scm
+ }
+
+ stage('Setup dependencies'){
+ setupRust()
+
+ bat 'wget -O prebuilt.zip "https://repo.sovrin.org/windows/libindy/deps/indy-sdk-deps.zip"'
+ bat 'unzip prebuilt.zip -d prebuilt'
+
+ String mainVersion = LIBINDY_VERSION.split('-').first()
+ bat "wget -O indy.zip \"https://repo.sovrin.org/windows/libindy/$LIBINDY_STREAM/$LIBINDY_VERSION/libindy_${mainVersion}.zip\""
+ bat 'unzip indy.zip -d indy'
+ }
+
+ stage('Run Indy pool') {
+ bat "docker -H $INDY_SDK_SERVER_IP build --build-arg pool_ip=$INDY_SDK_SERVER_IP -f devops/indy-pool/Dockerfile -t indy_pool devops/indy-pool/"
+ bat "docker -H $INDY_SDK_SERVER_IP run -d --network host --name indy_pool -p 9701-9708:9701-9708 indy_pool"
+ }
+
+ stage('Testing'){
+ dir('libsovtoken') {
+ echo "Libsovtoken Testing: Build"
+ withEnv([
+ "OPENSSL_DIR=$WORKSPACE\\prebuilt",
+ "SODIUM_LIB_DIR=$WORKSPACE\\prebuilt\\lib",
+ "LIBINDY_DIR=$WORKSPACE\\indy\\lib",
+ "PATH=$WORKSPACE\\prebuilt\\lib;$WORKSPACE\\indy\\lib;$PATH",
+ "RUST_BACKTRACE=1"
+ ]) {
+ bat "cargo build"
+ bat "cargo test --no-run"
+
+ echo "Libsovtoken Testing: Run tests"
+ withEnv([
+ "RUST_TEST_THREADS=1",
+ "RUST_LOG=debug",
+ "TEST_POOL_IP=$INDY_SDK_SERVER_IP"
+ ]) {
+ bat "cargo test"
+ }
+ }
+ }
+ }
+ } finally {
+ try {
+ bat "docker -H $INDY_SDK_SERVER_IP stop indy_pool"
+ } catch (ignore) {
+ }
+ try {
+ bat "docker -H $INDY_SDK_SERVER_IP rm indy_pool"
+ } catch (ignore) {
+ }
+ cleanWs()
+ }
+ }
+ cleanWs()
+ }
+}
+
pipelineWrapper({
nodeWrapper(nodeLabels.codeBuild) {
List _envBuildSrc = [
- 'devops',
- 'libsovtoken/Cargo.toml',
- 'libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt',
- 'libsovtoken/build_scripts/android/android_settings.txt'
+ 'devops',
+ 'libsovtoken/Cargo.toml',
+ 'libsovtoken/build_scripts/android/libsovtoken/libsovtoken.dependencies.txt',
+ 'libsovtoken/build_scripts/android/android_settings.txt'
]
List osnames = [
- 'xenial',
- //'centos7'
+ 'xenial',
+ //'centos7'
]
List goals = ['test_dry', 'test']
@@ -47,83 +115,88 @@ pipelineWrapper({
Map builds = osnames.collectEntries { osname ->
[(osname): [
"nodeLabel": nodeLabels.codeBuild,
- "build": {
- def buildImageTag
- def prTag = "ci-$osname"
+ "build" : {
+ def buildImageTag
+ def prTag = "ci-$osname"
- if (osname == 'xenial') {
- stage('Download plugin debs') {
- // TODO remove that code once repo.corp sovrin.com
- // become available from AWS CodeBuild
+ if (osname == 'xenial') {
+ stage('Download plugin debs') {
+ // TODO remove that code once repo.corp sovrin.com
+ // become available from AWS CodeBuild
- // TODO Aptly on repo.copr.sovrin.com removes '+' signs
- // from debian packages making versions in filenames
- // not accurate (it concatenates them):
- // debian package version: +
- // debian package name:
+ // TODO Aptly on repo.copr.sovrin.com removes '+' signs
+ // from debian packages making versions in filenames
+ // not accurate (it concatenates them):
+ // debian package version: +
+ // debian package name:
- def sovtoken_deb_version = "0.9.5"
- def sovtokenfees_deb_version = "0.9.5"
+ def sovtoken_deb_version = "0.9.5"
+ def sovtokenfees_deb_version = "0.9.5"
- sh """
+ sh """
cd ./devops/docker/ci/xenial/
wget --no-check-certificate https://repo.sovrin.org/deb/pool/xenial/stable/s/sovtoken/sovtoken_${sovtoken_deb_version}_amd64.deb
wget --no-check-certificate https://repo.sovrin.org/deb/pool/xenial/stable/s/sovtokenfees/sovtokenfees_${sovtokenfees_deb_version}_amd64.deb
"""
- }
- }
+ }
+ }
- stage("$osname: Resolve image tag") {
- def _imgVersion = utils.shStdout("OSNAME=$osname make -C devops image_lst_ci_version -s")
- buildImageTag = "${_imgVersion}-${osname}-ci"
- logger.info("CI docker image tag: $buildImageTag")
- }
+ stage("$osname: Resolve image tag") {
+ def _imgVersion = utils.shStdout("OSNAME=$osname make -C devops image_lst_ci_version -s")
+ buildImageTag = "${_imgVersion}-${osname}-ci"
+ logger.info("CI docker image tag: $buildImageTag")
+ }
- awsCBHelper.build() {
- projectTag = prTag
-
- // env and build spec
- imageTag = buildImageTag
- buildspec = 'devops/aws-codebuild/buildspec.ci.yml'
- envv = [
- [name: 'OSNAME', value: osname],
- [name: 'MAKE_GOALS', value: "${goals.join(' ')}"],
- [name: 'INDY_POOL_LOG_LEVEL', value: '10'],
- [name: 'INDY_POOL_DIRS', value: '/tmp /var/lib/indy/sandbox /var/log/indy/sandbox'],
- ]
- computeType = 'medium'
-
- // build spec for env image
- envBuildSrc = _envBuildSrc // TODO make more accurate
- envBuildAddPaths = ['./devops/docker/ci/xenial/*.deb']
- envBuildCmds = [
- 'export PROJECT_DIR=$PWD',
- 'make -C devops image_lst_ci'
- ]
- envBuildLocalName = "sovrin/libsovtoken:$buildImageTag"
- envBuildEnvv = [
- [name: 'OSNAME', value: osname],
- [name: 'LST_CI_DOCKER_TAG', value: buildImageTag],
- ]
-
- onArtifacts = {
- this.stage("$osname: Archive artifacts") {
- // make targets' logs
- utils.archiveArtifacts("logs/*.log*") {
- truncate = true
- allowEmptyArchive = true
- truncateFileSuffix = 'trunc.log'
- }
- // nodes' logs and validators info
- utils.archiveArtifacts("logs/pool/*") {
- truncate = false
- allowEmptyArchive = true
+ awsCBHelper.build() {
+ projectTag = prTag
+
+ // env and build spec
+ imageTag = buildImageTag
+ buildspec = 'devops/aws-codebuild/buildspec.ci.yml'
+ envv = [
+ [name: 'OSNAME', value: osname],
+ [name: 'MAKE_GOALS', value: "${goals.join(' ')}"],
+ [name: 'INDY_POOL_LOG_LEVEL', value: '10'],
+ [name: 'INDY_POOL_DIRS', value: '/tmp /var/lib/indy/sandbox /var/log/indy/sandbox'],
+ ]
+ computeType = 'medium'
+
+ // build spec for env image
+ envBuildSrc = _envBuildSrc // TODO make more accurate
+ envBuildAddPaths = ['./devops/docker/ci/xenial/*.deb']
+ envBuildCmds = [
+ 'export PROJECT_DIR=$PWD',
+ 'make -C devops image_lst_ci'
+ ]
+ envBuildLocalName = "sovrin/libsovtoken:$buildImageTag"
+ envBuildEnvv = [
+ [name: 'OSNAME', value: osname],
+ [name: 'LST_CI_DOCKER_TAG', value: buildImageTag],
+ ]
+
+ onArtifacts = {
+ this.stage("$osname: Archive artifacts") {
+ // make targets' logs
+ utils.archiveArtifacts("logs/*.log*") {
+ truncate = true
+ allowEmptyArchive = true
+ truncateFileSuffix = 'trunc.log'
+ }
+ // nodes' logs and validators info
+ utils.archiveArtifacts("logs/pool/*") {
+ truncate = false
+ allowEmptyArchive = true
+ }
+ }
}
}
- }
- }
- }]]
+ }]]
}
+
+ builds.put('windows', [
+ build: windowsOSPipeline,
+ nodeLabel: "$nodeLabels.windows"
+ ])
stage("Build and test") {
builds.failFast = false
@@ -139,3 +212,7 @@ pipelineWrapper({
notifier.email()
}
})
+
+def setupRust() {
+ shell("rustup default 1.32.0")
+}
diff --git a/devops/docker/base/xenial/Dockerfile b/devops/docker/base/xenial/Dockerfile
index a7d72a88f..032dd1a13 100644
--- a/devops/docker/base/xenial/Dockerfile
+++ b/devops/docker/base/xenial/Dockerfile
@@ -21,9 +21,9 @@ RUN cd /tmp \
# need for libsodium to be reachable via pkg-config (sodiumoxide uses it)
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:$PKG_CONFIG_PATH # TODO ??? is it really needed
-ENV LIBINDY_VERSION=1.8.2
+ENV LIBINDY_VERSION=1.8.3~1099
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 \
- && echo "deb https://repo.sovrin.org/sdk/deb xenial stable" >> /etc/apt/sources.list \
+ && echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list \
&& apt-get update && apt-get install -y --no-install-recommends \
libssl-dev \
libindy=${LIBINDY_VERSION} \
@@ -47,4 +47,4 @@ RUN cd /tmp/libsovtoken \
# TODO CMD ENTRYPOINT ...
-ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.19.0
+ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.20.0
diff --git a/devops/docker/ci/xenial/Dockerfile b/devops/docker/ci/xenial/Dockerfile
index 0bebb4f64..f9e0e02d7 100644
--- a/devops/docker/ci/xenial/Dockerfile
+++ b/devops/docker/ci/xenial/Dockerfile
@@ -1,4 +1,4 @@
-FROM sovrin/libsovtoken:base-xenial-0.19.0
+FROM sovrin/libsovtoken:base-xenial-0.20.0
# TODO LABEL maintainer="Name "
ARG LIBINDY_CRYPTO_VERSION
@@ -36,12 +36,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# or python3-rocksdb are not specified here)
ENV LIBINDY_CRYPTO_VERSION ${LIBINDY_CRYPTO_VERSION:-0.4.5}
ENV PYTHON3_INDY_CRYPTO_VERSION ${PYTHON3_INDY_CRYPTO_VERSION:-0.4.5}
-ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.6.53}
-ENV INDY_ANONCREDS_VERSION ${INDY_ANONCREDS_VERSION:-1.0.11}
-ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.6.78}
-ENV TOKEN_VER ${TOKEN_VER:-0.9.5}
-RUN echo "deb https://repo.sovrin.org/sdk/deb xenial stable" >> /etc/apt/sources.list
-RUN echo "deb https://repo.sovrin.org/deb xenial stable" >> /etc/apt/sources.list \
+ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.8.0~dev794}
+ENV INDY_ANONCREDS_VERSION ${INDY_ANONCREDS_VERSION:-1.0.32}
+ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.8.0~dev935}
+ENV TOKEN_VER ${TOKEN_VER:-0.9.6~25}
+RUN echo "deb https://repo.sovrin.org/sdk/deb xenial master" >> /etc/apt/sources.list
+RUN echo "deb https://repo.sovrin.org/deb xenial master" >> /etc/apt/sources.list \
&& apt-get update && apt-get install -y --no-install-recommends \
libindy-crypto=${LIBINDY_CRYPTO_VERSION} \
python3-indy-crypto=${PYTHON3_INDY_CRYPTO_VERSION} \
@@ -69,4 +69,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh
ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"]
-ENV LIBSOVTOKEN_CI_ENV_VERSION=0.55.0
+ENV LIBSOVTOKEN_CI_ENV_VERSION=0.57.0
diff --git a/devops/indy-pool/Dockerfile b/devops/indy-pool/Dockerfile
index b995f0c45..d8e6ed98c 100644
--- a/devops/indy-pool/Dockerfile
+++ b/devops/indy-pool/Dockerfile
@@ -22,12 +22,12 @@ ARG uid=1000
ARG indy_stream=master
-ARG indy_plenum_ver=1.6.735
-ARG indy_node_ver=1.6.874
+ARG indy_plenum_ver=1.8.0~dev794
+ARG indy_node_ver=1.8.0~dev935
ARG python3_indy_crypto_ver=0.4.5
ARG indy_crypto_ver=0.4.5
-ARG token_ver=0.9.6~2
-ARG fees_ver=0.9.6~2
+ARG token_ver=0.9.6~25
+ARG fees_ver=0.9.6~25
# Install environment
RUN apt-get update -y && apt-get install -y \
diff --git a/devops/windows/win-zip-and-upload.sh b/devops/windows/win-zip-and-upload.sh
new file mode 100755
index 000000000..e3c7ed38a
--- /dev/null
+++ b/devops/windows/win-zip-and-upload.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+set -e
+set -x
+
+if [ "$1" = "--help" ] ; then
+ echo "Usage: "
+ return
+fi
+
+version="$1"
+key="$2"
+type="$3"
+suffix="$4"
+
+[ -z $version ] && exit 1
+[ -z $key ] && exit 2
+[ -z $type ] && exit 3
+[ -z $suffix ] && exit 4
+
+PACKAGE_NAME="libsovtoken"
+TEMP_ARCH_DIR=./${PACKAGE_NAME}-zip
+
+mkdir ${TEMP_ARCH_DIR}
+
+cp ./target/release/*.dll ${TEMP_ARCH_DIR}/
+cp ./target/release/*.dll.lib ${TEMP_ARCH_DIR}/
+
+pushd ${TEMP_ARCH_DIR}
+ zip -r ${PACKAGE_NAME}_${version}.zip ./*
+ mv ${PACKAGE_NAME}_${version}.zip ..
+popd
+
+rm -rf ${TEMP_ARCH_DIR}
+
+cat < panic!("Missing required environment variable LIBINDY_DIR")
};
+ let target = env::var("TARGET").unwrap();
+ println!("target={}", target);
+
+ if target.find("-windows-").is_some() {
+ println!("cargo:rustc-link-lib=indy.dll");
+ println!("indy_dir={}", libindy_lib_path);
+ let libindy_lib_path = Path::new(libindy_lib_path.as_str());
+
+ println!("cargo:rustc-flags=-L {}", libindy_lib_path.as_os_str().to_str().unwrap());
+ return;
+ }
+
println!("cargo:rustc-link-search=native={}",libindy_lib_path);
if let Ok(_mode) = env::var("LIBINDY_STATIC") {
@@ -19,8 +31,6 @@ fn main() {
println!("cargo:rustc-link-lib=dylib=indy");
}
- let target = env::var("TARGET").unwrap();
- println!("target={}", target);
if target.contains("linux-android") {
let openssl = match env::var("OPENSSL_LIB_DIR") {
@@ -41,12 +51,5 @@ fn main() {
println!("cargo:rustc-link-lib=dylib=ssl");
println!("cargo:rustc-link-search=native={}", sodium);
println!("cargo:rustc-link-lib=static=sodium");
- }else if target.find("-windows-").is_some() {
- println!("cargo:rustc-link-lib=dylib=ssleay32");
- println!("cargo:rustc-link-lib=dylib=zmq");
- println!("cargo:rustc-link-lib=dylib=sodium");
- let prebuilt_dir = env::var("INDY_PREBUILT_DEPS_DIR").unwrap();
- println!("cargo:rustc-flags=-L {}\\lib", prebuilt_dir);
- return;
}
}
diff --git a/libsovtoken/build_scripts/ios/mac/shared.functions.sh b/libsovtoken/build_scripts/ios/mac/shared.functions.sh
index 6573cefb4..0fef3e720 100644
--- a/libsovtoken/build_scripts/ios/mac/shared.functions.sh
+++ b/libsovtoken/build_scripts/ios/mac/shared.functions.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-export LIBINDY_IOS_BUILD_URL="https://repo.sovrin.org/ios/libindy/stable/libindy-core/1.8.2/libindy.tar.gz"
+export LIBINDY_IOS_BUILD_URL="https://repo.sovrin.org/ios/libindy/stable/libindy-core/1.8.3/libindy.tar.gz"
export LIBINDY_FILE=$(basename ${LIBINDY_IOS_BUILD_URL})
export LIBINDY_VERSION=$(basename $(dirname ${LIBINDY_IOS_BUILD_URL}))
export BUILD_CACHE=~/.build_libvxc/ioscache
diff --git a/libsovtoken/src/api/mod.rs b/libsovtoken/src/api/mod.rs
index 0a5313283..0e2046d72 100644
--- a/libsovtoken/src/api/mod.rs
+++ b/libsovtoken/src/api/mod.rs
@@ -189,7 +189,7 @@ pub extern "C" fn add_request_fees_handler(
cb: JsonCallback
) -> i32 {
- trace!("api::add_request_fees_handler called did (address) >> {:?}", did);
+ trace!("api::add_request_fees_handler called did (address) >> {:?}", secret!(&did));
let (inputs, outputs, extra, request_json_map, cb) = match add_request_fees::deserialize_inputs(req_json, inputs_json, outputs_json, extra, cb) {
Ok(tup) => tup,
Err(error_code) => {
@@ -357,21 +357,22 @@ pub extern "C" fn build_payment_req_handler(
extra: *const c_char,
cb: JsonCallback
) -> i32 {
- trace!("api::build_payment_req_handler called >> submitter_did (address) {:?}", submitter_did);
- let (inputs, outputs, extra, cb) = match build_payment::deserialize_inputs(inputs_json, outputs_json, extra, cb) {
- Ok(tup) => tup,
- Err(error_code) => {
- trace!("api::build_payment_req_handler << result: {:?}", error_code);
- return error_code as i32;
- }
- };
+ trace!("api::build_payment_req_handler called >> submitter_did (address) {:?}", secret!(&submitter_did));
+ let (inputs, outputs, extra, submitter_did, cb) =
+ match build_payment::deserialize_inputs(inputs_json, outputs_json, extra, submitter_did, cb) {
+ Ok(tup) => tup,
+ Err(error_code) => {
+ trace!("api::build_payment_req_handler << result: {:?}", error_code);
+ return error_code as i32;
+ }
+ };
let payload = XferPayload::new(inputs, outputs, extra);
let result = payload.sign_transfer(
&CryptoSdk {},
wallet_handle,
- Box::new(move |result| build_payment::handle_signing(command_handle, result, cb))
+ Box::new(move |result| build_payment::handle_signing(command_handle, result, submitter_did.clone(), cb))
);
let ec = match result {
@@ -479,7 +480,7 @@ pub extern "C" fn build_get_utxo_request_handler(command_handle: i32,
return ErrorCode::CommonInvalidStructure as i32;
}
};
- debug!("api::build_get_utxo_request_handler >> wallet_handle: {:?}, payment_address: {:?}", wallet_handle, payment_address);
+ debug!("api::build_get_utxo_request_handler >> wallet_handle: {:?}, payment_address: {:?}", wallet_handle, secret!(&payment_address));
let utxo_request =
GetUtxoOperationRequest::new(String::from(payment_address));
@@ -656,15 +657,16 @@ pub extern "C" fn build_get_txn_fees_handler(
did.validate().map_err(map_err_trace!()).or(Err(ErrorCode::CommonInvalidStructure))
});
- debug!("api::build_get_txn_fees_handler >> wallet_handle: {:?}, submitter_did: {:?}", wallet_handle, did);
+ debug!("api::build_get_txn_fees_handler >> wallet_handle: {:?}, submitter_did: {:?}", wallet_handle, secret!(&did));
let did = match opt_res_to_res_opt!(did) {
Ok(did) => did,
- Err(e) => { return e as i32; }
+ Err(_) => None
};
+ let did = Some(did.unwrap_or(Did::new("LibsovtokenDid11111111".to_string())));
+
let get_txn_request = GetFeesRequest::new().as_request(did);
- info!("Built GET_TXN_FEES request: {:?}", get_txn_request);
let request_pointer = match get_txn_request.serialize_to_pointer() {
Ok(p) => p,
diff --git a/libsovtoken/src/lib.rs b/libsovtoken/src/lib.rs
index 91f2e9c67..c7c80e066 100644
--- a/libsovtoken/src/lib.rs
+++ b/libsovtoken/src/lib.rs
@@ -33,7 +33,8 @@ extern crate sha2;
// ------------------------------------------
extern crate indy_sys; // lib-sdk project
-extern crate indyrs as indy; // lib-sdk rust wrapper to get ErrorCodes
+extern crate indyrs as indy;
+extern crate core; // lib-sdk rust wrapper to get ErrorCodes
// ------------------------------------------
// define our crate by defining the modules in the project
diff --git a/libsovtoken/src/logic/api_internals/add_request_fees.rs b/libsovtoken/src/logic/api_internals/add_request_fees.rs
index 42e42b36e..a4b08c4ca 100644
--- a/libsovtoken/src/logic/api_internals/add_request_fees.rs
+++ b/libsovtoken/src/logic/api_internals/add_request_fees.rs
@@ -2,7 +2,7 @@
use ErrorCode;
use libc::c_char;
-use logic::xfer_payload::{XferPayload, serialize_signature};
+use logic::xfer_payload::{XferPayload, Extra, serialize_signature};
use logic::input::Inputs;
use logic::output::Outputs;
use serde_json;
@@ -11,12 +11,13 @@ use logic::indy_sdk_api::crypto_api::CryptoSdk;
use utils::constants::txn_types::XFER_PUBLIC;
use utils::constants::txn_fields::FEES;
use utils::constants::general::JsonCallbackUnwrapped;
+use utils::txn_author_agreement::TaaAcceptance;
use sha2::{Sha256, Digest};
use hex::ToHex;
type SerdeMap = serde_json::Map;
type AddRequestFeesCb = extern fn(command_handle_: i32, err: i32, req_with_fees_json: *const c_char) -> i32;
-type DeserializedArguments = (Inputs, Outputs, Option, SerdeMap, AddRequestFeesCb);
+type DeserializedArguments = (Inputs, Outputs, Option, SerdeMap, AddRequestFeesCb);
/**
* Deserializes arguments of [`add_request_fees_handler`]
@@ -28,27 +29,32 @@ pub fn deserialize_inputs (
extra: *const c_char,
cb: Option
) -> Result {
- debug!("logic::add_request_fees::deserialize_inputs >> req_json: {:?}, inputs_json: {:?}, outputs_json: {:?}", req_json, inputs_json, outputs_json);
+ debug!("logic::add_request_fees::deserialize_inputs >> req_json: {:?}, inputs_json: {:?}, outputs_json: {:?}", secret!(&req_json), secret!(&inputs_json), secret!(&outputs_json));
let cb = cb.ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
let request_json = string_from_char_ptr(req_json).ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
- debug!("Converted request_json pointer into string >>> {:?}", request_json);
+ debug!("Converted request_json pointer into string >>> {:?}", secret!(&request_json));
let inputs_json = string_from_char_ptr(inputs_json).ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
- debug!("Converted inputs_json pointer to string >>> {:?}", inputs_json);
+ debug!("Converted inputs_json pointer to string >>> {:?}", secret!(&inputs_json));
let outputs_json = string_from_char_ptr(outputs_json).ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
- debug!("Converted outputs_json pointer to string >>> {:?}", outputs_json);
+ debug!("Converted outputs_json pointer to string >>> {:?}", secret!(&outputs_json));
let extra = string_from_char_ptr(extra);
debug!("Converted extra pointer to string >>> {:?}", extra);
let inputs: Inputs = serde_json::from_str(&inputs_json).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?;
- debug!("Deserialized input_json >>> {:?}", inputs);
+ debug!("Deserialized input_json >>> {:?}", secret!(&inputs));
let outputs: Outputs = serde_json::from_str(&outputs_json).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?;
- debug!("Deserialized output_json >>> {:?}", outputs);
+ debug!("Deserialized output_json >>> {:?}", secret!(&outputs));
+
+ let extra: Option = if let Some(extra_) = extra {
+ serde_json::from_str(&extra_).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?
+ } else { None };
+ debug!("Deserialized extra >>> {:?}", secret!(&extra));
let request_json_object: serde_json::Value = serde_json::from_str(&request_json).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?;
trace!("Converted request_json to serde::json::Value");
@@ -56,7 +62,7 @@ pub fn deserialize_inputs (
let request_json_map = request_json_object.as_object().ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
trace!("Converted request_json to hash_map");
- debug!("Deserialized values: inputs: {:?}, outputs: {:?}, request_json_map: {:?}", inputs, outputs, request_json_map);
+ debug!("Deserialized values: inputs: {:?}, outputs: {:?}, request_json_map: {:?}", secret!(&inputs), secret!(&outputs), secret!(&request_json_map));
return Ok((
inputs,
outputs,
@@ -87,11 +93,11 @@ pub fn add_fees_to_request_and_serialize(
wallet_handle: i32,
inputs: Inputs,
outputs: Outputs,
- extra: Option,
+ extra: Option,
request_json_map: SerdeMap,
cb: Box) + Send + Sync>
) -> Result<(), ErrorCode> {
- trace!("logic::add_request_fees::add_fees_to_request_and_serialize >> wallet_handle: {:?}, inputs: {:?}, outputs: {:?}, request_json_map: {:?}", wallet_handle, inputs, outputs, request_json_map);
+ trace!("logic::add_request_fees::add_fees_to_request_and_serialize >> wallet_handle: {:?}, inputs: {:?}, outputs: {:?}, request_json_map: {:?}", wallet_handle, secret!(&inputs), secret!(&outputs), secret!(&request_json_map));
let res = add_fees(wallet_handle, inputs, outputs, extra, request_json_map, Box::new(move |request_json_map_updated|{
let rm_fees = request_json_map_updated.map(|request_json_map_with_fees| serialize_request_with_fees(request_json_map_with_fees));
match rm_fees {
@@ -123,7 +129,7 @@ pub fn closure_cb_response(command_handle: i32, cb: JsonCallbackUnwrapped) -> im
KEEP all public methods above
*/
-fn add_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option, request_json_map: SerdeMap, cb: Box) + Send + Sync>) -> Result<(), ErrorCode> {
+fn add_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option, request_json_map: SerdeMap, cb: Box) + Send + Sync>) -> Result<(), ErrorCode> {
let txn_serialized = serialize_signature(request_json_map.clone().into())?;
let mut hasher = Sha256::default();
hasher.input(txn_serialized.as_bytes());
@@ -131,7 +137,7 @@ fn add_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option<
signed_fees(wallet_handle, inputs, outputs, extra, &txn_digest, Box::new(move |fees| {
trace!("Added fees to request_json.");
match fees {
- Ok(fees) => {
+ Ok((fees, _)) => {
let mut map = request_json_map.clone();
map.insert(FEES.to_string(), json!([fees.inputs, fees.outputs, fees.signatures]));
cb(Ok(map.clone()));
@@ -146,7 +152,7 @@ fn add_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option<
}
fn serialize_request_with_fees(request_json_map_with_fees: SerdeMap) -> Result {
- trace!("fee_map: {:?}", request_json_map_with_fees);
+ trace!("fee_map: {:?}", secret!(&request_json_map_with_fees));
let serialized_request_with_fees = serde_json::to_string(&json!(request_json_map_with_fees))
.or(Err(ErrorCode::CommonInvalidStructure))?;
trace!("Serialized request_with_fees");
@@ -154,7 +160,7 @@ fn serialize_request_with_fees(request_json_map_with_fees: SerdeMap) -> Result, txn_digest: &Option, cb: Box) + Send + Sync>) -> Result<(), ErrorCode> {
+fn signed_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option, txn_digest: &Option, cb: Box), ErrorCode>) + Send + Sync>) -> Result<(), ErrorCode> {
let fees = XferPayload::new(inputs, outputs, extra);
fees.sign_fees(&CryptoSdk{}, wallet_handle, txn_digest, cb)?;
Ok(())
diff --git a/libsovtoken/src/logic/api_internals/create_address.rs b/libsovtoken/src/logic/api_internals/create_address.rs
index e7a4ea8cd..2ba9a4a24 100644
--- a/libsovtoken/src/logic/api_internals/create_address.rs
+++ b/libsovtoken/src/logic/api_internals/create_address.rs
@@ -29,14 +29,14 @@ pub fn deserialize_arguments(
.ok_or(ErrorCode::CommonInvalidStructure)
.map_err(map_err_err!())?;
- debug!("api::create_payment_address_handler json_config_string >> {:?}", json_config_string);
+ debug!("api::create_payment_address_handler json_config_string >> {:?}", secret!(&json_config_string));
// TODO: Only continue when seed is missing, not on any error.
let config = PaymentAddressConfig::from_json(&json_config_string)
.map_err(map_err_trace!())
.unwrap_or(PaymentAddressConfig { seed: "".to_string() });
- debug!("api::create_payment_address_handler PaymentAddressConfig >> {:?}", config);
+ debug!("api::create_payment_address_handler PaymentAddressConfig >> {:?}", secret!(&config));
Ok((config, cb))
}
@@ -52,7 +52,7 @@ pub fn create_address_cb(command_handle: i32, cb: JsonCallbackUnwrapped) -> impl
return;
}
- debug!("create_payment_address_handler returning payment address of '{}'", &payment_address);
+ debug!("create_payment_address_handler returning payment address of '{}'", secret!(&payment_address));
let payment_address_cstring = cstring_from_str(payment_address);
let payment_address_ptr = payment_address_cstring.as_ptr();
diff --git a/libsovtoken/src/logic/build_payment.rs b/libsovtoken/src/logic/build_payment.rs
index 8186a1f69..5a795d921 100644
--- a/libsovtoken/src/logic/build_payment.rs
+++ b/libsovtoken/src/logic/build_payment.rs
@@ -6,77 +6,100 @@ use serde_json;
use logic::config::payment_config::PaymentRequest;
use logic::input::Inputs;
use logic::output::Outputs;
-use logic::xfer_payload::XferPayload;
+use logic::xfer_payload::{XferPayload, Extra};
use utils::base58::{IntoBase58, FromBase58};
+use utils::txn_author_agreement::TaaAcceptance;
use ErrorCode;
use utils::ffi_support::{string_from_char_ptr, c_pointer_from_str};
+use logic::did::Did;
type BuildPaymentRequestCb = extern fn(ch: i32, err: i32, request_json: *const c_char) -> i32;
-type DeserializedArguments = (Inputs, Outputs, Option, BuildPaymentRequestCb);
+type DeserializedArguments = (Inputs, Outputs, Option, Option, BuildPaymentRequestCb);
pub fn deserialize_inputs(
inputs_json: *const c_char,
outputs_json: *const c_char,
extra: *const c_char,
+ did: *const c_char,
cb: Option
) -> Result {
- trace!("logic::build_payment::deserialize_inputs >> inputs_json: {:?}, outputs_json: {:?}, extra: {:?}", inputs_json, outputs_json, extra);
+ trace!("logic::build_payment::deserialize_inputs >> inputs_json: {:?}, outputs_json: {:?}, extra: {:?}", secret!(&inputs_json), secret!(&outputs_json), secret!(&extra));
let cb = cb.ok_or(ErrorCode::CommonInvalidStructure)?;
let inputs_json = string_from_char_ptr(inputs_json)
.ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
- debug!("Converted inputs_json pointer to string >>> {:?}", inputs_json);
-
+ debug!("Converted inputs_json pointer to string >>> {:?}", secret!(&inputs_json));
+
+ let did = if let Some(did) = Did::from_pointer(did) {
+ Some(did.validate().map_err(map_err_err!()).map_err(|_| ErrorCode::CommonInvalidStructure)?)
+ } else {None};
+ debug!("Converted did pointer to string >>> {:?}", secret!(&did));
+
let outputs_json = string_from_char_ptr(outputs_json)
.ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
- debug!("Converted outputs_json pointer to string >>> {:?}", outputs_json);
+ debug!("Converted outputs_json pointer to string >>> {:?}", secret!(&outputs_json));
let inputs: Inputs = serde_json::from_str(&inputs_json).map_err(map_err_err!())
.or(Err(ErrorCode::CommonInvalidStructure))?;
- debug!("Deserialized input_json >>> {:?}", inputs);
+ debug!("Deserialized input_json >>> {:?}", secret!(&inputs));
let outputs: Outputs = serde_json::from_str(&outputs_json).map_err(map_err_err!())
.or(Err(ErrorCode::CommonInvalidStructure))?;
- debug!("Deserialized output_json >>> {:?}", outputs);
+ debug!("Deserialized output_json >>> {:?}", secret!(&outputs));
let extra = string_from_char_ptr(extra);
- debug!("Deserialized extra >>> {:?}", extra);
+ debug!("Converted extra pointer to string >>> {:?}", extra);
+
+ let extra: Option = if let Some(extra_) = extra {
+ serde_json::from_str(&extra_).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?
+ } else { None };
+ debug!("Deserialized extra >>> {:?}", secret!(&extra));
- trace!("logic::build_payment::deserialize_inputs << inputs: {:?}, outputs: {:?}, extra: {:?}", inputs, outputs, extra);
- return Ok((inputs, outputs, extra, cb));
+ trace!("logic::build_payment::deserialize_inputs << inputs: {:?}, outputs: {:?}, extra: {:?}", secret!(&inputs), secret!(&outputs), secret!(&extra));
+ return Ok((inputs, outputs, extra, did, cb));
}
pub fn handle_signing(
command_handle: i32,
- signed_payload: Result,
+ result: Result<(XferPayload, Option), ErrorCode>,
+ identifier: Option,
cb: BuildPaymentRequestCb
) {
- let (error_code, pointer) = match build_payment_request_pointer(signed_payload) {
+ let (error_code, pointer) = match build_payment_request_pointer(identifier, result) {
Ok(request_pointer) => (ErrorCode::Success, request_pointer),
Err(ec) => (ec, c_pointer_from_str("")),
};
-
+
cb(command_handle, error_code as i32, pointer);
}
fn build_payment_request_pointer(
- signed_payload: Result
+ identifier: Option,
+ result: Result<(XferPayload, Option), ErrorCode>,
) -> Result<*const c_char, ErrorCode> {
- let signed_payload = signed_payload?;
- debug!("Signed payload >>> {:?}", signed_payload);
+ let (signed_payload, taa_acceptance) = result?;
+ debug!("Signed payload >>> {:?}", secret!(&signed_payload));
if signed_payload.signatures.is_none() {
error!("Building an unsigned payment request.");
return Err(ErrorCode::CommonInvalidStructure);
}
- let identifier = signed_payload.inputs[0].address.clone();
- let identifier = identifier.as_bytes().from_base58_check();
- let identifier = identifier.map(|s| s.into_base58()).map_err(|_| ErrorCode::CommonInvalidStructure)?;
+ let identifier = match identifier.map(String::from) {
+ Some(idr) => idr,
+ None => {
+ let addr = signed_payload.inputs[0].address.clone();
+ let idr = addr.as_bytes().from_base58_check();
+ idr.map(|s| s.into_base58()).map_err(|_| ErrorCode::CommonInvalidStructure)?
+ }
+ };
- let payment_request = PaymentRequest::new(signed_payload)
+ let mut payment_request = PaymentRequest::new(signed_payload)
.as_request(identifier);
+
+ payment_request.set_taa_acceptance(taa_acceptance);
+
debug!("payment_request >>> {:?}", payment_request);
return payment_request
@@ -105,31 +128,40 @@ mod test_deserialize_inputs {
inputs_json: Option<*const c_char>,
outputs_json: Option<*const c_char>,
extra: Option<*const c_char>,
+ did: Option<*const c_char>,
cb: Option