diff --git a/.travis.yml b/.travis.yml index 5e7bb92aa..c07570bac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,14 @@ sudo: required language: go +go: + - "1.11.x" matrix: include: - - os: linux - dist: xenial - - os: osx + # - os: linux + # dist: xenial + # - os: osx + # osx_image: xcode8.3 + - os: windows before_install: - ./ci-scripts/install-travis-gcc.sh - eval "CC=gcc-6 && CXX=g++-6" diff --git a/Makefile b/Makefile index 50a3ce4c9..21fa45574 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ COIN ?= skycoin +CC = gcc + # Resource paths # --- Absolute path to repository root LIBSRC_ABS_PATH = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) @@ -68,9 +70,9 @@ ifeq ($(UNAME_S),Linux) LDPATH=$(shell printenv LD_LIBRARY_PATH) LDPATHVAR=LD_LIBRARY_PATH LDFLAGS=$(LIBC_FLAGS) $(STDC_FLAG) - OSNAME ?= linux + OSNAME = linux else ifeq ($(UNAME_S),Darwin) - OSNAME ?= osx + OSNAME = osx LDLIBS = $(LIBC_LIBS) LDPATH=$(shell printenv DYLD_LIBRARY_PATH) LDPATHVAR=DYLD_LIBRARY_PATH @@ -80,6 +82,7 @@ else LDPATH=$(shell printenv LD_LIBRARY_PATH) LDPATHVAR=LD_LIBRARY_PATH LDFLAGS=$(LIBC_FLAGS) + OSNAME = win endif configure-build: @@ -153,13 +156,24 @@ docs-libc: ## Generate libskycoin documentation docs: docs-libc docs-skyapi docs-skyhwd ## Generate documentation for all libraries -lint: ## Run linters. Use make install-linters first. +lint-linux: ## Run linters. Use make install-linters first. + vendorcheck ./... + # lib/cgo needs separate linting rules + golangci-lint run -c .golangci.libcgo.yml ./lib/cgo/... + # The govet version in golangci-lint is out of date and has spurious warnings, run it separately + go vet -all ./... + +lint-osx: ## Run linters. Use make install-linters first. vendorcheck ./... # lib/cgo needs separate linting rules golangci-lint run -c .golangci.libcgo.yml ./lib/cgo/... # The govet version in golangci-lint is out of date and has spurious warnings, run it separately go vet -all ./... +lint-win: + +lint: lint-$(OSNAME) + lint-libc: format-libc # Linter LIBC clang-tidy lib/cgo/tests/*.c -- $(LIBC_FLAGS) -Wincompatible-pointer-types @@ -167,28 +181,33 @@ lint-libc: format-libc check: lint test-libc lint-libc test-skyapi ## Run tests and linters -install-linters-Linux: ## Install linters on GNU/Linux +install-linters-linux: ## Install linters on GNU/Linux sudo apt-get update sudo apt-get install $(PKG_CLANG_FORMAT) -y sudo apt-get install $(PKG_CLANG_LINTER) -y -install-linters-Darwin: ## Install linters on Mac OSX +install-linters-win: ## Install linters on Windows + + +install-linters-osx: ## Install linters on Mac OSX # brew install $(PKG_CLANG_FORMAT) brew install llvm ln -s "/usr/local/opt/llvm/bin/clang-format" "/usr/local/bin/clang-format" ln -s "/usr/local/opt/llvm/bin/clang-tidy" "/usr/local/bin/clang-tidy" -install-deps-Linux: ## Install deps on GNU/Linux +install-deps-linux: ## Install deps on GNU/Linux sudo apt-get install $(PKG_LIB_TEST) -install-deps-Darwin: ## Install deps on Mac OSX +install-deps-osx: ## Install deps on Mac OSX brew install $(PKG_LIB_TEST) -install-linters: install-linters-$(UNAME_S) ## Install linters + + +install-linters: install-linters-$(OSNAME) ## Install linters go get -u github.com/FiloSottile/vendorcheck cat ./ci-scripts/install-golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.10.2 -install-deps-skyapi-Linux: +install-deps-skyapi-linux: mkdir -p deps sudo add-apt-repository ppa:george-edison55/cmake-3.x -y sudo apt-get update @@ -198,7 +217,7 @@ install-deps-skyapi-Linux: (cd deps && wget http://curl.haxx.se/download/curl-7.58.0.tar.gz && tar -xvf curl-7.58.0.tar.gz && cd curl-7.58.0/ && ./configure && make && sudo make install) (cd deps && git clone https://github.com/uncrustify/uncrustify.git && cd uncrustify && mkdir build && cd build && cmake .. && make && sudo make install) -install-deps-skyapi-Darwin: +install-deps-skyapi-osx: export LDFLAGS="-L/usr/local/opt/curl/lib" export CPPFLAGS="-I/usr/local/opt/curl/include" mkdir -p deps @@ -206,20 +225,33 @@ install-deps-skyapi-Darwin: brew install openssl curl uncrustify || true (cd deps && wget http://curl.haxx.se/download/curl-7.58.0.tar.gz && tar -xf curl-7.58.0.tar.gz && cd curl-7.58.0/ && mkdir build && cd build && cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .. && make && sudo make install) -install-deps-libc: install-deps-libc-$(UNAME_S) ## Install deps for libc +install-deps-skyapi-win: + mkdir -p C:/program + choco uninstall curl + choco install curl --version=7.58.0 + +install-deps-libc: install-deps-libc-$(OSNAME) ## Install deps for libc -install-deps-skyapi: install-deps-skyapi-$(UNAME_S) ## Install skyapi(libcurl based) library. +install-deps-skyapi: install-deps-skyapi-$(OSNAME) ## Install skyapi(libcurl based) library. -install-deps-libc-Linux: configure-build check-0.12.0/src/.libs/libcheck.so ## Install locally dependencies for testing libskycoin +install-deps-libc-linux: configure-build check-0.12.0/src/.libs/libcheck.so ## Install locally dependencies for testing libskycoin check-0.12.0/src/.libs/libcheck.so: ## Install libcheck wget -c https://github.com/libcheck/check/releases/download/0.12.0/check-0.12.0.tar.gz tar -xzf check-0.12.0.tar.gz cd check-0.12.0 && ./configure --prefix=/usr --disable-static && make && sudo make install -install-deps-libc-Darwin: configure-build ## Install locally dependencies for testing libskycoin +install-deps-libc-osx: configure-build ## Install locally dependencies for testing libskycoin brew install check +install-deps-libc-win: ## Install deps on Windows + # mkdir C:/program + # wget -c https://github.com/libcheck/check/releases/download/0.12.0/check-0.12.0.tar.gz + # tar -xvf check-0.12.0.tar.gz + # cd check-0.12.0 && ./configure --prefix=/usr --disable-static + # cd check-0.12.0 && make + # cd check-0.12.0 && make install + install-deps: install-deps-libc install-deps-skyapi ## Install deps for libc and skyapi format: ## Formats the code. Must have goimports installed (use make install-linters). @@ -231,6 +263,7 @@ clean-libc: ## Clean files generated by libc rm -rfv qemu_test_libskycoin* rm -rfv qemu_* rm -rfv include/libskycoin.h + rm -fv core clean-skyapi: ## Clean files generated by skyapi rm -rfv $(BUILDLIBSKYAPI_DIR) diff --git a/ci-scripts/install-golangci-lint.sh b/ci-scripts/install-golangci-lint.sh index fdec86064..e10f1253c 100755 --- a/ci-scripts/install-golangci-lint.sh +++ b/ci-scripts/install-golangci-lint.sh @@ -71,6 +71,7 @@ is_supported_platform() { windows/386) found=0 ;; linux/amd64) found=0 ;; linux/386) found=0 ;; + msys_nt-10.0/amd64) found=0 ;; esac return $found } @@ -174,7 +175,7 @@ log_crit() { uname_os() { os=$(uname -s | tr '[:upper:]' '[:lower:]') case "$os" in - msys_nt) os="windows" ;; + msys_nt*) os="windows" ;; esac echo "$os" } @@ -355,6 +356,7 @@ PREFIX="$OWNER/$REPO" log_prefix() { echo "$PREFIX" } + PLATFORM="${OS}/${ARCH}" GITHUB_DOWNLOAD=https://github.com/${OWNER}/${REPO}/releases/download diff --git a/ci-scripts/install-travis-gcc.sh b/ci-scripts/install-travis-gcc.sh index d6ad84686..07dda83b7 100755 --- a/ci-scripts/install-travis-gcc.sh +++ b/ci-scripts/install-travis-gcc.sh @@ -3,6 +3,7 @@ if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -qq gcc-6 g++-6 + sudo apt-get install cmake fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then @@ -17,5 +18,12 @@ if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc\@6 || brew link --overwrite gcc\@6 fi +if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + choco install make + choco install pkgconfiglite + choco install sudo + # choco install curl --force --version 7.58.0 +fi + cd $TRAVIS_BUILD_DIR diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/README.md b/vendor/github.com/skycoin/libskycoin/lib/cgo/README.md new file mode 100644 index 000000000..bfec00c5e --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/README.md @@ -0,0 +1,152 @@ + +# Skycoin C client library + +[![Build Status](https://travis-ci.org/skycoin/skycoin.svg)](https://travis-ci.org/skycoin/skycoin) +[![GoDoc](https://godoc.org/github.com/skycoin/skycoin?status.svg)](https://godoc.org/github.com/skycoin/skycoin) +[![Go Report Card](https://goreportcard.com/badge/github.com/skycoin/skycoin)](https://goreportcard.com/report/github.com/skycoin/skycoin) + +Skycoin C client library (a.k.a libskycoin) provides access to Skycoin Core +internal and API functions for implementing third-party applications. + +## API Interface + +The API interface is defined in the [libskycoin header file](/include/libskycoin.h). + +## Building + +```sh +$ make build-libc +``` + +This command compiles wrappers partially generated by [cgogen](https://github.com/simelo/cgogen) tool. + +**Important** : `libskycoin.so` shared library +[can not be compiled on Windows 64 bit systems](t.me/skycoindev/925) due to +[lack of support for c-shared buildmode in golang 1.9](https://github.com/golang/go/issues/23582). +Make sure you have installed a go version higher than `1.10`. + +## Testing + +In order to test the C client libraries follow these steps + +- Install [Criterion](https://github.com/Snaipe/Criterion) + * locally by executing `make instal-deps-libc` command + * or by [installing Criterion system-wide](https://github.com/Snaipe/Criterion#packages) +- Run `make test-libc` command + +## Binary distribution + +The following files will be generated + +- `include/libskycoin.h` - Platform-specific header file for including libskycoin symbols in your app code +- `build/libskycoin.a` - Static library. +- `build/libskycoin.so` - Shared library object. + +In Mac OS X the linker will need extra `-framework CoreFoundation -framework Security` +options. + +In GNU/Linux distributions it will be necessary to load symbols in `pthread` +library e.g. by supplying extra `-lpthread` to the linker toolchain. + + +## API usage + +The C API (a.k.a libskycoin) exposes the internals of Skycoin core +classes and objects. This makes it suitable for writing third-party +applications and integrations. The notable differences between go lang +and C languages have consequences for the consumers of the API. + +The following subsets of the golang API are not available in the C client library: + +- `cipher.encrypt.sha256xor` + +### Data types + +Skycoin core objects may not be passed across API boundaries. Therefore +equivalent C types are defined for each Skycoin core struct that +might be needed by developers. The result of this translation is +available in [skytpes.h](../../include/skytypes.h). + +#### Instances of `time.Time` + +Instances of `time.Time` will be formatted as RFC3339 strings before crossing API boundaries. + +#### Interface types + +At present there is limited support for functions with arguments +of interface types or collections of such types. + +#### Callback functions + +Given the fact that most widely used C language toolchains have no support for +function closures, signatures of API functions with callback parameters differ +from the originals in that they include an additional `void *` parameter +callers can use to supply context information. The very same pointer is passed +in to the callback function itself in a similar manner. + +### Memory management + +Caller is responsible for allocating memory for objects meant to be +created by libskycoin API. Different approaches are chosen to avoid +segmentation faults and memory corruption. + +API functions perform memory allocation for output `GoString *` arguments. +In that case new memory is allocated dynamically by `libskycoin` code. +The caller C code is responsible for releasing that memory by passing the pointer +in `p` field in to [free()](http://en.cppreference.com/w/c/memory/free). + +The parameters corresponding to slices returned by `libskycoin` are +of `GoSlice *` type. Aforementioned approach is also implemented for slices +with `cap` field set to `0` prior to function invocation. +Otherwise their `data` field must always be +set consistently to point at the buffer memory address whereas +`cap` must always be set to the number of items of the +target element type that will fit in the memory +area reserved in advance for that buffer. If the size of the data +to be returned by a given libskycoin function exceeds the value +set in `cap` then libskycoin will copy `cap` items in available +memory space and will set `len` to a negative value representing +the number of extra items that could not be copied due to +overflow. + +For instance if `100` bytes have been allocated in advance +by the caller for a struct type that occupies `25` bytes then only +`4` items fit in that memory and `cap` should be set accordingly. +In the hypothetical situation that `libskycoin` result occupies +`125` bytes (e.g. a slice of same type including `5` items) then +the first `100` bytes will be copied onto C-allocated `data` buffer +and `len` field will be set to `-1` as a side-effect of function +invocation. The caller will be responsible for +[reallocating another memory buffer](http://en.cppreference.com/w/c/memory/realloc) +using a higher `cap` and retry. + +#### Memory handles + +Complex objects represent a challenge to proper memory management, +especially when mutable values move across API boundaries. Hence some objects +always remain managed by `libskycoin` C API. Client applications can refer +to them using memory handles created by multiple functions distributed all over +the API. The memory associated to these objects remains allocated until +`SKY_handle_close` API function is applied upon the corresponding handle +value. + +Opening and closing handles can lead to memory leaks under certain circumstances, +including but not limited to nested scopes, and recursive function calls. +In order to cope with this, the API provides the means to duplicate references to +the same complex object by applying `SKY_handle_copy` function upon an existing +(valid) handle pointing at the object. There are no copy semantics involved for +the object. After the call a new handle reference is created pointing at the same +object referred to by the original handle value. The target will remain allocated +in memory (at least) until all open handles pointing at it will be closed by +invoking `SKY_handle_close` API function. + +## Generating documentation + +Follow these steps to generate API documentation. + +- Install `doxygen` like so: `sudo apt-get install doxygen` +- Install `moxygen` like so: `npm install moxygen -g` +- At the project top-level folder invoke `make docs-libc` (libskycoin docs only) or `make docs` (all docs). + +`doxygen` and `moxygen` generate documentation for cryptographic API. Both are are pre-installed in [`skycoin/skycoindev-cli:develop`](https://hub.docker.com/r/skycoin/skycoindev-cli) Docker image. + diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/api.client.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/api.client.go new file mode 100644 index 000000000..bc9f4c8ad --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/api.client.go @@ -0,0 +1,800 @@ +package main + +import ( + "reflect" + "strings" + "unsafe" + + api "github.com/skycoin/skycoin/src/api" + daemon "github.com/skycoin/skycoin/src/daemon" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_api_NewClient +func SKY_api_NewClient(_addr string, _arg1 *C.Client__Handle) (____error_code uint32) { + addr := _addr + __arg1 := api.NewClient(addr) + *_arg1 = registerClientHandle(__arg1) + return +} + +//export SKY_api_Client_CSRF +func SKY_api_Client_CSRF(_c C.Client__Handle, _arg0 *C.GoString_) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.CSRF() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg0, _arg0) + } + return +} + +//export SKY_api_Client_Version +func SKY_api_Client_Version(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.Version() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerBuildInfoHandle(__arg0) + } + return +} + +//export SKY_api_Client_Outputs +func SKY_api_Client_Outputs(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.Outputs() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_OutputsForAddresses +func SKY_api_Client_OutputsForAddresses(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.OutputsForAddresses(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_OutputsForHashes +func SKY_api_Client_OutputsForHashes(_c C.Client__Handle, _hashes []string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + hashes := *(*[]string)(unsafe.Pointer(&_hashes)) + __arg1, ____return_err := c.OutputsForHashes(hashes) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_CoinSupply +func SKY_api_Client_CoinSupply(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.CoinSupply() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_BlockByHash +func SKY_api_Client_BlockByHash(_c C.Client__Handle, _hash string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + hash := _hash + __arg1, ____return_err := c.BlockByHash(hash) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_BlockBySeq +func SKY_api_Client_BlockBySeq(_c C.Client__Handle, _seq uint64, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + seq := _seq + __arg1, ____return_err := c.BlockBySeq(seq) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_Blocks +func SKY_api_Client_Blocks(_c C.Client__Handle, _seqs []uint64, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg1, ____return_err := c.Blocks(_seqs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_LastBlocks +func SKY_api_Client_LastBlocks(_c C.Client__Handle, _n uint64, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + n := _n + __arg1, ____return_err := c.LastBlocks(n) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_BlockchainMetadata +func SKY_api_Client_BlockchainMetadata(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.BlockchainMetadata() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_BlockchainProgress +func SKY_api_Client_BlockchainProgress(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.BlockchainProgress() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_Balance +func SKY_api_Client_Balance(_c C.Client__Handle, _addrs []string, _arg1 *C.wallet__BalancePair) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.Balance(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.wallet__BalancePair)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_api_Client_UxOut +func SKY_api_Client_UxOut(_c C.Client__Handle, _uxID string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + uxID := _uxID + __arg1, ____return_err := c.UxOut(uxID) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_AddressUxOuts +func SKY_api_Client_AddressUxOuts(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addr := _addr + __arg1, ____return_err := c.AddressUxOuts(addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_Wallet +func SKY_api_Client_Wallet(_c C.Client__Handle, _id string, _arg1 *C.WalletResponse__Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + __arg1, ____return_err := c.Wallet(id) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerWalletResponseHandle(__arg1) + } + return +} + +//export SKY_api_Client_Wallets +func SKY_api_Client_Wallets(_c C.Client__Handle, _arg0 *C.Wallets__Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.Wallets() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerWalletsHandle(&__arg0) + } + return +} + +//export SKY_api_Client_CreateUnencryptedWallet +func SKY_api_Client_CreateUnencryptedWallet(_c C.Client__Handle, _seed, _label string, _scanN int, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + seed := _seed + label := _label + scanN := _scanN + __arg2, ____return_err := c.CreateUnencryptedWallet(seed, label, scanN) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletResponseHandle(__arg2) + } + return +} + +//export SKY_api_Client_CreateEncryptedWallet +func SKY_api_Client_CreateEncryptedWallet(_c C.Client__Handle, _seed, _label, _password string, _scanN int, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + seed := _seed + label := _label + password := _password + scanN := _scanN + __arg2, ____return_err := c.CreateEncryptedWallet(seed, label, password, scanN) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletResponseHandle(__arg2) + } + return +} + +//export SKY_api_Client_NewWalletAddress +func SKY_api_Client_NewWalletAddress(_c C.Client__Handle, _id string, _n int, _password string, _arg3 *C.Strings__Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + n := _n + password := _password + __arg3, ____return_err := c.NewWalletAddress(id, n, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = (C.Strings__Handle)(registerHandle(__arg3)) + } + return +} + +//export SKY_api_Client_WalletBalance +func SKY_api_Client_WalletBalance(_c C.Client__Handle, _id string, _arg1 *C.wallet__BalancePair) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + __arg1, ____return_err := c.WalletBalance(id) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.wallet__BalancePair)(unsafe.Pointer(__arg1)) + } + return +} + +//export SKY_api_Client_Spend +func SKY_api_Client_Spend(_c C.Client__Handle, _id, _dst string, _coins uint64, _password string, _arg3 *C.SpendResult_Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + dst := _dst + coins := _coins + password := _password + __arg3, ____return_err := c.Spend(id, dst, coins, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = registerSpendResultHandle(__arg3) + } + return +} + +//export SKY_api_Client_CreateTransaction +func SKY_api_Client_CreateTransaction(_c C.Client__Handle, _req *C.Handle, _arg1 *C.CreateTransactionResponse__Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + req, okreq := lookupCreateTransactionRequestHandle(C.CreateTransactionRequest__Handle(*_req)) + if !okreq { + ____error_code = SKY_BAD_HANDLE + return + } + __arg1, ____return_err := c.CreateTransaction(*req) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerCreateTransactionResponseHandle(__arg1) + } + return +} + +//export SKY_api_Client_UpdateWallet +func SKY_api_Client_UpdateWallet(_c C.Client__Handle, _id, _label string) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + label := _label + ____return_err := c.UpdateWallet(id, label) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_api_Client_WalletFolderName +func SKY_api_Client_WalletFolderName(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.WalletFolderName() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_NewSeed +func SKY_api_Client_NewSeed(_c C.Client__Handle, _entropy int, _arg1 *C.GoString_) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + entropy := _entropy + __arg1, ____return_err := c.NewSeed(entropy) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_api_Client_WalletSeed +func SKY_api_Client_WalletSeed(_c C.Client__Handle, _id string, _password string, _arg2 *C.GoString_) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + password := _password + __arg2, ____return_err := c.WalletSeed(id, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg2, _arg2) + } + return +} + +//export SKY_api_Client_NetworkConnection +func SKY_api_Client_NetworkConnection(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addr := _addr + __arg1, ____return_err := c.NetworkConnection(addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +type _networkConnectionsFilter struct { + States string + Direction string +} + +func parseNetworkConnectionsFilter(_filter *C.api__NetworkConnectionsFilter, filter *api.NetworkConnectionsFilter) { + __filter := (*_networkConnectionsFilter)(unsafe.Pointer(_filter)) + states := strings.Split(string(__filter.States), ",") + filter.States = make([]daemon.ConnectionState, len(states)) + for i, state := range states { + filter.States[i] = daemon.ConnectionState(state) + } + filter.Direction = string(__filter.Direction) +} + +//export SKY_api_Client_NetworkConnections +func SKY_api_Client_NetworkConnections(_c C.Client__Handle, _filters *C.api__NetworkConnectionsFilter, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + var filters api.NetworkConnectionsFilter + parseNetworkConnectionsFilter(_filters, &filters) + __arg0, ____return_err := c.NetworkConnections(&filters) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_NetworkDefaultPeers +func SKY_api_Client_NetworkDefaultPeers(_c C.Client__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.NetworkDefaultPeers() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_api_Client_NetworkTrustedPeers +func SKY_api_Client_NetworkTrustedPeers(_c C.Client__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.NetworkTrustedPeers() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_api_Client_NetworkExchangedPeers +func SKY_api_Client_NetworkExchangedPeers(_c C.Client__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.NetworkExchangedPeers() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_api_Client_PendingTransactions +func SKY_api_Client_PendingTransactions(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.PendingTransactions() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_Transaction +func SKY_api_Client_Transaction(_c C.Client__Handle, _txid string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + txid := _txid + __arg1, ____return_err := c.Transaction(txid) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_Transactions +func SKY_api_Client_Transactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.Transactions(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_ConfirmedTransactions +func SKY_api_Client_ConfirmedTransactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.ConfirmedTransactions(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_UnconfirmedTransactions +func SKY_api_Client_UnconfirmedTransactions(_c C.Client__Handle, _addrs []string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.UnconfirmedTransactions(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_InjectTransaction +func SKY_api_Client_InjectTransaction(_c C.Client__Handle, _rawTx C.Transaction__Handle, _arg1 *C.GoString_) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + rawTx, okt := lookupTransactionHandle(_rawTx) + if !okt { + ____error_code = SKY_BAD_HANDLE + return + } + + __arg1, ____return_err := c.InjectTransaction(rawTx) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_api_Client_ResendUnconfirmedTransactions +func SKY_api_Client_ResendUnconfirmedTransactions(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.ResendUnconfirmedTransactions() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_RawTransaction +func SKY_api_Client_RawTransaction(_c C.Client__Handle, _txid string, _arg1 *C.GoString_) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + txid := _txid + __arg1, ____return_err := c.RawTransaction(txid) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_api_Client_AddressTransactions +func SKY_api_Client_AddressTransactions(_c C.Client__Handle, _addr string, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addr := _addr + __arg1, ____return_err := c.AddressTransactions(addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_Richlist +func SKY_api_Client_Richlist(_c C.Client__Handle, _params *C.api__RichlistParams, _arg1 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + params := (*api.RichlistParams)(unsafe.Pointer(_params)) + __arg1, ____return_err := c.Richlist(params) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerHandle(__arg1) + } + return +} + +//export SKY_api_Client_AddressCount +func SKY_api_Client_AddressCount(_c C.Client__Handle, _arg0 *uint64) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.AddressCount() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_api_Client_UnloadWallet +func SKY_api_Client_UnloadWallet(_c C.Client__Handle, _id string) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + ____return_err := c.UnloadWallet(id) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_api_Client_Health +func SKY_api_Client_Health(_c C.Client__Handle, _arg0 *C.Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.Health() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerHandle(__arg0) + } + return +} + +//export SKY_api_Client_EncryptWallet +func SKY_api_Client_EncryptWallet(_c C.Client__Handle, _id string, _password string, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + password := _password + __arg2, ____return_err := c.EncryptWallet(id, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletResponseHandle(__arg2) + } + return +} + +//export SKY_api_Client_DecryptWallet +func SKY_api_Client_DecryptWallet(_c C.Client__Handle, _id string, _password string, _arg2 *C.WalletResponse__Handle) (____error_code uint32) { + c, okc := lookupClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + id := _id + password := _password + __arg2, ____return_err := c.DecryptWallet(id, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletResponseHandle(__arg2) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/api.spend.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/api.spend.go new file mode 100644 index 000000000..4f38bac1d --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/api.spend.go @@ -0,0 +1,89 @@ +package main + +import ( + "unsafe" + + api "github.com/skycoin/skycoin/src/api" + cipher "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_api_NewCreateTransactionResponse +func SKY_api_NewCreateTransactionResponse(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.CreateTransactionResponse__Handle) (____error_code uint32) { + txn, ok := lookupTransactionHandle(_txn) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + inputs := *(*[]wallet.UxBalance)(unsafe.Pointer(&_inputs)) + __arg2, ____return_err := api.NewCreateTransactionResponse(txn, inputs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerCreateTransactionResponseHandle(__arg2) + } + return +} + +//export SKY_api_NewCreatedTransaction +func SKY_api_NewCreatedTransaction(_txn C.Transaction__Handle, _inputs []C.wallet__UxBalance, _arg2 *C.CreatedTransaction__Handle) (____error_code uint32) { + txn, ok := lookupTransactionHandle(_txn) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + inputs := *(*[]wallet.UxBalance)(unsafe.Pointer(&_inputs)) + __arg2, ____return_err := api.NewCreatedTransaction(txn, inputs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerCreatedTransactionHandle(__arg2) + } + return +} + +//export SKY_api_CreatedTransaction_ToTransaction +func SKY_api_CreatedTransaction_ToTransaction(_r C.CreatedTransaction__Handle, _arg0 *C.Transaction__Handle) (____error_code uint32) { + r, ok := lookupCreatedTransactionHandle(_r) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := r.ToTransaction() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerTransactionHandle(__arg0) + } + return +} + +//export SKY_api_NewCreatedTransactionOutput +func SKY_api_NewCreatedTransactionOutput(_out *C.coin__TransactionOutput, _txid *C.cipher__SHA256, _arg2 *C.CreatedTransactionOutput__Handle) (____error_code uint32) { + out := *(*coin.TransactionOutput)(unsafe.Pointer(_out)) + txid := *(*cipher.SHA256)(unsafe.Pointer(_txid)) + __arg2, ____return_err := api.NewCreatedTransactionOutput(out, txid) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerCreatedTransactionOutputHandle(__arg2) + } + return +} + +//export SKY_api_NewCreatedTransactionInput +func SKY_api_NewCreatedTransactionInput(_out *C.wallet__UxBalance, _arg1 *C.CreatedTransactionInput__Handle) (____error_code uint32) { + out := *(*wallet.UxBalance)(unsafe.Pointer(_out)) + __arg1, ____return_err := api.NewCreatedTransactionInput(out) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerCreatedTransactionInputHandle(__arg1) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/api.wallet.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/api.wallet.go new file mode 100644 index 000000000..90b218dc5 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/api.wallet.go @@ -0,0 +1,27 @@ +package main + +import api "github.com/skycoin/skycoin/src/api" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_api_NewWalletResponse +func SKY_api_NewWalletResponse(_w C.Wallet__Handle, _arg1 *C.WalletResponse__Handle) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + __arg1, ____return_err := api.NewWalletResponse(w) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerWalletResponseHandle(__arg1) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/api.webrpc.client.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/api.webrpc.client.go new file mode 100644 index 000000000..55ceed0ca --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/api.webrpc.client.go @@ -0,0 +1,158 @@ +package main + +import ( + "reflect" + "unsafe" + + webrpc "github.com/skycoin/skycoin/src/api/webrpc" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_webrpc_NewClient +func SKY_webrpc_NewClient(_addr string, _arg1 *C.WebRpcClient__Handle) (____error_code uint32) { + __arg1, ____return_err := webrpc.NewClient(_addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerWebRpcClientHandle(__arg1) + } + return +} + +//export SKY_webrpc_Client_CSRF +func SKY_webrpc_Client_CSRF(_c C.WebRpcClient__Handle, _arg0 *C.GoString_) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.CSRF() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg0, _arg0) + } + return +} + +//export SKY_webrpc_Client_InjectTransaction +func SKY_webrpc_Client_InjectTransaction(_c C.WebRpcClient__Handle, _tx C.Transaction__Handle, _arg1 *C.GoString_) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + tx, ok := lookupTransactionHandle(_tx) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg1, ____return_err := c.InjectTransaction(tx) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_webrpc_Client_GetStatus +func SKY_webrpc_Client_GetStatus(_c C.WebRpcClient__Handle, _arg0 *C.StatusResult_Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := c.GetStatus() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerStatusResultHandle(__arg0) + } + return +} + +//export SKY_webrpc_Client_GetTransactionByID +func SKY_webrpc_Client_GetTransactionByID(_c C.WebRpcClient__Handle, _txid string, _arg1 *C.TransactionResult_Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + txid := _txid + __arg1, ____return_err := c.GetTransactionByID(txid) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerTransactionResultHandle(__arg1) + } + return +} + +//export SKY_webrpc_Client_GetAddressUxOuts +func SKY_webrpc_Client_GetAddressUxOuts(_c C.WebRpcClient__Handle, _addrs []string, _arg1 *C.GoSlice_) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg1, ____return_err := c.GetAddressUxOuts(addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_webrpc_Client_GetBlocksInRange +func SKY_webrpc_Client_GetBlocksInRange(_c C.WebRpcClient__Handle, _start, _end uint64, _arg1 *C.GoSlice_) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + start := _start + end := _end + __arg1, ____return_err := c.GetBlocksInRange(start, end) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) + } + return +} + +//export SKY_webrpc_Client_GetBlocksBySeq +func SKY_webrpc_Client_GetBlocksBySeq(_c C.WebRpcClient__Handle, _ss []uint64, _arg1 *C.GoSlice_) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + ss := *(*[]uint64)(unsafe.Pointer(&_ss)) + __arg1, ____return_err := c.GetBlocksBySeq(ss) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) + } + return +} + +//export SKY_webrpc_Client_GetLastBlocks +func SKY_webrpc_Client_GetLastBlocks(_c C.WebRpcClient__Handle, _n uint64, _arg1 *C.GoSlice_) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + n := _n + __arg1, ____return_err := c.GetLastBlocks(n) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1.Blocks), _arg1) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.address.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.address.go new file mode 100644 index 000000000..843cb8f5c --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.address.go @@ -0,0 +1,98 @@ +package main + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" +) + +/* + +#include +#include +#include "skytypes.h" +*/ +import "C" + +//export SKY_cipher_DecodeBase58Address +func SKY_cipher_DecodeBase58Address(_addr string, _arg1 *C.cipher__Address) (____error_code uint32) { + addr, err := cipher.DecodeBase58Address(_addr) + ____error_code = libErrorCode(err) + if err == nil { + *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&addr)) + } + return +} + +//export SKY_cipher_AddressFromBytes +func SKY_cipher_AddressFromBytes(_b []byte, _arg1 *C.cipher__Address) (____error_code uint32) { + addr, err := cipher.AddressFromBytes(_b) + ____error_code = libErrorCode(err) + if err == nil { + *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&addr)) + } + return +} + +//export SKY_cipher_AddressFromPubKey +func SKY_cipher_AddressFromPubKey(_pubKey *C.cipher__PubKey, _arg1 *C.cipher__Address) (____error_code uint32) { + pubKey := (*cipher.PubKey)(unsafe.Pointer(_pubKey)) + + addr := cipher.AddressFromPubKey(*pubKey) + *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&addr)) + return +} + +//export SKY_cipher_AddressFromSecKey +func SKY_cipher_AddressFromSecKey(_secKey *C.cipher__SecKey, _arg1 *C.cipher__Address) (____error_code uint32) { + secKey := *(*cipher.SecKey)(unsafe.Pointer(_secKey)) + addr, err := cipher.AddressFromSecKey(secKey) + ____error_code = libErrorCode(err) + if err == nil { + *_arg1 = *(*C.cipher__Address)(unsafe.Pointer(&addr)) + } + return +} + +//export SKY_cipher_Address_Null +func SKY_cipher_Address_Null(_addr *C.cipher__Address, _arg0 *bool) (____error_code uint32) { + + addr := *inplaceAddress(_addr) + __arg0 := addr.Null() + *_arg0 = __arg0 + return +} + +//export SKY_cipher_Address_Bytes +func SKY_cipher_Address_Bytes(_addr *C.cipher__Address, _arg0 *C.GoSlice_) (____error_code uint32) { + addr := (*cipher.Address)(unsafe.Pointer(_addr)) + bytes := addr.Bytes() + copyToGoSlice(reflect.ValueOf(bytes), _arg0) + return +} + +//export SKY_cipher_Address_Verify +func SKY_cipher_Address_Verify(_addr *C.cipher__Address, _key *C.cipher__PubKey) (____error_code uint32) { + addr := (*cipher.Address)(unsafe.Pointer(_addr)) + key := (*cipher.PubKey)(unsafe.Pointer(_key)) + err := addr.Verify(*key) + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_Address_String +func SKY_cipher_Address_String(_addr *C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { + addr := (*cipher.Address)(unsafe.Pointer(_addr)) + s := addr.String() + copyString(s, _arg1) + return +} + +//export SKY_cipher_Address_Checksum +func SKY_cipher_Address_Checksum(_addr *C.cipher__Address, _arg0 *C.cipher__Checksum) (____error_code uint32) { + addr := (*cipher.Address)(unsafe.Pointer(_addr)) + cs := addr.Checksum() + C.memcpy(unsafe.Pointer(_arg0), unsafe.Pointer(&cs[0]), C.size_t(len(cs))) + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.base58.base58.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.base58.base58.go new file mode 100644 index 000000000..29b43e76a --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.base58.base58.go @@ -0,0 +1,45 @@ +package main + +import ( + "reflect" + "unsafe" + + "github.com/skycoin/skycoin/src/cipher/base58" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_base58_Hex2Base58 +func SKY_base58_Hex2Base58(_val []byte, _arg1 *C.GoString_) (____error_code uint32) { + val := *(*[]byte)(unsafe.Pointer(&_val)) + __arg1 := string(base58.Encode(val)) + copyString(__arg1, _arg1) + return +} + +//export SKY_base58_Encode +func SKY_base58_Encode(_bin []byte, _arg1 *C.GoString_) (____error_code uint32) { + bin := *(*[]byte)(unsafe.Pointer(&_bin)) + __arg1 := base58.Encode(bin) + copyString(__arg1, _arg1) + return +} + +//export SKY_base58_Decode +func SKY_base58_Decode(_s string, _arg1 *C.GoSlice_) (____error_code uint32) { + s := _s + __arg1, ____return_err := base58.Decode(s) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.bitcoin.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.bitcoin.go new file mode 100644 index 000000000..34f140288 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.bitcoin.go @@ -0,0 +1,112 @@ +package main + +/* +#include +#include + +#include "skytypes.h" + +*/ +import "C" + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" +) + +/** + * Functions in github.com/skycoin/skycoin/src/cipher/bitcoin.go + */ + +//export SKY_cipher_DecodeBase58BitcoinAddress +func SKY_cipher_DecodeBase58BitcoinAddress(_addr string, _arg1 *C.cipher__BitcoinAddress) uint32 { + addr, err := cipher.DecodeBase58BitcoinAddress(_addr) + errcode := libErrorCode(err) + if err == nil { + *_arg1 = *(*C.cipher__BitcoinAddress)(unsafe.Pointer(&addr)) + } + return errcode +} + +//export SKY_cipher_BitcoinAddressFromPubKey +func SKY_cipher_BitcoinAddressFromPubKey(_pubKey *C.cipher__PubKey, _arg1 *C.cipher__BitcoinAddress) { + pubKey := (*cipher.PubKey)(unsafe.Pointer(_pubKey)) + + addr := cipher.BitcoinAddressFromPubKey(*pubKey) + *_arg1 = *(*C.cipher__BitcoinAddress)(unsafe.Pointer(&addr)) +} + +//export SKY_cipher_BitcoinAddressFromSecKey +func SKY_cipher_BitcoinAddressFromSecKey(_secKey *C.cipher__SecKey, _arg1 *C.cipher__BitcoinAddress) uint32 { + secKey := (*cipher.SecKey)(unsafe.Pointer(_secKey)) + + addr, err := cipher.BitcoinAddressFromSecKey(*secKey) + if err == nil { + *_arg1 = *(*C.cipher__BitcoinAddress)(unsafe.Pointer(&addr)) + } + return libErrorCode(err) +} + +//export SKY_cipher_BitcoinWalletImportFormatFromSeckey +func SKY_cipher_BitcoinWalletImportFormatFromSeckey(_seckey *C.cipher__SecKey, _arg1 *C.GoString_) { + seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) + s := cipher.BitcoinWalletImportFormatFromSeckey(*seckey) + copyString(s, _arg1) +} + +//export SKY_cipher_BitcoinAddressFromBytes +func SKY_cipher_BitcoinAddressFromBytes(_b []byte, _arg1 *C.cipher__BitcoinAddress) uint32 { + addr, err := cipher.BitcoinAddressFromBytes(_b) + errcode := libErrorCode(err) + if err == nil { + *_arg1 = *(*C.cipher__BitcoinAddress)(unsafe.Pointer(&addr)) + } + return errcode +} + +//export SKY_cipher_SecKeyFromBitcoinWalletImportFormat +func SKY_cipher_SecKeyFromBitcoinWalletImportFormat(_input string, _arg1 *C.cipher__SecKey) uint32 { + seckey, err := cipher.SecKeyFromBitcoinWalletImportFormat(_input) + errcode := libErrorCode(err) + if err == nil { + *_arg1 = *(*C.cipher__SecKey)(unsafe.Pointer(&seckey)) + } + return errcode +} + +//export SKY_cipher_BitcoinAddress_Null +func SKY_cipher_BitcoinAddress_Null(_addr *C.cipher__BitcoinAddress) bool { + addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr)) + return addr.Null() +} + +//export SKY_cipher_BitcoinAddress_Bytes +func SKY_cipher_BitcoinAddress_Bytes(_addr *C.cipher__BitcoinAddress, _arg0 *C.GoSlice_) { + addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr)) + bytes := addr.Bytes() + copyToGoSlice(reflect.ValueOf(bytes), _arg0) +} + +//export SKY_cipher_BitcoinAddress_Verify +func SKY_cipher_BitcoinAddress_Verify(_addr *C.cipher__BitcoinAddress, _key *C.cipher__PubKey) uint32 { + addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr)) + key := (*cipher.PubKey)(unsafe.Pointer(_key)) + err := addr.Verify(*key) + return libErrorCode(err) +} + +//export SKY_cipher_BitcoinAddress_String +func SKY_cipher_BitcoinAddress_String(_addr *C.cipher__BitcoinAddress, _arg1 *C.GoString_) { + addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr)) + s := addr.String() + copyString(s, _arg1) +} + +//export SKY_cipher_BitcoinAddress_Checksum +func SKY_cipher_BitcoinAddress_Checksum(_addr *C.cipher__BitcoinAddress, _arg0 *C.cipher__Checksum) { + addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr)) + cs := addr.Checksum() + C.memcpy(unsafe.Pointer(_arg0), unsafe.Pointer(&cs[0]), C.size_t(len(cs))) +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.crypto.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.crypto.go new file mode 100644 index 000000000..dfd6468a7 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.crypto.go @@ -0,0 +1,297 @@ +package main + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cipher_RandByte +func SKY_cipher_RandByte(_n int, _arg1 *C.GoSlice_) (____error_code uint32) { + b := cipher.RandByte(_n) + copyToGoSlice(reflect.ValueOf(b), _arg1) + return +} + +//export SKY_cipher_NewPubKey +func SKY_cipher_NewPubKey(_b []byte, _arg1 *C.cipher__PubKey) (____error_code uint32) { + pubkey, err := cipher.NewPubKey(_b) + if err == nil { + copyToBuffer(reflect.ValueOf(pubkey[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) + } + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_PubKeyFromHex +func SKY_cipher_PubKeyFromHex(_s string, _arg1 *C.cipher__PubKey) (____error_code uint32) { + pubkey, err := cipher.PubKeyFromHex(_s) + ____error_code = libErrorCode(err) + if err == nil { + copyToBuffer(reflect.ValueOf(pubkey[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) + } + return +} + +//export SKY_cipher_PubKeyFromSecKey +func SKY_cipher_PubKeyFromSecKey(_seckey *C.cipher__SecKey, _arg1 *C.cipher__PubKey) (____error_code uint32) { + seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) + + pubkey, err := cipher.PubKeyFromSecKey(*seckey) + ____error_code = libErrorCode(err) + + if err == nil { + copyToBuffer(reflect.ValueOf(pubkey[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) + } + + return +} + +//export SKY_cipher_PubKeyFromSig +func SKY_cipher_PubKeyFromSig(_sig *C.cipher__Sig, _hash *C.cipher__SHA256, _arg2 *C.cipher__PubKey) (____error_code uint32) { + sig := (*cipher.Sig)(unsafe.Pointer(_sig)) + hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) + + pubkey, err := cipher.PubKeyFromSig(*sig, *hash) + + errcode := libErrorCode(err) + if err == nil { + copyToBuffer(reflect.ValueOf(pubkey[:]), unsafe.Pointer(_arg2), uint(SizeofPubKey)) + + } + ____error_code = errcode + return +} + +//export SKY_cipher_PubKey_Verify +func SKY_cipher_PubKey_Verify(_pk *C.cipher__PubKey) (____error_code uint32) { + pk := (*cipher.PubKey)(unsafe.Pointer(_pk)) + + err := pk.Verify() + errcode := libErrorCode(err) + ____error_code = errcode + return +} + +//export SKY_cipher_PubKey_Hex +func SKY_cipher_PubKey_Hex(_pk *C.cipher__PubKey, _arg1 *C.GoString_) (____error_code uint32) { + pk := (*cipher.PubKey)(unsafe.Pointer(_pk)) + s := pk.Hex() + copyString(s, _arg1) + return SKY_OK +} + +//export SKY_cipher_PubKeyRipemd160 +func SKY_cipher_PubKeyRipemd160(_pk *C.cipher__PubKey, _arg0 *C.cipher__Ripemd160) (____error_code uint32) { + pk := (*cipher.PubKey)(unsafe.Pointer(_pk)) + h := cipher.PubKeyRipemd160(*pk) + copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg0), uint(SizeofRipemd160)) + return +} + +//export SKY_cipher_NewSecKey +func SKY_cipher_NewSecKey(_b []byte, _arg1 *C.cipher__SecKey) (____error_code uint32) { + sk, err := cipher.NewSecKey(_b) + if err == nil { + copyToBuffer(reflect.ValueOf(sk[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) + } + + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_SecKeyFromHex +func SKY_cipher_SecKeyFromHex(_s string, _arg1 *C.cipher__SecKey) (____error_code uint32) { + sk, err := cipher.SecKeyFromHex(_s) + errcode := libErrorCode(err) + if err == nil { + copyToBuffer(reflect.ValueOf(sk[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) + } + ____error_code = errcode + return +} + +//export SKY_cipher_SecKey_Verify +func SKY_cipher_SecKey_Verify(_sk *C.cipher__SecKey) (____error_code uint32) { + sk := (*cipher.SecKey)(unsafe.Pointer(_sk)) + err := sk.Verify() + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_SecKey_Hex +func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *C.GoString_) (____error_code uint32) { + sk := (*cipher.SecKey)(unsafe.Pointer(_sk)) + s := sk.Hex() + copyString(s, _arg1) + return +} + +//export SKY_cipher_ECDH +func SKY_cipher_ECDH(_pub *C.cipher__PubKey, _sec *C.cipher__SecKey, _arg2 *C.GoSlice_) (____error_code uint32) { + pub := (*cipher.PubKey)(unsafe.Pointer(_pub)) + sec := (*cipher.SecKey)(unsafe.Pointer(_sec)) + b, err := cipher.ECDH(*pub, *sec) + ____error_code = libErrorCode(err) + if err == nil { + copyToGoSlice(reflect.ValueOf(b), _arg2) + } + return +} + +//export SKY_cipher_NewSig +func SKY_cipher_NewSig(_b []byte, _arg1 *C.cipher__Sig) (____error_code uint32) { + s, err := cipher.NewSig(_b) + if err == nil { + copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg1), uint(SizeofSig)) + } + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_SigFromHex +func SKY_cipher_SigFromHex(_s string, _arg1 *C.cipher__Sig) (____error_code uint32) { + s, err := cipher.SigFromHex(_s) + errcode := libErrorCode(err) + if err == nil { + copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg1), uint(SizeofSig)) + } + ____error_code = errcode + return +} + +//export SKY_cipher_Sig_Hex +func SKY_cipher_Sig_Hex(_s *C.cipher__Sig, _arg1 *C.GoString_) (____error_code uint32) { + s := (*cipher.Sig)(unsafe.Pointer(_s)) + copyString(s.Hex(), _arg1) + return +} + +//export SKY_cipher_SignHash +func SKY_cipher_SignHash(_hash *C.cipher__SHA256, _sec *C.cipher__SecKey, _arg2 *C.cipher__Sig) (____error_code uint32) { + hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) + sec := (*cipher.SecKey)(unsafe.Pointer(_sec)) + s, err := cipher.SignHash(*hash, *sec) + ____error_code = libErrorCode(err) + if err == nil { + copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg2), uint(SizeofSig)) + } + return +} + +//export SKY_cipher_VerifyAddressSignedHash +func SKY_cipher_VerifyAddressSignedHash(_address *C.cipher__Address, _sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { + address := inplaceAddress(_address) + hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) + sig := (*cipher.Sig)(unsafe.Pointer(_sig)) + + err := cipher.VerifyAddressSignedHash(*address, *sig, *hash) + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_VerifySignedHash +func SKY_cipher_VerifySignedHash(_sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { + hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) + sig := (*cipher.Sig)(unsafe.Pointer(_sig)) + + err := cipher.VerifySignedHash(*sig, *hash) + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_VerifyPubKeySignedHash +func SKY_cipher_VerifyPubKeySignedHash(_pubkey *C.cipher__PubKey, _sig *C.cipher__Sig, _hash *C.cipher__SHA256) (____error_code uint32) { + pubkey := (*cipher.PubKey)(unsafe.Pointer(_pubkey)) + sig := (*cipher.Sig)(unsafe.Pointer(_sig)) + hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) + + err := cipher.VerifyPubKeySignedHash(*pubkey, *sig, *hash) + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_GenerateKeyPair +func SKY_cipher_GenerateKeyPair(_arg0 *C.cipher__PubKey, _arg1 *C.cipher__SecKey) (____error_code uint32) { + p, s := cipher.GenerateKeyPair() + copyToBuffer(reflect.ValueOf(p[:]), unsafe.Pointer(_arg0), uint(SizeofPubKey)) + copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg1), uint(SizeofSecKey)) + return +} + +//export SKY_cipher_GenerateDeterministicKeyPair +func SKY_cipher_GenerateDeterministicKeyPair(_seed []byte, _arg1 *C.cipher__PubKey, _arg2 *C.cipher__SecKey) (____error_code uint32) { + p, s, err := cipher.GenerateDeterministicKeyPair(_seed) + if err == nil { + copyToBuffer(reflect.ValueOf(p[:]), unsafe.Pointer(_arg1), uint(SizeofPubKey)) + copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg2), uint(SizeofSecKey)) + } + + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_DeterministicKeyPairIterator +func SKY_cipher_DeterministicKeyPairIterator(_seed []byte, _arg1 *C.GoSlice_, _arg2 *C.cipher__PubKey, _arg3 *C.cipher__SecKey) (____error_code uint32) { + h, p, s, err := cipher.DeterministicKeyPairIterator(_seed) + ____error_code = libErrorCode(err) + + if err == nil { + copyToGoSlice(reflect.ValueOf(h), _arg1) + copyToBuffer(reflect.ValueOf(p[:]), unsafe.Pointer(_arg2), uint(SizeofPubKey)) + copyToBuffer(reflect.ValueOf(s[:]), unsafe.Pointer(_arg3), uint(SizeofSecKey)) + } + + return +} + +//export SKY_cipher_GenerateDeterministicKeyPairs +func SKY_cipher_GenerateDeterministicKeyPairs(_seed []byte, _n int, _arg2 *C.GoSlice_) (____error_code uint32) { + sks, err := cipher.GenerateDeterministicKeyPairs(_seed, _n) + ____error_code = libErrorCode(err) + if err == nil { + copyToGoSlice(reflect.ValueOf(sks), _arg2) + } + + return +} + +//export SKY_cipher_GenerateDeterministicKeyPairsSeed +func SKY_cipher_GenerateDeterministicKeyPairsSeed(_seed []byte, _n int, _arg2 *C.GoSlice_, _arg3 *C.GoSlice_) (____error_code uint32) { + h, sks, err := cipher.GenerateDeterministicKeyPairsSeed(_seed, _n) + if err == nil { + copyToGoSlice(reflect.ValueOf(h), _arg2) + copyToGoSlice(reflect.ValueOf(sks), _arg3) + } + + return +} + +//export SKY_cipher_CheckSecKey +func SKY_cipher_CheckSecKey(_seckey *C.cipher__SecKey) (____error_code uint32) { + seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) + + err := cipher.CheckSecKey(*seckey) + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_CheckSecKeyHash +func SKY_cipher_CheckSecKeyHash(_seckey *C.cipher__SecKey, _hash *C.cipher__SHA256) (____error_code uint32) { + seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) + hash := (*cipher.SHA256)(unsafe.Pointer(_hash)) + + err := cipher.CheckSecKeyHash(*seckey, *hash) + ____error_code = libErrorCode(err) + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go new file mode 100644 index 000000000..6141b8401 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.encrypt.scrypt_chacha20poly1305.go @@ -0,0 +1,44 @@ +package main + +import ( + "reflect" + "unsafe" + + encrypt "github.com/skycoin/skycoin/src/cipher/encrypt" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_encrypt_ScryptChacha20poly1305_Encrypt +func SKY_encrypt_ScryptChacha20poly1305_Encrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + + s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s)) + data := *(*[]byte)(unsafe.Pointer(&_data)) + password := *(*[]byte)(unsafe.Pointer(&_password)) + __arg1, ____return_err := s.Encrypt(data, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_encrypt_ScryptChacha20poly1305_Decrypt +func SKY_encrypt_ScryptChacha20poly1305_Decrypt(_s *C.encrypt__ScryptChacha20poly1305, _data []byte, _password []byte, _arg1 *C.GoSlice_) (____error_code uint32) { + s := *(*encrypt.ScryptChacha20poly1305)(unsafe.Pointer(_s)) + data := *(*[]byte)(unsafe.Pointer(&_data)) + password := *(*[]byte)(unsafe.Pointer(&_password)) + __arg1, ____return_err := s.Decrypt(data, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.go-bip39.bip39.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.go-bip39.bip39.go new file mode 100644 index 000000000..a0a88c00c --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.go-bip39.bip39.go @@ -0,0 +1,68 @@ +package main + +import ( + "reflect" + "unsafe" + + gobip39 "github.com/skycoin/skycoin/src/cipher/go-bip39" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_bip39_NewDefaultMnemomic +func SKY_bip39_NewDefaultMnemomic(_arg0 *C.GoString_) (____error_code uint32) { + __arg0, ____return_err := gobip39.NewDefaultMnemonic() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg0, _arg0) + } + return +} + +//export SKY_bip39_NewEntropy +func SKY_bip39_NewEntropy(_bitSize int, _arg1 *C.GoSlice_) (____error_code uint32) { + bitSize := _bitSize + __arg1, ____return_err := gobip39.NewEntropy(bitSize) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_bip39_NewMnemonic +func SKY_bip39_NewMnemonic(_entropy []byte, _arg1 *C.GoString_) (____error_code uint32) { + entropy := *(*[]byte)(unsafe.Pointer(&_entropy)) + __arg1, ____return_err := gobip39.NewMnemonic(entropy) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_bip39_MnemonicToByteArray +func SKY_bip39_MnemonicToByteArray(_mnemonic string, _arg1 *C.GoSlice_) (____error_code uint32) { + mnemonic := _mnemonic + __arg1, ____return_err := gobip39.MnemonicToByteArray(mnemonic) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_bip39_IsMnemonicValid +func SKY_bip39_IsMnemonicValid(_mnemonic string, _arg1 *bool) (____error_code uint32) { + mnemonic := _mnemonic + __arg1 := gobip39.IsMnemonicValid(mnemonic) + *_arg1 = __arg1 + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.hash.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.hash.go new file mode 100644 index 000000000..3509e2e15 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cipher.hash.go @@ -0,0 +1,110 @@ +package main + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cipher_Ripemd160_Set +func SKY_cipher_Ripemd160_Set(_rd *C.cipher__Ripemd160, _b []byte) (____error_code uint32) { + rd := (*cipher.Ripemd160)(unsafe.Pointer(_rd)) + + err := rd.Set(_b) + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_HashRipemd160 +func SKY_cipher_HashRipemd160(_data []byte, _arg1 *C.cipher__Ripemd160) (____error_code uint32) { + rd := cipher.HashRipemd160(_data) + + copyToBuffer(reflect.ValueOf(rd[:]), unsafe.Pointer(_arg1), uint(SizeofRipemd160)) + return +} + +//export SKY_cipher_SHA256_Set +func SKY_cipher_SHA256_Set(_g *C.cipher__SHA256, _b []byte) (____error_code uint32) { + g := (*cipher.SHA256)(unsafe.Pointer(_g)) + + err := g.Set(_b) + ____error_code = libErrorCode(err) + return +} + +//export SKY_cipher_SHA256_Hex +func SKY_cipher_SHA256_Hex(_g *C.cipher__SHA256, _arg1 *C.GoString_) (____error_code uint32) { + g := (*cipher.SHA256)(unsafe.Pointer(_g)) + copyString(g.Hex(), _arg1) + return +} + +//export SKY_cipher_SHA256_Xor +func SKY_cipher_SHA256_Xor(_g *C.cipher__SHA256, _b *C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____error_code uint32) { + g := (*cipher.SHA256)(unsafe.Pointer(_g)) + b := (*cipher.SHA256)(unsafe.Pointer(_b)) + + x := g.Xor(*b) + copyToBuffer(reflect.ValueOf(x[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) + return +} + +//export SKY_cipher_SumSHA256 +func SKY_cipher_SumSHA256(_b []byte, _arg1 *C.cipher__SHA256) (____error_code uint32) { + h := cipher.SumSHA256(_b) + + copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) + return +} + +//export SKY_cipher_SHA256FromHex +func SKY_cipher_SHA256FromHex(_hs string, _arg1 *C.cipher__SHA256) (____error_code uint32) { + h, err := cipher.SHA256FromHex(_hs) + ____error_code = libErrorCode(err) + if err == nil { + copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) + } + return +} + +//export SKY_cipher_DoubleSHA256 +func SKY_cipher_DoubleSHA256(_b []byte, _arg1 *C.cipher__SHA256) (____error_code uint32) { + h := cipher.DoubleSHA256(_b) + copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) + return +} + +//export SKY_cipher_AddSHA256 +func SKY_cipher_AddSHA256(_a *C.cipher__SHA256, _b *C.cipher__SHA256, _arg2 *C.cipher__SHA256) (____error_code uint32) { + a := (*cipher.SHA256)(unsafe.Pointer(_a)) + b := (*cipher.SHA256)(unsafe.Pointer(_b)) + + h := cipher.AddSHA256(*a, *b) + copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg2), uint(SizeofSHA256)) + return +} + +//export SKY_cipher_Merkle +func SKY_cipher_Merkle(_h0 *[]C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____error_code uint32) { + h0 := (*[]cipher.SHA256)(unsafe.Pointer(_h0)) + h := cipher.Merkle(*h0) + copyToBuffer(reflect.ValueOf(h[:]), unsafe.Pointer(_arg1), uint(SizeofSHA256)) + return +} + +//export SKY_cipher_SHA256_Null +func SKY_cipher_SHA256_Null(_g *C.cipher__SHA256, _arg0 *bool) (____error_code uint32) { + g := (*cipher.SHA256)(unsafe.Pointer(_g)) + *_arg0 = g.Null() + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.add_private_key.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.add_private_key.go new file mode 100644 index 000000000..2620fe7aa --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.add_private_key.go @@ -0,0 +1,45 @@ +package main + +import ( + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_AddPrivateKey +func SKY_cli_AddPrivateKey(_wlt C.Wallet__Handle, _key string) (____error_code uint32) { + wlt, okwlt := lookupWalletHandle(_wlt) + if !okwlt { + ____error_code = SKY_BAD_HANDLE + return + } + key := _key + ____return_err := cli.AddPrivateKey(wlt, key) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_cli_AddPrivateKeyToFile +func SKY_cli_AddPrivateKeyToFile(_walletFile, _key string, pwd C.PasswordReader__Handle) (____error_code uint32) { + walletFile := _walletFile + key := _key + pr, okc := lookupPasswordReaderHandle(pwd) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + ____return_err := cli.AddPrivateKeyToFile(walletFile, key, *pr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.check_balance.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.check_balance.go new file mode 100644 index 000000000..d69ec3e57 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.check_balance.go @@ -0,0 +1,48 @@ +package main + +import ( + "unsafe" + + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_CheckWalletBalance +func SKY_cli_CheckWalletBalance(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + walletFile := _walletFile + __arg2, ____return_err := cli.CheckWalletBalance(c, walletFile) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerBalanceResultHandle(__arg2) + } + return +} + +//export SKY_cli_GetBalanceOfAddresses +func SKY_cli_GetBalanceOfAddresses(_c C.WebRpcClient__Handle, _addrs []string, _arg2 *C.BalanceResult_Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addrs := *(*[]string)(unsafe.Pointer(&_addrs)) + __arg2, ____return_err := cli.GetBalanceOfAddresses(c, addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerBalanceResultHandle(__arg2) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.cli.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.cli.go new file mode 100644 index 000000000..9b585bd8a --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.cli.go @@ -0,0 +1,102 @@ +package main + +import ( + "reflect" + "unsafe" + + "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_LoadConfig +func SKY_cli_LoadConfig(_arg0 *C.Config__Handle) (____error_code uint32) { + __arg0, ____return_err := cli.LoadConfig() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = registerConfigHandle(&__arg0) + } + return +} + +//export SKY_cli_Config_FullWalletPath +func SKY_cli_Config_FullWalletPath(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { + __c, okc := lookupConfigHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + c := *__c + __arg0 := c.FullWalletPath() + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_Config_FullDBPath +func SKY_cli_Config_FullDBPath(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { + __c, okc := lookupConfigHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + c := *__c + __arg0 := c.FullDBPath() + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_NewCLI +func SKY_cli_NewCLI(_cfg C.Config__Handle, _arg1 *C.CLI__Handle) (____error_code uint32) { + __cfg, okcfg := lookupConfigHandle(_cfg) + if !okcfg { + ____error_code = SKY_BAD_HANDLE + return + } + cfg := *__cfg + __arg1, ____return_err := cli.NewCLI(cfg) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + if cmd, ok := inplaceCobraCommand(__arg1); ok { + *_arg1 = registerCLIHandle(cmd) + } else { + ____error_code = SKY_ERROR + } + } + return +} + +//export SKY_cli_NewPasswordReader +func SKY_cli_NewPasswordReader(_password []byte, passwordReader *C.PasswordReader__Handle) { + password := *(*[]byte)(unsafe.Pointer(&_password)) + pr := cli.NewPasswordReader(password) + *passwordReader = registerPasswordReaderHandle(&pr) +} + +//export SKY_cli_PasswordFromBytes_Password +func SKY_cli_PasswordFromBytes_Password(_p *C.cli__PasswordFromBytes, _arg0 *C.GoSlice_) (____error_code uint32) { + p := *(*cli.PasswordFromBytes)(unsafe.Pointer(_p)) + __arg0, ____return_err := p.Password() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_cli_PasswordFromTerm_Password +func SKY_cli_PasswordFromTerm_Password(_arg0 *C.GoSlice_) (____error_code uint32) { + p := cli.PasswordFromTerm{} + __arg0, ____return_err := p.Password() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.create_rawtx.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.create_rawtx.go new file mode 100644 index 000000000..35e9ce3ec --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.create_rawtx.go @@ -0,0 +1,105 @@ +package main + +import ( + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + cli "github.com/skycoin/skycoin/src/cli" + coin "github.com/skycoin/skycoin/src/coin" + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_CreateRawTxFromWallet +func SKY_cli_CreateRawTxFromWallet(_c C.WebRpcClient__Handle, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.Transaction__Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + + walletFile := _walletFile + chgAddr := _chgAddr + toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs)) + pr, okp := lookupPasswordReaderHandle(pwd) + if !okp { + ____error_code = SKY_BAD_HANDLE + return + } + __arg4, ____return_err := cli.CreateRawTxFromWallet(c, walletFile, chgAddr, toAddrs, *pr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg4 = registerTransactionHandle(__arg4) + } + return +} + +//export SKY_cli_CreateRawTxFromAddress +func SKY_cli_CreateRawTxFromAddress(_c C.WebRpcClient__Handle, _addr, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, pwd C.PasswordReader__Handle, _arg4 *C.Transaction__Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + addr := _addr + walletFile := _walletFile + chgAddr := _chgAddr + toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs)) + pr, okp := lookupPasswordReaderHandle(pwd) + if !okp { + ____error_code = SKY_BAD_HANDLE + return + } + __arg4, ____return_err := cli.CreateRawTxFromAddress(c, addr, walletFile, chgAddr, toAddrs, *pr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg4 = registerTransactionHandle(__arg4) + } + return +} + +//export SKY_cli_CreateRawTx +func SKY_cli_CreateRawTx(_c C.WebRpcClient__Handle, _wlt C.Wallet__Handle, _inAddrs []string, _chgAddr string, _toAddrs []C.cli__SendAmount, _password []byte, _arg6 *C.Transaction__Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + + wlt, okwlt := lookupWalletHandle(_wlt) + if !okwlt { + ____error_code = SKY_BAD_HANDLE + return + } + inAddrs := *(*[]string)(unsafe.Pointer(&_inAddrs)) + chgAddr := _chgAddr + toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs)) + password := *(*[]byte)(unsafe.Pointer(&_password)) + __arg6, ____return_err := cli.CreateRawTx(c, wlt, inAddrs, chgAddr, toAddrs, password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg6 = registerTransactionHandle(__arg6) + } + return +} + +//export SKY_cli_NewTransaction +func SKY_cli_NewTransaction(_utxos []C.wallet__UxBalance, _keys []C.cipher__SecKey, _outs []C.coin__TransactionOutput, _arg3 *C.Transaction__Handle) (____error_code uint32) { + utxos := *(*[]wallet.UxBalance)(unsafe.Pointer(&_utxos)) + keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) + outs := *(*[]coin.TransactionOutput)(unsafe.Pointer(&_outs)) + __arg3, ____return_err := cli.NewTransaction(utxos, keys, outs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = registerTransactionHandle(__arg3) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.generate_addrs.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.generate_addrs.go new file mode 100644 index 000000000..da13765e6 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.generate_addrs.go @@ -0,0 +1,65 @@ +package main + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_GenerateAddressesInFile +func SKY_cli_GenerateAddressesInFile(_walletFile string, _num uint64, pwd C.PasswordReader__Handle, _arg3 *C.GoSlice_) (____error_code uint32) { + walletFile := _walletFile + num := _num + pr, okc := lookupPasswordReaderHandle(pwd) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + __arg3, ____return_err := cli.GenerateAddressesInFile(walletFile, num, *pr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg3), _arg3) + } + return +} + +//export SKY_cli_FormatAddressesAsJSON +func SKY_cli_FormatAddressesAsJSON(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { + addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) + __addrs := toAddresserArray(addrs) + __arg1, ____return_err := cli.FormatAddressesAsJSON(__addrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_cli_FormatAddressesAsJoinedArray +func SKY_cli_FormatAddressesAsJoinedArray(_addrs []C.cipher__Address, _arg1 *C.GoString_) (____error_code uint32) { + addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) + __addrs := toAddresserArray(addrs) + __arg1 := cli.FormatAddressesAsJoinedArray(__addrs) + copyString(__arg1, _arg1) + return +} + +//export SKY_cli_AddressesToStrings +func SKY_cli_AddressesToStrings(_addrs []C.cipher__Address, _arg1 *C.GoSlice_) (____error_code uint32) { + addrs := *(*[]cipher.Address)(unsafe.Pointer(&_addrs)) + __addrs := toAddresserArray(addrs) + __arg1 := cli.AddressesToStrings(__addrs) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.generate_wallet.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.generate_wallet.go new file mode 100644 index 000000000..48714c990 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.generate_wallet.go @@ -0,0 +1,39 @@ +package main + +import ( + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_GenerateWallet +func SKY_cli_GenerateWallet(_walletFile string, _opts *C.Options__Handle, _numAddrs uint64, _arg3 *C.Wallet__Handle) (____error_code uint32) { + walletFile := _walletFile + __opts, okopts := lookupOptionsHandle(*_opts) + if !okopts { + ____error_code = SKY_BAD_HANDLE + return + } + opts := *__opts + numAddrs := _numAddrs + __arg3, ____return_err := cli.GenerateWallet(walletFile, opts, numAddrs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = registerWalletHandle(__arg3) + } + return +} + +//export SKY_cli_MakeAlphanumericSeed +func SKY_cli_MakeAlphanumericSeed(_arg0 *C.GoString_) (____error_code uint32) { + __arg0 := cli.MakeAlphanumericSeed() + copyString(__arg0, _arg0) + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.outputs.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.outputs.go new file mode 100644 index 000000000..8d4ce1f66 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli.outputs.go @@ -0,0 +1,50 @@ +package main + +import ( + cli "github.com/skycoin/skycoin/src/cli" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_GetWalletOutputsFromFile +func SKY_cli_GetWalletOutputsFromFile(_c C.WebRpcClient__Handle, _walletFile string, _arg2 *C.ReadableUnspentOutputsSummary_Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + walletFile := _walletFile + __arg2, ____return_err := cli.GetWalletOutputsFromFile(c, walletFile) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerReadableUnspentOutputsSummaryHandle(__arg2) + } + return +} + +//export SKY_cli_GetWalletOutputs +func SKY_cli_GetWalletOutputs(_c C.WebRpcClient__Handle, _wlt *C.Wallet__Handle, _arg2 *C.ReadableUnspentOutputsSummary_Handle) (____error_code uint32) { + c, okc := lookupWebRpcClientHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + wlt, okwlt := lookupWalletHandle(*_wlt) + if !okwlt { + ____error_code = SKY_BAD_HANDLE + return + } + __arg2, ____return_err := cli.GetWalletOutputs(c, wlt) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerReadableUnspentOutputsSummaryHandle(__arg2) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/cli_helper.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli_helper.go new file mode 100644 index 000000000..9c0d97b73 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/cli_helper.go @@ -0,0 +1,71 @@ +package main + +import ( + "os" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_cli_CLI_Run +func SKY_cli_CLI_Run(_app C.CLI__Handle) (____error_code uint32) { + cli, okapp := lookupCLIHandle(_app) + if !okapp { + ____error_code = SKY_BAD_HANDLE + return + } + + ____return_err := cli.Execute() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_cli_Config_GetCoin +func SKY_cli_Config_GetCoin(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { + __c, okc := lookupConfigHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + c := *__c + __arg0 := c.Coin + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_Config_GetRPCAddress +func SKY_cli_Config_GetRPCAddress(_c C.Config__Handle, _arg0 *C.GoString_) (____error_code uint32) { + __c, okc := lookupConfigHandle(_c) + if !okc { + ____error_code = SKY_BAD_HANDLE + return + } + c := *__c + __arg0 := c.RPCAddress + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_Getenv +func SKY_cli_Getenv(varname string, _arg0 *C.GoString_) (____error_code uint32) { + __arg0 := os.Getenv(varname) + copyString(__arg0, _arg0) + return +} + +//export SKY_cli_Setenv +func SKY_cli_Setenv(varname string, value string) (____error_code uint32) { + ____return_err := os.Setenv(varname, value) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.block.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.block.go new file mode 100644 index 000000000..af92dc29f --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.block.go @@ -0,0 +1,422 @@ +package main + +import ( + "errors" + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" +) + +/* + + #include + #include + + #include "skytypes.h" + #include "skyfee.h" +*/ +import "C" + +//export SKY_coin_NewBlock +// nolint nakedret +func SKY_coin_NewBlock(_b C.Block__Handle, _currentTime uint64, _hash *C.cipher__SHA256, _txns C.Transactions__Handle, pFeeCalc *C.FeeCalculator, _arg2 *C.Block__Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + err := errorFromLibCode(uint32(result)) + if err == nil { + err = errors.New("Error in libskycoin fee calculator") + } + return 0, err + } + } + + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + hash := *(*cipher.SHA256)(unsafe.Pointer(_hash)) + txns, ok := lookupTransactionsHandle(_txns) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg2, ____return_err := coin.NewBlock(*b, _currentTime, hash, *txns, feeCalc) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerBlockHandle(__arg2) + } + return +} + +//export SKY_coin_SignedBlock_VerifySignature +func SKY_coin_SignedBlock_VerifySignature(_b *C.coin__SignedBlock, _pubkey *C.cipher__PubKey) (____error_code uint32) { + b := *(*coin.SignedBlock)(unsafe.Pointer(_b)) + pubkey := *(*cipher.PubKey)(unsafe.Pointer(_pubkey)) + ____return_err := b.VerifySignature(pubkey) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_coin_NewGenesisBlock +func SKY_coin_NewGenesisBlock(_genesisAddr *C.cipher__Address, _genesisCoins, _timestamp uint64, _arg2 *C.Block__Handle) (____error_code uint32) { + genesisAddr := *(*cipher.Address)(unsafe.Pointer(_genesisAddr)) + genesisCoins := uint64(_genesisCoins) + timestamp := uint64(_timestamp) + __arg2, ____return_err := coin.NewGenesisBlock(genesisAddr, genesisCoins, timestamp) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + __arg2.Head.Time = timestamp + *_arg2 = registerBlockHandle(__arg2) + } + return +} + +//export SKY_coin_Block_HashHeader +func SKY_coin_Block_HashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := b.HashHeader() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Block_PreHashHeader +func SKY_coin_Block_PreHashHeader(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := b.PreHashHeader() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Block_Time +func SKY_coin_Block_Time(_b C.Block__Handle, _arg0 *uint64) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := b.Time() + *_arg0 = __arg0 + return +} + +//export SKY_coin_Block_Seq +func SKY_coin_Block_Seq(_b C.Block__Handle, _arg0 *uint64) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := b.Seq() + *_arg0 = __arg0 + return +} + +//export SKY_coin_Block_HashBody +func SKY_coin_Block_HashBody(_b C.Block__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := b.HashBody() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Block_Size +func SKY_coin_Block_Size(_b C.Block__Handle, _arg0 *uint32) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := b.Size() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_coin_Block_String +func SKY_coin_Block_String(_b C.Block__Handle, _arg0 *C.GoString_) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := b.String() + copyString(__arg0, _arg0) + return +} + +//export SKY_coin_Block_GetTransaction +func SKY_coin_Block_GetTransaction(_b C.Block__Handle, _txHash *C.cipher__SHA256, _arg1 *C.Transaction__Handle, _arg2 *bool) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + txHash := *(*cipher.SHA256)(unsafe.Pointer(_txHash)) + __arg1, __arg2 := b.GetTransaction(txHash) + *_arg1 = registerTransactionHandle(&__arg1) + *_arg2 = __arg2 + return +} + +//export SKY_coin_NewBlockHeader +func SKY_coin_NewBlockHeader(_prev *C.coin__BlockHeader, _uxHash *C.cipher__SHA256, _currentTime, _fee uint64, _body C.BlockBody__Handle, _arg4 *C.coin__BlockHeader) (____error_code uint32) { + prev := *(*coin.BlockHeader)(unsafe.Pointer(_prev)) + uxHash := *(*cipher.SHA256)(unsafe.Pointer(_uxHash)) + currentTime := uint64(_currentTime) + fee := uint64(_fee) + body, ok := lookupBlockBodyHandle(_body) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg4 := coin.NewBlockHeader(prev, uxHash, currentTime, fee, *body) + *_arg4 = *(*C.coin__BlockHeader)(unsafe.Pointer(&__arg4)) + return +} + +//export SKY_coin_BlockHeader_Hash +func SKY_coin_BlockHeader_Hash(_bh *C.coin__BlockHeader, _arg0 *C.cipher__SHA256) (____error_code uint32) { + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + __arg0 := bh.Hash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_BlockHeader_Bytes +func SKY_coin_BlockHeader_Bytes(_bh *C.coin__BlockHeader, _arg0 *C.GoSlice_) (____error_code uint32) { + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + __arg0 := bh.Bytes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_BlockHeader_String +func SKY_coin_BlockHeader_String(_bh *C.coin__BlockHeader, _arg0 *C.GoString_) (____error_code uint32) { + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + __arg0 := bh.String() + copyString(__arg0, _arg0) + return +} + +//export SKY_coin_BlockBody_Hash +func SKY_coin_BlockBody_Hash(_body C.BlockBody__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { + body, ok := lookupBlockBodyHandle(_body) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := body.Hash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_BlockBody_Size +func SKY_coin_BlockBody_Size(_bb *C.BlockBody__Handle, _arg0 *uint32) (____error_code uint32) { + bb, ok := lookupBlockBodyHandle(*_bb) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := bb.Size() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_coin_BlockBody_Bytes +func SKY_coin_BlockBody_Bytes(_bb C.BlockBody__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + bb, ok := lookupBlockBodyHandle(_bb) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := bb.Bytes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_CreateUnspents +func SKY_coin_CreateUnspents(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, _arg2 *C.coin__UxArray) (____error_code uint32) { + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + bh.Time = uint64(_bh.Time) + bh.BkSeq = uint64(_bh.BkSeq) + bh.Fee = uint64(_bh.Fee) + tx, ok := lookupTransactionHandle(_tx) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg2 := coin.CreateUnspents(bh, *tx) + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + return +} + +//export SKY_coin_CreateUnspent +func SKY_coin_CreateUnspent(_bh *C.coin__BlockHeader, _tx C.Transaction__Handle, _outIndex int, _arg3 *C.coin__UxOut) (____error_code uint32) { + bh := *(*coin.BlockHeader)(unsafe.Pointer(_bh)) + bh.Time = uint64(_bh.Time) + bh.BkSeq = uint64(_bh.BkSeq) + tx, ok := lookupTransactionHandle(_tx) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + outIndex := _outIndex + __arg3, ____return_err := coin.CreateUnspent(bh, *tx, outIndex) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = *(*C.coin__UxOut)(unsafe.Pointer(&__arg3)) + } + return +} + +//export SKY_coin_GetBlockObject +func SKY_coin_GetBlockObject(_b C.Block__Handle, _p **C.coin__Block) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_p = (*C.coin__Block)(unsafe.Pointer(b)) + } + return +} + +//export SKY_coin_GetBlockBody +func SKY_coin_GetBlockBody(_b C.Block__Handle, _p *C.BlockBody__Handle) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_p = registerBlockBodyHandle(&b.Body) + } + return +} + +//export SKY_coin_NewEmptyBlock +func SKY_coin_NewEmptyBlock(_txns C.Transactions__Handle, handle *C.Block__Handle) (____error_code uint32) { + txns, ok := lookupTransactionsHandle(_txns) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + body := coin.BlockBody{ + Transactions: *txns, + } + block := coin.Block{ + Body: body, + Head: coin.BlockHeader{ + Version: 0x02, + Time: 100, + BkSeq: 0, + Fee: 10, + PrevHash: cipher.SHA256{}, + BodyHash: body.Hash(), + }} + *handle = registerBlockHandle(&block) + return +} + +//export SKY_coin_Block_GetBlockHeader +func SKY_coin_Block_GetBlockHeader(_b C.Block__Handle, _bh *C.BlockHeader__Handle) (____error_code uint32) { + b, ok := lookupBlockHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_bh = registerBlockHeaderHandle(&b.Head) + } + return +} + +//export SKY_coin_GetBlockHeaderObject +func SKY_coin_GetBlockHeaderObject(_b C.BlockHeader__Handle, _p **C.coin__BlockHeader) (____error_code uint32) { + b, ok := lookupBlockHeaderHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_p = (*C.coin__BlockHeader)(unsafe.Pointer(b)) + } + return +} + +//export SKY_coin_BlockHeader_Time +func SKY_coin_BlockHeader_Time(_b C.BlockHeader__Handle, _arg0 *uint64) (____error_code uint32) { + b, ok := lookupBlockHeaderHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_arg0 = uint64(b.Time) + } + return +} + +//export SKY_coin_BlockHeader_BkSeq +func SKY_coin_BlockHeader_BkSeq(_b C.BlockHeader__Handle, _arg0 *uint64) (____error_code uint32) { + b, ok := lookupBlockHeaderHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_arg0 = uint64(b.BkSeq) + } + return +} + +//export SKY_coin_BlockHeader_UxHash +func SKY_coin_BlockHeader_UxHash(_b C.BlockHeader__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { + b, ok := lookupBlockHeaderHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&b.UxHash)) + } + return +} + +//export SKY_coin_BlockHeader_Fee +func SKY_coin_BlockHeader_Fee(_b C.BlockHeader__Handle, _arg0 *uint64) (____error_code uint32) { + b, ok := lookupBlockHeaderHandle(_b) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_arg0 = uint64(b.Fee) + } + return +} + +//export SKY_coin_BlockBody_Transactions +func SKY_coin_BlockBody_Transactions(_bb C.BlockBody__Handle, _arg0 *C.Transactions__Handle) (____error_code uint32) { + bb, ok := lookupBlockBodyHandle(_bb) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := bb.Transactions + *_arg0 = registerTransactionsHandle(&__arg0) + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.math.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.math.go new file mode 100644 index 000000000..c4003438b --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.math.go @@ -0,0 +1,57 @@ +package main + +import coin "github.com/skycoin/skycoin/src/coin" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_coin_AddUint64 +func SKY_coin_AddUint64(_a, _b uint64, _arg1 *uint64) (____error_code uint32) { + a := _a + b := _b + __arg1, ____return_err := coin.AddUint64(a, b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_coin_Uint64ToInt64 +func SKY_coin_Uint64ToInt64(_a uint64, _arg1 *int64) (____error_code uint32) { + a := _a + __arg1, ____return_err := coin.Uint64ToInt64(a) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_coin_Int64ToUint64 +func SKY_coin_Int64ToUint64(_a int64, _arg1 *uint64) (____error_code uint32) { + a := _a + __arg1, ____return_err := coin.Int64ToUint64(a) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_coin_IntToUint32 +func SKY_coin_IntToUint32(_a int, _arg1 *uint32) (____error_code uint32) { + a := _a + __arg1, ____return_err := coin.IntToUint32(a) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.outputs.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.outputs.go new file mode 100644 index 000000000..bafc22137 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.outputs.go @@ -0,0 +1,281 @@ +package main + +import ( + "reflect" + "unsafe" + + "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_coin_UxOut_Hash +func SKY_coin_UxOut_Hash(_uo *C.coin__UxOut, _arg0 *C.cipher__SHA256) (____error_code uint32) { + uo := (*coin.UxOut)(unsafe.Pointer(_uo)) + __arg0 := uo.Hash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_UxOut_SnapshotHash +func SKY_coin_UxOut_SnapshotHash(_uo *C.coin__UxOut, _arg0 *C.cipher__SHA256) (____error_code uint32) { + uo := (*coin.UxOut)(unsafe.Pointer(_uo)) + __arg0 := uo.SnapshotHash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_UxBody_Hash +func SKY_coin_UxBody_Hash(_ub *C.coin__UxBody, _arg0 *C.cipher__SHA256) (____error_code uint32) { + ub := (*coin.UxBody)(unsafe.Pointer(_ub)) + __arg0 := ub.Hash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_UxOut_CoinHours +func SKY_coin_UxOut_CoinHours(_uo *C.coin__UxOut, _t uint64, _arg1 *uint64) (____error_code uint32) { + uo := (*coin.UxOut)(unsafe.Pointer(_uo)) + t := _t + __arg1, ____return_err := uo.CoinHours(t) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_coin_UxArray_Hashes +func SKY_coin_UxArray_Hashes(_ua *C.coin__UxArray, _arg0 *C.GoSlice_) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + __arg0 := ua.Hashes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_UxArray_HasDupes +func SKY_coin_UxArray_HasDupes(_ua *C.coin__UxArray, _arg0 *bool) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + *_arg0 = ua.HasDupes() + return +} + +//export SKY_coin_UxArray_Sort +func SKY_coin_UxArray_Sort(_ua *C.coin__UxArray) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + ua.Sort() + return +} + +//export SKY_coin_UxArray_Len +func SKY_coin_UxArray_Len(_ua *C.coin__UxArray, _arg0 *int) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + *_arg0 = ua.Len() + return +} + +//export SKY_coin_UxArray_Less +func SKY_coin_UxArray_Less(_ua *C.coin__UxArray, _i, _j int, _arg0 *bool) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + *_arg0 = ua.Less(_i, _j) + return +} + +//export SKY_coin_UxArray_Swap +func SKY_coin_UxArray_Swap(_ua *C.coin__UxArray, _i, _j int) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + ua.Swap(_i, _j) + return +} + +//export SKY_coin_UxArray_Coins +func SKY_coin_UxArray_Coins(_ua *C.coin__UxArray, _arg0 *uint64) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + __arg0, ____return_err := ua.Coins() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_coin_UxArray_CoinHours +func SKY_coin_UxArray_CoinHours(_ua *C.coin__UxArray, _headTime uint64, _arg1 *uint64) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + headTime := _headTime + __arg1, ____return_err := ua.CoinHours(headTime) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_coin_UxArray_Sub +func SKY_coin_UxArray_Sub(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 *C.coin__UxArray) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + other := *(*coin.UxArray)(unsafe.Pointer(_other)) + __arg1 := ua.Sub(other) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_coin_UxArray_Add +func SKY_coin_UxArray_Add(_ua *C.coin__UxArray, _other *C.coin__UxArray, _arg1 *C.coin__UxArray) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + other := *(*coin.UxArray)(unsafe.Pointer(_other)) + __arg1 := ua.Add(other) + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + return +} + +//export SKY_coin_NewAddressUxOuts +func SKY_coin_NewAddressUxOuts(_ua *C.coin__UxArray, _address_outs *C.AddressUxOuts_Handle) (____error_code uint32) { + ua := *(*coin.UxArray)(unsafe.Pointer(_ua)) + address_outs := coin.NewAddressUxOuts(ua) + *_address_outs = registerAddressUxOutHandle(&address_outs) + return +} + +//export SKY_coin_AddressUxOuts_Keys +func SKY_coin_AddressUxOuts_Keys(_address_outs C.AddressUxOuts_Handle, _keys *C.GoSlice_) (____error_code uint32) { + address_outs, ok := lookupAddressUxOutHandle(_address_outs) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + keys := (*address_outs).Keys() + copyToGoSlice(reflect.ValueOf(keys), _keys) + return +} + +//export SKY_coin_AddressUxOuts_Flatten +func SKY_coin_AddressUxOuts_Flatten(_address_outs C.AddressUxOuts_Handle, _ua *C.coin__UxArray) (____error_code uint32) { + address_outs, ok := lookupAddressUxOutHandle(_address_outs) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + ux := (*address_outs).Flatten() + copyToGoSlice(reflect.ValueOf(ux), _ua) + return +} + +//export SKY_coin_AddressUxOuts_Sub +func SKY_coin_AddressUxOuts_Sub(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { + auo1, ok := lookupAddressUxOutHandle(_auo1) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + auo2, ok := lookupAddressUxOutHandle(_auo2) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + auo_result := (*auo1).Sub(*auo2) + *_auo_result = registerAddressUxOutHandle(&auo_result) + return +} + +//export SKY_coin_AddressUxOuts_Add +func SKY_coin_AddressUxOuts_Add(_auo1 C.AddressUxOuts_Handle, _auo2 C.AddressUxOuts_Handle, _auo_result *C.AddressUxOuts_Handle) (____error_code uint32) { + auo1, ok := lookupAddressUxOutHandle(_auo1) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + auo2, ok := lookupAddressUxOutHandle(_auo2) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + auo_result := (*auo1).Add(*auo2) + *_auo_result = registerAddressUxOutHandle(&auo_result) + return +} + +//export SKY_coin_AddressUxOuts_Get +func SKY_coin_AddressUxOuts_Get(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) (____error_code uint32) { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + uxOuts, found := (*a)[key] + if found { + copyToGoSlice(reflect.ValueOf(uxOuts), _uxOuts) + ____error_code = SKY_OK + } + } else { + ____error_code = SKY_BAD_HANDLE + } + return +} + +//export SKY_coin_AddressUxOuts_HasKey +func SKY_coin_AddressUxOuts_HasKey(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _hasKey *bool) (____error_code uint32) { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + _, found := (*a)[key] + *_hasKey = found + ____error_code = SKY_OK + } else { + ____error_code = SKY_BAD_HANDLE + } + return +} + +//export SKY_coin_AddressUxOuts_GetOutputLength +func SKY_coin_AddressUxOuts_GetOutputLength(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _length *int) (____error_code uint32) { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + uxOuts, found := (*a)[key] + if found { + *_length = len(uxOuts) + ____error_code = SKY_OK + } + } else { + ____error_code = SKY_BAD_HANDLE + } + return +} + +//export SKY_coin_AddressUxOuts_Length +func SKY_coin_AddressUxOuts_Length(handle C.AddressUxOuts_Handle, _length *int) (____error_code uint32) { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + *_length = len(*a) + ____error_code = SKY_OK + } else { + ____error_code = SKY_BAD_HANDLE + } + return +} + +//export SKY_coin_AddressUxOuts_Set +func SKY_coin_AddressUxOuts_Set(handle C.AddressUxOuts_Handle, _key *C.cipher__Address, _uxOuts *C.coin__UxArray) (____error_code uint32) { + a, ok := lookupAddressUxOutHandle(handle) + if ok { + key := *(*cipher.Address)(unsafe.Pointer(_key)) + //Copy the slice because it is going to be kept + //We can't hold memory allocated outside Go + tempUxOuts := *(*coin.UxArray)(unsafe.Pointer(_uxOuts)) + uxOuts := make(coin.UxArray, 0, len(tempUxOuts)) + + uxOuts = append(uxOuts, tempUxOuts...) + (*a)[key] = uxOuts + ____error_code = SKY_OK + } else { + ____error_code = SKY_BAD_HANDLE + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.transactions.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.transactions.go new file mode 100644 index 000000000..9ff980d1a --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/coin.transactions.go @@ -0,0 +1,694 @@ +package main + +import ( + "errors" + "reflect" + "strconv" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" +) + +/* + + #include + #include + + #include "skytypes.h" + #include "skyfee.h" +*/ +import "C" + +//export SKY_coin_Create_Transaction +func SKY_coin_Create_Transaction(handle *C.Transaction__Handle) (____error_code uint32) { + tx := coin.Transaction{} + *handle = registerTransactionHandle(&tx) + return +} + +//export SKY_coin_Transaction_Copy +func SKY_coin_Transaction_Copy(handle C.Transaction__Handle, handle2 *C.Transaction__Handle) (____error_code uint32) { + tx, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + ntx := coin.Transaction{} + ntx.Length = tx.Length + ntx.Type = tx.Type + ntx.InnerHash = tx.InnerHash + ntx.Sigs = make([]cipher.Sig, 0) + ntx.Sigs = append(ntx.Sigs, tx.Sigs...) + ntx.In = make([]cipher.SHA256, 0) + ntx.In = append(ntx.In, tx.In...) + ntx.Out = make([]coin.TransactionOutput, 0) + ntx.Out = append(ntx.Out, tx.Out...) + *handle2 = registerTransactionHandle(&ntx) + return +} + +//export SKY_coin_GetTransactionObject +func SKY_coin_GetTransactionObject(handle C.Transaction__Handle, _pptx **C.coin__Transaction) (____error_code uint32) { + ptx, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_pptx = (*C.coin__Transaction)(unsafe.Pointer(ptx)) + } + return +} + +//export SKY_coin_Transaction_ResetInputs +func SKY_coin_Transaction_ResetInputs(handle C.Transaction__Handle, count int) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + txn.In = make([]cipher.SHA256, count) + return +} + +//export SKY_coin_Transaction_GetInputsCount +func SKY_coin_Transaction_GetInputsCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + *length = len(txn.In) + return +} + +//export SKY_coin_Transaction_GetInputAt +func SKY_coin_Transaction_GetInputAt(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + if i >= len(txn.In) { + ____error_code = SKY_BAD_HANDLE + return + } + *input = *(*C.cipher__SHA256)(unsafe.Pointer(&txn.In[i])) + return +} + +//export SKY_coin_Transaction_SetInputAt +func SKY_coin_Transaction_SetInputAt(handle C.Transaction__Handle, i int, input *C.cipher__SHA256) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + if i >= len(txn.In) { + ____error_code = SKY_BAD_HANDLE + return + } + *(*C.cipher__SHA256)(unsafe.Pointer(&txn.In[i])) = *input + return +} + +//export SKY_coin_Transaction_GetOutputsCount +func SKY_coin_Transaction_GetOutputsCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + *length = len(txn.Out) + return +} + +//export SKY_coin_Transaction_GetOutputAt +func SKY_coin_Transaction_GetOutputAt(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + if i >= len(txn.Out) { + ____error_code = SKY_ERROR + return + } + *output = *(*C.coin__TransactionOutput)(unsafe.Pointer(&txn.Out[i])) + return +} + +//export SKY_coin_Transaction_SetOutputAt +func SKY_coin_Transaction_SetOutputAt(handle C.Transaction__Handle, i int, output *C.coin__TransactionOutput) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + if i >= len(txn.Out) { + ____error_code = SKY_ERROR + return + } + *(*C.coin__TransactionOutput)(unsafe.Pointer(&txn.Out[i])) = *output + return +} + +//export SKY_coin_Transaction_GetSignaturesCount +func SKY_coin_Transaction_GetSignaturesCount(handle C.Transaction__Handle, length *int) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + *length = len(txn.Sigs) + return +} + +//export SKY_coin_Transaction_GetSignatureAt +func SKY_coin_Transaction_GetSignatureAt(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + if i >= len(txn.Sigs) { + ____error_code = SKY_BAD_HANDLE + return + } + *sig = *(*C.cipher__Sig)(unsafe.Pointer(&txn.Sigs[i])) + return +} + +//export SKY_coin_Transaction_SetSignatureAt +func SKY_coin_Transaction_SetSignatureAt(handle C.Transaction__Handle, i int, sig *C.cipher__Sig) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + if i >= len(txn.Sigs) { + ____error_code = SKY_BAD_HANDLE + return + } + *(*C.cipher__Sig)(unsafe.Pointer(&txn.Sigs[i])) = *sig + return +} + +//export SKY_coin_Transaction_PushSignature +func SKY_coin_Transaction_PushSignature(handle C.Transaction__Handle, _sig *C.cipher__Sig) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + sig := *(*cipher.Sig)(unsafe.Pointer(_sig)) + txn.Sigs = append(txn.Sigs, sig) + return +} + +//export SKY_coin_Transaction_ResetOutputs +func SKY_coin_Transaction_ResetOutputs(handle C.Transaction__Handle, count int) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + txn.Out = make([]coin.TransactionOutput, count) + return +} + +//export SKY_coin_Transaction_ResetSignatures +func SKY_coin_Transaction_ResetSignatures(handle C.Transaction__Handle, count int) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + txn.Sigs = make([]cipher.Sig, count) + return +} + +//export SKY_coin_Transaction_Verify +func SKY_coin_Transaction_Verify(handle C.Transaction__Handle) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + ____return_err := txn.Verify() + ____error_code = libErrorCode(____return_err) + return +} + +//export SKY_coin_Transaction_VerifyInput +func SKY_coin_Transaction_VerifyInput(handle C.Transaction__Handle, _uxIn *C.coin__UxArray) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) + ____return_err := txn.VerifyInput(uxIn) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_coin_Transaction_PushInput +func SKY_coin_Transaction_PushInput(handle C.Transaction__Handle, _uxOut *C.cipher__SHA256, _arg1 *uint16) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + uxOut := *(*cipher.SHA256)(unsafe.Pointer(_uxOut)) + __arg1 := txn.PushInput(uxOut) + *_arg1 = __arg1 + return +} + +//export SKY_coin_TransactionOutput_UxID +func SKY_coin_TransactionOutput_UxID(_txOut *C.coin__TransactionOutput, _txID *C.cipher__SHA256, _arg1 *C.cipher__SHA256) (____error_code uint32) { + txOut := *(*coin.TransactionOutput)(unsafe.Pointer(_txOut)) + txID := *(*cipher.SHA256)(unsafe.Pointer(_txID)) + __arg1 := txOut.UxID(txID) + *_arg1 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_coin_Transaction_PushOutput +func SKY_coin_Transaction_PushOutput(handle C.Transaction__Handle, _dst *C.cipher__Address, _coins, _hours uint64) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + dst := *(*cipher.Address)(unsafe.Pointer(_dst)) + coins := uint64(_coins) + hours := uint64(_hours) + txn.PushOutput(dst, coins, hours) + return +} + +//export SKY_coin_Transaction_SignInputs +func SKY_coin_Transaction_SignInputs(handle C.Transaction__Handle, _keys []C.cipher__SecKey) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + keys := *(*[]cipher.SecKey)(unsafe.Pointer(&_keys)) + txn.SignInputs(keys) + return +} + +//export SKY_coin_Transaction_Size +func SKY_coin_Transaction_Size(handle C.Transaction__Handle, _arg0 *uint32) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := txn.Size() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_coin_Transaction_Hash +func SKY_coin_Transaction_Hash(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := txn.Hash() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Transaction_SizeHash +func SKY_coin_Transaction_SizeHash(handle C.Transaction__Handle, _arg0 *uint32, _arg1 *C.cipher__SHA256) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, __arg1, ____return_err := txn.SizeHash() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + *_arg1 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg1)) + } + return +} + +//export SKY_coin_Transaction_TxID +func SKY_coin_Transaction_TxID(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := txn.TxID() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_Transaction_TxIDHex +func SKY_coin_Transaction_TxIDHex(handle C.Transaction__Handle, _arg0 *C.GoString_) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := txn.TxIDHex() + copyString(__arg0, _arg0) + return +} + +//export SKY_coin_Transaction_UpdateHeader +func SKY_coin_Transaction_UpdateHeader(handle C.Transaction__Handle) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + ____return_err := txn.UpdateHeader() + ____error_code = libErrorCode(____return_err) + return +} + +//export SKY_coin_Transaction_HashInner +func SKY_coin_Transaction_HashInner(handle C.Transaction__Handle, _arg0 *C.cipher__SHA256) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := txn.HashInner() + *_arg0 = *(*C.cipher__SHA256)(unsafe.Pointer(&__arg0)) + return +} + +//export SKY_coin_Transaction_Serialize +func SKY_coin_Transaction_Serialize(handle C.Transaction__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := txn.Serialize() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_TransactionDeserialize +func SKY_coin_TransactionDeserialize(_b []byte, _arg1 *C.Transaction__Handle) (____error_code uint32) { + b := *(*[]byte)(unsafe.Pointer(&_b)) + __arg1, ____return_err := coin.TransactionDeserialize(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerTransactionHandle(&__arg1) + } + return +} + +//export SKY_coin_Transaction_OutputHours +func SKY_coin_Transaction_OutputHours(handle C.Transaction__Handle, _arg0 *uint64) (____error_code uint32) { + txn, ok := lookupTransactionHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := txn.OutputHours() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_coin_Create_Transactions +func SKY_coin_Create_Transactions(handle *C.Transactions__Handle) (____error_code uint32) { + txs := make(coin.Transactions, 0) + *handle = registerTransactionsHandle(&txs) + return SKY_OK +} + +//export SKY_coin_GetTransactionsObject +func SKY_coin_GetTransactionsObject(handle C.Transactions__Handle, _pptx **C.coin__Transactions) (____error_code uint32) { + ptx, ok := lookupTransactionsHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + } else { + *_pptx = (*C.coin__Transactions)(unsafe.Pointer(ptx)) + } + return +} + +//export SKY_coin_Transactions_Length +func SKY_coin_Transactions_Length(handle C.Transactions__Handle, _length *int) (____error_code uint32) { + txns, ok := lookupTransactionsHandle(handle) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + *_length = len(*txns) + return +} + +//export SKY_coin_Transactions_Add +func SKY_coin_Transactions_Add(tsh C.Transactions__Handle, th C.Transaction__Handle) (____error_code uint32) { + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + tx, okt := lookupTransactionHandle(th) + if !okt { + ____error_code = SKY_BAD_HANDLE + return + } + *txns = append(*txns, *tx) + result := overwriteHandle(tsh, txns) + if !result { + ____error_code = SKY_ERROR + } + return +} + +//export SKY_coin_Transactions_Fees +func SKY_coin_Transactions_Fees(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalculator, _result *uint64) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } + } + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + result, err := txns.Fees(feeCalc) + if err != nil { + ____error_code = SKY_ERROR + } else { + *_result = result + } + return +} + +//export SKY_coin_Transactions_GetAt +func SKY_coin_Transactions_GetAt(tsh C.Transactions__Handle, n int, th *C.Transaction__Handle) (____error_code uint32) { + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + if n >= len(*txns) { + ____error_code = SKY_ERROR + return + } + tx := (*txns)[n] + *th = registerTransactionHandle(&tx) + return +} + +//export SKY_coin_Transactions_Hashes +func SKY_coin_Transactions_Hashes(tsh C.Transactions__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := txns.Hashes() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_coin_Transactions_Size +func SKY_coin_Transactions_Size(tsh C.Transactions__Handle, _arg0 *uint32) (____error_code uint32) { + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0, ____return_err := txns.Size() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg0 = __arg0 + } + return +} + +//export SKY_coin_Transactions_TruncateBytesTo +func SKY_coin_Transactions_TruncateBytesTo(tsh C.Transactions__Handle, _size uint32, _arg1 *C.Transactions__Handle) (____error_code uint32) { + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + size := _size + __arg1, ____return_err := txns.TruncateBytesTo(size) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerTransactionsHandle(&__arg1) + } + return +} + +//export SKY_coin_SortTransactions +func SKY_coin_SortTransactions(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalculator, ptsh *C.Transactions__Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + errorcode := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if errorcode != SKY_OK { + if err, exists := codeToErrorMap[uint32(errorcode)]; exists { + return 0, err + } + return 0, errors.New("C fee calculator failed code=" + strconv.Itoa(int(errorcode))) + } + return uint64(fee), nil + } + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + sorted, ____return_err := coin.SortTransactions(*txns, feeCalc) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *ptsh = registerTransactionsHandle(&sorted) + } + return +} + +//export SKY_coin_NewSortableTransactions +func SKY_coin_NewSortableTransactions(tsh C.Transactions__Handle, pFeeCalc *C.FeeCalculator, ptsh *C.SortableTransactionResult_Handle) (____error_code uint32) { + feeCalc := func(pTx *coin.Transaction) (uint64, error) { + var fee C.GoUint64_ + handle := registerTransactionHandle(pTx) + result := C.callFeeCalculator(pFeeCalc, handle, &fee) + closeHandle(Handle(handle)) + if result == SKY_OK { + return uint64(fee), nil + } else { + return 0, errors.New("Error calculating fee") + } + } + txns, ok := lookupTransactionsHandle(tsh) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + sorted, ____return_err := coin.NewSortableTransactions(*txns, feeCalc) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *ptsh = registerSortableTransactiontHandle(sorted) + } + return +} + +//export SKY_coin_SortableTransactions_Sort +func SKY_coin_SortableTransactions_Sort(_txns C.SortableTransactionResult_Handle) (____error_code uint32) { + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + txns.Sort() + return +} + +//export SKY_coin_SortableTransactions_Len +func SKY_coin_SortableTransactions_Len(_txns C.SortableTransactionResult_Handle, _arg0 *int) (____error_code uint32) { + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := txns.Len() + *_arg0 = __arg0 + return +} + +//export SKY_coin_SortableTransactions_Less +func SKY_coin_SortableTransactions_Less(_txns C.SortableTransactionResult_Handle, _i, _j int, _arg1 *bool) (____error_code uint32) { + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + i := _i + j := _j + __arg1 := txns.Less(i, j) + *_arg1 = __arg1 + return +} + +//export SKY_coin_SortableTransactions_Swap +func SKY_coin_SortableTransactions_Swap(_txns C.SortableTransactionResult_Handle, _i, _j int) (____error_code uint32) { + txns, ok := lookupSortableTransactionHandle(_txns) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + i := _i + j := _j + txns.Swap(i, j) + return +} + +//export SKY_coin_VerifyTransactionCoinsSpending +func SKY_coin_VerifyTransactionCoinsSpending(_uxIn *C.coin__UxArray, _uxOut *C.coin__UxArray) (____error_code uint32) { + uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) + uxOut := *(*coin.UxArray)(unsafe.Pointer(_uxOut)) + ____return_err := coin.VerifyTransactionCoinsSpending(uxIn, uxOut) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_coin_VerifyTransactionHoursSpending +func SKY_coin_VerifyTransactionHoursSpending(_headTime uint64, _uxIn *C.coin__UxArray, _uxOut *C.coin__UxArray) (____error_code uint32) { + headTime := uint64(_headTime) + uxIn := *(*coin.UxArray)(unsafe.Pointer(_uxIn)) + uxOut := *(*coin.UxArray)(unsafe.Pointer(_uxOut)) + ____return_err := coin.VerifyTransactionHoursSpending(headTime, uxIn, uxOut) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_error.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_error.go new file mode 100644 index 000000000..a32a82b6d --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_error.go @@ -0,0 +1,691 @@ +package main + +import ( + "errors" + + "github.com/skycoin/skycoin/src/cipher" + "github.com/skycoin/skycoin/src/cipher/encoder" + "github.com/skycoin/skycoin/src/cipher/encrypt" + "github.com/skycoin/skycoin/src/cli" + "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/daemon" + "github.com/skycoin/skycoin/src/daemon/gnet" + "github.com/skycoin/skycoin/src/daemon/pex" + "github.com/skycoin/skycoin/src/params" + "github.com/skycoin/skycoin/src/util/droplet" + "github.com/skycoin/skycoin/src/util/fee" + "github.com/skycoin/skycoin/src/util/file" + "github.com/skycoin/skycoin/src/visor" + "github.com/skycoin/skycoin/src/visor/blockdb" + "github.com/skycoin/skycoin/src/visor/dbutil" + "github.com/skycoin/skycoin/src/visor/historydb" + "github.com/skycoin/skycoin/src/wallet" +) + +const ( + // SKY_PKG_LIBCGO package prefix for internal API errors + SKY_PKG_LIBCGO = 0x7F000000 // nolint megacheck + // SKY_OK error code is used to report success + SKY_OK = 0 + // SKY_ERROR generic error condition + SKY_ERROR = 0x7FFFFFFF +) + +const ( + // SKY_BAD_HANDLE invalid handle argument + SKY_BAD_HANDLE = SKY_PKG_LIBCGO + iota + 1 + // SKY_INVALID_TIMESTRING invalid time value + SKY_INVALID_TIMESTRING +) + +// Package prefixes for error codes +//nolint megacheck +const ( + // Error code prefix for api package + SKY_PKG_API = (1 + iota) << 24 // nolint megacheck + // Error code prefix for cipher package and subpackages + SKY_PKG_CIPHER + // Error code prefix for cli package + SKY_PKG_CLI + // Error code prefix for coin package + SKY_PKG_COIN + // Error code prefix for consensus package + SKY_PKG_CONSENSUS // nolint megacheck + // Error code prefix for daemon package + SKY_PKG_DAEMON + // Error code prefix for gui package + SKY_PKG_GUI // nolint megacheck + // Error code prefix for skycoin package + SKY_PKG_SKYCOIN // nolint megacheck + // Error code prefix for util package + SKY_PKG_UTIL + // Error code prefix for visor package + SKY_PKG_VISOR + // Error code prefix for wallet package + SKY_PKG_WALLET + // Error code prefix for params package + SKY_PKG_PARAMS +) + +// Error codes defined in cipher package +//nolint megacheck +const ( + // SKY_ErrAddressInvalidLength Unexpected size of address bytes buffer + SKY_ErrAddressInvalidLength = SKY_PKG_CIPHER + iota + // SKY_ErrAddressInvalidChecksum Computed checksum did not match expected value + SKY_ErrAddressInvalidChecksum + // SKY_ErrAddressInvalidVersion Unsupported address version value + SKY_ErrAddressInvalidVersion + // SKY_ErrAddressInvalidPubKey Public key invalid for address + SKY_ErrAddressInvalidPubKey + // SKY_ErrAddressInvalidFirstByte Invalid first byte in wallet import format string + SKY_ErrAddressInvalidFirstByte + // SKY_ErrAddressInvalidLastByte 33rd byte in wallet import format string is invalid + SKY_ErrAddressInvalidLastByte + // SKY_ErrBufferUnderflow bytes in input buffer not enough to deserialize expected type + SKY_ErrBufferUnderflow + // SKY_ErrInvalidOmitEmpty field tagged with omitempty and it's not last one in struct + SKY_ErrInvalidOmitEmpty + // SKY_ErrInvalidLengthPubKey Invalid public key length + SKY_ErrInvalidLengthPubKey + // SKY_ErrPubKeyFromNullSecKey PubKeyFromSecKey, attempt to load null seckey, unsafe + SKY_ErrPubKeyFromNullSecKey + // SKY_ErrPubKeyFromBadSecKey PubKeyFromSecKey, pubkey recovery failed. Function + SKY_ErrPubKeyFromBadSecKey + // SKY_ErrInvalidLengthSecKey Invalid secret key length + SKY_ErrInvalidLengthSecKey + // SKY_ErrECHDInvalidPubKey ECDH invalid pubkey input + SKY_ErrECHDInvalidPubKey + // SKY_ErrECHDInvalidSecKey ECDH invalid seckey input + SKY_ErrECHDInvalidSecKey + // SKY_ErrInvalidLengthSig Invalid signature length + SKY_ErrInvalidLengthSig + // SKY_ErrInvalidLengthRipemd160 Invalid ripemd160 length + SKY_ErrInvalidLengthRipemd160 + // SKY_ErrInvalidLengthSHA256 Invalid sha256 length + SKY_ErrInvalidLengthSHA256 + // SKY_ErrInvalidBase58Char Invalid base58 character + SKY_ErrInvalidBase58Char + // SKY_ErrInvalidBase58String Invalid base58 string + SKY_ErrInvalidBase58String + // SKY_ErrInvalidBase58Length Invalid base58 length + SKY_ErrInvalidBase58Length + // SKY_ErrInvalidHexLength Invalid hex length + SKY_ErrInvalidHexLength + // SKY_ErrInvalidBytesLength Invalid bytes length + SKY_ErrInvalidBytesLength + // SKY_ErrInvalidPubKey Invalid public key + SKY_ErrInvalidPubKey + // SKY_ErrInvalidSecKey Invalid public key + SKY_ErrInvalidSecKey + // SKY_ErrInvalidSigPubKeyRecovery Invalig sig: PubKey recovery failed + SKY_ErrInvalidSigPubKeyRecovery + // SKY_ErrInvalidSecKeyHex Invalid SecKey: not valid hex + SKY_ErrInvalidSecKeyHex // nolint megacheck + // SKY_ErrInvalidAddressForSig Invalid sig: address does not match output address + SKY_ErrInvalidAddressForSig + // SKY_ErrInvalidHashForSig Signature invalid for hash + SKY_ErrInvalidHashForSig + // SKY_ErrPubKeyRecoverMismatch Recovered pubkey does not match pubkey + SKY_ErrPubKeyRecoverMismatch + // SKY_ErrInvalidSigInvalidPubKey VerifySignedHash, secp256k1.VerifyPubkey failed + SKY_ErrInvalidSigInvalidPubKey + // SKY_ErrInvalidSigValidity VerifySignedHash, VerifySignatureValidity failed + SKY_ErrInvalidSigValidity + // SKY_ErrInvalidSigForMessage Invalid signature for this message + SKY_ErrInvalidSigForMessage + // SKY_ErrInvalidSecKyVerification Seckey secp256k1 verification failed + SKY_ErrInvalidSecKyVerification + // SKY_ErrNullPubKeyFromSecKey Impossible error, CheckSecKey, nil pubkey recovered + SKY_ErrNullPubKeyFromSecKey + // SKY_ErrInvalidDerivedPubKeyFromSecKey impossible error, CheckSecKey, Derived Pubkey verification failed + SKY_ErrInvalidDerivedPubKeyFromSecKey + // SKY_ErrInvalidPubKeyFromHash Recovered pubkey does not match signed hash + SKY_ErrInvalidPubKeyFromHash + // SKY_ErrPubKeyFromSecKeyMismatch impossible error CheckSecKey, pubkey does not match recovered pubkey + SKY_ErrPubKeyFromSecKeyMismatch + // SKY_ErrInvalidLength Unexpected size of string or bytes buffer + SKY_ErrInvalidLength + // SKY_ErrBitcoinWIFInvalidFirstByte Unexpected value (!= 0x80) of first byte in Bitcoin Wallet Import Format + SKY_ErrBitcoinWIFInvalidFirstByte + // SKY_ErrBitcoinWIFInvalidSuffix Unexpected value (!= 0x01) of 33rd byte in Bitcoin Wallet Import Format + SKY_ErrBitcoinWIFInvalidSuffix + // SKY_ErrBitcoinWIFInvalidChecksum Invalid Checksum in Bitcoin WIF address + SKY_ErrBitcoinWIFInvalidChecksum + // SKY_ErrEmptySeed Seed input is empty + SKY_ErrEmptySeed + // SKY_ErrInvalidSig Invalid signature + SKY_ErrInvalidSig + // SKY_ErrMissingPassword missing password + SKY_ErrMissingPassword + // SKY_SKY_ErrDataTooLarge data length overflowed, it must <= math.MaxUint32(4294967295) + SKY_ErrDataTooLarge + // SKY_ErrInvalidChecksumLength invalid checksum length + SKY_ErrInvalidChecksumLength + // SKY_ErrInvalidChecksum invalid data, checksum is not matched + SKY_ErrInvalidChecksum + // SKY_ErrInvalidNonceLength invalid nonce length + SKY_ErrInvalidNonceLength + // SKY_ErrInvalidBlockSize invalid block size, must be multiple of 32 bytes + SKY_ErrInvalidBlockSize + // SKY_ErrReadDataHashFailed read data hash failed: read length != 32 + SKY_ErrReadDataHashFailed + // SKY_ErrInvalidPassword invalid password SHA256or + SKY_ErrInvalidPassword + // SKY_ErrReadDataLengthFailed read data length failed + SKY_ErrReadDataLengthFailed + // SKY_ErrInvalidDataLength invalid data length + SKY_ErrInvalidDataLength +) + +// Error codes defined in cli package +// nolint megacheck +const ( + // SKY_ErrTemporaryInsufficientBalance is returned if a wallet does not have + // enough balance for a spend, but will have enough after unconfirmed transactions confirm + SKY_ErrTemporaryInsufficientBalance = SKY_PKG_CLI + iota + // SKY_ErrAddress is returned if an address is invalid + SKY_ErrAddress + // ErrWalletName is returned if the wallet file name is invalid + SKY_ErrWalletName + // ErrJSONMarshal is returned if JSON marshaling failed + SKY_ErrJSONMarshal + // WalletLoadError is returned if a wallet could not be loaded + SKY_WalletLoadError + // WalletSaveError is returned if a wallet could not be saved + SKY_WalletSaveError +) + +// Error codes defined in coin package +// nolint megacheck +const ( + // ErrAddEarnedCoinHoursAdditionOverflow is returned by UxOut.CoinHours() + // if during the addition of base coin + // hours to additional earned coin hours, the value would overflow a uint64. + // Callers may choose to ignore this errors and use 0 as the coinhours value instead. + // This affects one existing spent output, spent in block 13277. + SKY_ErrAddEarnedCoinHoursAdditionOverflow = SKY_PKG_COIN + iota + // SKY_ErrUint64MultOverflow is returned when multiplying uint64 values would overflow uint64 + SKY_ErrUint64MultOverflow + // SKY_ErrUint64AddOverflow is returned when adding uint64 values would overflow uint64 + SKY_ErrUint64AddOverflow + // SKY_ErrUint32AddOverflow is returned when adding uint32 values would overflow uint32 + SKY_ErrUint32AddOverflow + // SKY_ErrUint64OverflowsInt64 is returned when converting a uint64 to an int64 would overflow int64 + SKY_ErrUint64OverflowsInt64 + // SKY_ErrInt64UnderflowsUint64 is returned when converting an int64 to a uint64 would underflow uint64 + SKY_ErrInt64UnderflowsUint64 + // SKY_ErrIntUnderflowsUint32 is returned if when converting an int to a uint32 would underflow uint32 + SKY_ErrIntUnderflowsUint32 + // SKY_ErrIntOverflowsUint32 is returned if when converting an int to a uint32 would overflow uint32 + SKY_ErrIntOverflowsUint32 +) + +// Error codes defined in daemon package +// nolint megacheck +const ( + // SKY_ErrPeerlistFull is returned when the Pex is at a maximum + SKY_ErrPeerlistFull = SKY_PKG_DAEMON + iota + // SKY_ErrInvalidAddress is returned when an address appears malformed + SKY_ErrInvalidAddress + // SKY_ErrNoLocalhost is returned if a localhost addresses are not allowed + SKY_ErrNoLocalhost + // SKY_ErrNotExternalIP is returned if an IP address is not a global unicast address + SKY_ErrNotExternalIP + // SKY_ErrPortTooLow is returned if a port is less than 1024 + SKY_ErrPortTooLow + // SKY_ErrBlacklistedAddress returned when attempting to add a blacklisted peer + SKY_ErrBlacklistedAddress + // // SKY_ErrDisconnectReadFailed also includes a remote closed socket + // SKY_ErrDisconnectReadFailed + // SKY_ErrDisconnectWriteFailed write faile + // SKY_ErrDisconnectWriteFailed + // SKY_ErrDisconnectSetReadDeadlineFailed set read deadline failed + SKY_ErrDisconnectSetReadDeadlineFailed + // SKY_ErrDisconnectInvalidMessageLength invalid message length + SKY_ErrDisconnectInvalidMessageLength + // SKY_ErrDisconnectMalformedMessage malformed message + SKY_ErrDisconnectMalformedMessage + // SKY_ErrDisconnectUnknownMessage unknow message + SKY_ErrDisconnectUnknownMessage + // SKY_ErrConnectionPoolClosed error message indicates the connection pool is closed + SKY_ErrConnectionPoolClosed + // SKY_ErrWriteQueueFull write queue is full + SKY_ErrWriteQueueFull + // SKY_ErrNoReachableConnections when broadcasting a message, no connections were available to send a message to + SKY_ErrNoReachableConnections + // SKY_ErrMaxDefaultConnectionsReached returns when maximum number of default connections is reached + SKY_ErrMaxDefaultConnectionsReached // nolint megacheck + // SKY_ErrDisconnectReasons invalid version + SKY_ErrDisconnectVersionNotSupported + // SKY_ErrDisconnectIntroductionTimeout timeout + SKY_ErrDisconnectIntroductionTimeout + // SKY_ErrDisconnectIsBlacklisted is blacklisted + SKY_ErrDisconnectIsBlacklisted + // SKY_ErrDisconnectSelf self connnect + SKY_ErrDisconnectSelf + // SKY_ErrDisconnectConnectedTwice connect twice + SKY_ErrDisconnectConnectedTwice + // SKY_ErrDisconnectIdle idle + SKY_ErrDisconnectIdle + // SKY_ErrDisconnectNoIntroduction no introduction + SKY_ErrDisconnectNoIntroduction + // SKY_ErrDisconnectIPLimitReached ip limit reached + SKY_ErrDisconnectIPLimitReached + // SKY_ErrDisconnectMaxDefaultConnectionReached Maximum number of default connections was reached + SKY_ErrDisconnectMaxDefaultConnectionReached // nolint megacheck + // SKY_ErrDisconnectMaxOutgoingConnectionsReached is returned when connection pool size is greater than the maximum allowed + SKY_ErrDisconnectMaxOutgoingConnectionsReached + // SKY_ConnectionError represent a failure to connect/dial a connection, with context + SKY_ConnectionError // nolint megacheck +) + +// Error codes defined in util package +// nolint megacheck +const ( + // ErrTxnNoFee is returned if a transaction has no coinhour fee + SKY_ErrTxnNoFee = SKY_PKG_UTIL + iota + // ErrTxnInsufficientFee is returned if a transaction's coinhour burn fee is not enough + SKY_ErrTxnInsufficientFee + // ErrTxnInsufficientCoinHours is returned if a transaction has more coinhours in its outputs than its inputs + SKY_ErrTxnInsufficientCoinHours + // ErrNegativeValue is returned if a balance string is a negative number + SKY_ErrNegativeValue + // ErrTooManyDecimals is returned if a balance string has more than 6 decimal places + SKY_ErrTooManyDecimals + // ErrTooLarge is returned if a balance string is greater than math.MaxInt64 + SKY_ErrTooLarge + // ErrEmptyDirectoryName is returned by constructing the full path + SKY_ErrEmptyDirectoryName + // ErrDotDirectoryName is returned by constructing the full path of + SKY_ErrDotDirectoryName +) + +// Error codes defined in visor package +// nolint megacheck +const ( + // SKY_ErrHistoryDBCorrupted Internal format error in HistoryDB database + SKY_ErrHistoryDBCorrupted = SKY_PKG_VISOR + iota + // SKY_ErrUxOutNotExist is returned if an uxout is not found in historydb + SKY_ErrUxOutNotExist + // ErrNoHeadBlock is returned when calling Blockchain.Head() when no head block exists + SKY_ErrNoHeadBlock + // SKY_ErrMissingSignature is returned if a block in the db does not have a corresponding signature in the db + SKY_ErrMissingSignature + // SKY_ErrUnspentNotExist is returned if an unspent is not found in the pool + SKY_ErrUnspentNotExist + // ErrVerifyStopped is returned when database verification is interrupted + SKY_ErrVerifyStopped + // SKY_ErrCreateBucketFailed is returned if creating a bolt.DB bucket fails + SKY_ErrCreateBucketFailed + // SKY_ErrBucketNotExist is returned if a bolt.DB bucket does not exist + SKY_ErrBucketNotExist + // SKY_ErrTxnViolatesHardConstraint is returned when a transaction violates hard constraints + SKY_ErrTxnViolatesHardConstraint + // SKY_ErrTxnViolatesSoftConstraint is returned when a transaction violates soft constraints + SKY_ErrTxnViolatesSoftConstraint + // SKY_ErrTxnViolatesUserConstraint is returned when a transaction violates user constraints + SKY_ErrTxnViolatesUserConstraint +) + +// Error codes defined in wallet package +// nolint megacheck +const ( + // SKY_ErrInsufficientBalance is returned if a wallet does not have enough balance for a spend + SKY_ErrInsufficientBalance = SKY_PKG_WALLET + iota + // SKY_ErrInsufficientHours is returned if a wallet does not have enough hours for a spend with requested hours + SKY_ErrInsufficientHours + // SKY_ErrZeroSpend is returned if a transaction is trying to spend 0 coins + SKY_ErrZeroSpend + // SKY_ErrSpendingUnconfirmed is returned if caller attempts to spend unconfirmed outputs + SKY_ErrSpendingUnconfirmed + // SKY_ErrInvalidEncryptedField is returned if a wallet's Meta.encrypted value is invalid. + SKY_ErrInvalidEncryptedField + // SKY_ErrWalletEncrypted is returned when trying to generate addresses or sign tx in encrypted wallet + SKY_ErrWalletEncrypted + // SKY_ErrWalletNotEncrypted is returned when trying to decrypt unencrypted wallet + SKY_ErrWalletNotEncrypted + // SKY_ErrWalletMissingPassword is returned when trying to create wallet with encryption, but password is not provided. + SKY_ErrWalletMissingPassword + // SKY_ErrMissingEncrypt is returned when trying to create wallet with password, but options.Encrypt is not set. + SKY_ErrMissingEncrypt + // SKY_ErrWalletInvalidPassword is returned if decrypts secrets failed + SKY_ErrWalletInvalidPassword + // SKY_ErrMissingSeed is returned when trying to create wallet without a seed + SKY_ErrMissingSeed + // SKY_ErrMissingAuthenticated is returned if try to decrypt a scrypt chacha20poly1305 encrypted wallet, and find no authenticated metadata. + SKY_ErrMissingAuthenticated + // SKY_ErrWrongCryptoType is returned when decrypting wallet with wrong crypto method + SKY_ErrWrongCryptoType + // SKY_ErrWalletNotExist is returned if a wallet does not exist + SKY_ErrWalletNotExist + // SKY_ErrSeedUsed is returned if a wallet already exists with the same seed + SKY_ErrSeedUsed + // SKY_ErrWalletAPIDisabled is returned when trying to do wallet actions while the EnableWalletAPI option is false + SKY_ErrWalletAPIDisabled + // SKY_ErrSeedAPIDisabled is returned when trying to get seed of wallet while the EnableWalletAPI or EnableSeedAPI is false + SKY_ErrSeedAPIDisabled + // SKY_ErrWalletNameConflict represents the wallet name conflict error + SKY_ErrWalletNameConflict + // SKY_ErrInvalidHoursSelectionMode for invalid HoursSelection mode values + SKY_ErrInvalidHoursSelectionMode + // SKY_ErrInvalidHoursSelectionType for invalid HoursSelection type values + SKY_ErrInvalidHoursSelectionType + // SKY_ErrUnknownAddress is returned if an address is not found in a wallet + SKY_ErrUnknownAddress + // SKY_ErrUnknownUxOut is returned if a uxout is not owned by any address in a wallet + SKY_ErrUnknownUxOut + // SKY_ErrNoUnspents is returned if a wallet has no unspents to spend + SKY_ErrNoUnspents + // SKY_ErrNullChangeAddress ChangeAddress must not be the null address + SKY_ErrNullChangeAddress + // SKY_ErrMissingTo To is required + SKY_ErrMissingTo + // SKY_ErrZeroCoinsTo To.Coins must not be zero + SKY_ErrZeroCoinsTo + // SKY_ErrNullAddressTo To.Address must not be the null address + SKY_ErrNullAddressTo + // SKY_ErrDuplicateTo To contains duplicate values + SKY_ErrDuplicateTo + // SKY_ErrMissingWalletID Wallet.ID is required + SKY_ErrMissingWalletID + // SKY_ErrIncludesNullAddress Wallet.Addresses must not contain the null address + SKY_ErrIncludesNullAddress + // SKY_ErrDuplicateAddresses Wallet.Addresses contains duplicate values + SKY_ErrDuplicateAddresses + // SKY_ErrZeroToHoursAuto To.Hours must be zero for auto type hours selection + SKY_ErrZeroToHoursAuto + // SKY_ErrMissingModeAuto HoursSelection.Mode is required for auto type hours selection + SKY_ErrMissingModeAuto + // SKY_ErrInvalidHoursSelMode Invalid HoursSelection.Mode + SKY_ErrInvalidHoursSelMode + // SKY_ErrInvalidModeManual HoursSelection.Mode cannot be used for manual type hours selection + SKY_ErrInvalidModeManual + // SKY_ErrInvalidHoursSelType Invalid HoursSelection.Type + SKY_ErrInvalidHoursSelType + // SKY_ErrMissingShareFactor HoursSelection.ShareFactor must be set for share mode + SKY_ErrMissingShareFactor + // SKY_ErrInvalidShareFactor HoursSelection.ShareFactor can only be used for share mode + SKY_ErrInvalidShareFactor + // SKY_ErrShareFactorOutOfRange HoursSelection.ShareFactor must be >= 0 and <= 1 + SKY_ErrShareFactorOutOfRange + // SKY_ErrWalletParamsConflict Wallet.UxOuts and Wallet.Addresses cannot be combined + SKY_ErrWalletParamsConflict + // SKY_ErrDuplicateUxOuts Wallet.UxOuts contains duplicate values + SKY_ErrDuplicateUxOuts + // SKY_ErrUnknownWalletID params.Wallet.ID does not match wallet + SKY_ErrUnknownWalletID + // SKY_ErrVerifySignatureInvalidInputsNils VerifySignature, ERROR: invalid input, nils + SKY_ErrVerifySignatureInvalidInputsNils + // SKY_ErrVerifySignatureInvalidSigLength + SKY_ErrVerifySignatureInvalidSigLength + // SKY_ErrVerifySignatureInvalidPubkeysLength + SKY_ErrVerifySignatureInvalidPubkeysLength +) + +// Error codes defined in params package +// nolint megacheck +const ( + // SKY_ErrInvalidDecimals is returned by DropletPrecisionCheck if a coin amount has an invalid number of decimal places + SKY_ErrInvalidDecimals = SKY_PKG_PARAMS + iota +) + +var ( + // ErrorBadHandle invalid handle value + ErrorBadHandle = errors.New("Invalid or unknown handle value") + // ErrorUnknown unexpected error + ErrorUnknown = errors.New("Unexpected error") + // ErrorInvalidTimeString time string does not match expected time format + // More precise errors conditions can be found in the logs + ErrorInvalidTimeString = errors.New("Invalid time value") + + codeToErrorMap = make(map[uint32]error) + errorToCodeMap = map[error]uint32{ + // libcgo + ErrorBadHandle: SKY_BAD_HANDLE, + ErrorUnknown: SKY_ERROR, + ErrorInvalidTimeString: SKY_INVALID_TIMESTRING, + // cipher + cipher.ErrAddressInvalidLength: SKY_ErrAddressInvalidLength, + cipher.ErrAddressInvalidChecksum: SKY_ErrAddressInvalidChecksum, + cipher.ErrAddressInvalidVersion: SKY_ErrAddressInvalidVersion, + cipher.ErrAddressInvalidPubKey: SKY_ErrAddressInvalidPubKey, + cipher.ErrAddressInvalidFirstByte: SKY_ErrAddressInvalidFirstByte, + cipher.ErrAddressInvalidLastByte: SKY_ErrAddressInvalidLastByte, + encoder.ErrBufferUnderflow: SKY_ErrBufferUnderflow, + encoder.ErrInvalidOmitEmpty: SKY_ErrInvalidOmitEmpty, + cipher.ErrInvalidLengthPubKey: SKY_ErrInvalidLengthPubKey, + cipher.ErrPubKeyFromNullSecKey: SKY_ErrPubKeyFromNullSecKey, + cipher.ErrPubKeyFromBadSecKey: SKY_ErrPubKeyFromBadSecKey, + cipher.ErrInvalidLengthSecKey: SKY_ErrInvalidLengthSecKey, + cipher.ErrECHDInvalidPubKey: SKY_ErrECHDInvalidPubKey, + cipher.ErrECHDInvalidSecKey: SKY_ErrECHDInvalidSecKey, + cipher.ErrInvalidLengthSig: SKY_ErrInvalidLengthSig, + cipher.ErrInvalidLengthRipemd160: SKY_ErrInvalidLengthRipemd160, + cipher.ErrInvalidLengthSHA256: SKY_ErrInvalidLengthSHA256, + // base58.ErrInvalidBase58Char: SKY_ErrInvalidBase58Char, + // base58.ErrInvalidBase58String: SKY_ErrInvalidBase58String, + // base58.ErrInvalidBase58Length: SKY_ErrInvalidBase58Length, + cipher.ErrInvalidHexLength: SKY_ErrInvalidHexLength, + cipher.ErrInvalidBytesLength: SKY_ErrInvalidBytesLength, + cipher.ErrInvalidPubKey: SKY_ErrInvalidPubKey, + cipher.ErrInvalidSecKey: SKY_ErrInvalidSecKey, + cipher.ErrInvalidSigPubKeyRecovery: SKY_ErrInvalidSigPubKeyRecovery, + // Removed in ea0aafbffb76 + // cipher.ErrInvalidSecKeyHex: SKY_ErrInvalidSecKeyHex, + cipher.ErrInvalidAddressForSig: SKY_ErrInvalidAddressForSig, + cipher.ErrInvalidHashForSig: SKY_ErrInvalidHashForSig, + cipher.ErrPubKeyRecoverMismatch: SKY_ErrPubKeyRecoverMismatch, + cipher.ErrInvalidSigInvalidPubKey: SKY_ErrInvalidSigInvalidPubKey, + cipher.ErrInvalidSigValidity: SKY_ErrInvalidSigValidity, + cipher.ErrInvalidSigForMessage: SKY_ErrInvalidSigForMessage, + cipher.ErrInvalidSecKyVerification: SKY_ErrInvalidSecKyVerification, + cipher.ErrNullPubKeyFromSecKey: SKY_ErrNullPubKeyFromSecKey, + cipher.ErrInvalidDerivedPubKeyFromSecKey: SKY_ErrInvalidDerivedPubKeyFromSecKey, + cipher.ErrInvalidPubKeyFromHash: SKY_ErrInvalidPubKeyFromHash, + cipher.ErrPubKeyFromSecKeyMismatch: SKY_ErrPubKeyFromSecKeyMismatch, + cipher.ErrInvalidLength: SKY_ErrInvalidLength, + cipher.ErrBitcoinWIFInvalidFirstByte: SKY_ErrBitcoinWIFInvalidFirstByte, + cipher.ErrBitcoinWIFInvalidSuffix: SKY_ErrBitcoinWIFInvalidSuffix, + cipher.ErrBitcoinWIFInvalidChecksum: SKY_ErrBitcoinWIFInvalidChecksum, + cipher.ErrEmptySeed: SKY_ErrEmptySeed, + cipher.ErrInvalidSig: SKY_ErrInvalidSig, + encrypt.ErrMissingPassword: SKY_ErrMissingPassword, + encrypt.ErrDataTooLarge: SKY_ErrDataTooLarge, + encrypt.ErrInvalidChecksumLength: SKY_ErrInvalidChecksumLength, + encrypt.ErrInvalidChecksum: SKY_ErrInvalidChecksum, + encrypt.ErrInvalidNonceLength: SKY_ErrInvalidNonceLength, + encrypt.ErrInvalidBlockSize: SKY_ErrInvalidBlockSize, + encrypt.ErrReadDataHashFailed: SKY_ErrReadDataHashFailed, + encrypt.ErrInvalidPassword: SKY_ErrInvalidPassword, + encrypt.ErrReadDataLengthFailed: SKY_ErrReadDataLengthFailed, + encrypt.ErrInvalidDataLength: SKY_ErrInvalidDataLength, + + // cli + cli.ErrTemporaryInsufficientBalance: SKY_ErrTemporaryInsufficientBalance, + cli.ErrAddress: SKY_ErrAddress, + cli.ErrWalletName: SKY_ErrWalletName, + cli.ErrJSONMarshal: SKY_ErrJSONMarshal, + // coin + coin.ErrAddEarnedCoinHoursAdditionOverflow: SKY_ErrAddEarnedCoinHoursAdditionOverflow, + coin.ErrUint64MultOverflow: SKY_ErrUint64MultOverflow, + coin.ErrUint64AddOverflow: SKY_ErrUint64AddOverflow, + coin.ErrUint32AddOverflow: SKY_ErrUint32AddOverflow, + coin.ErrUint64OverflowsInt64: SKY_ErrUint64OverflowsInt64, + coin.ErrInt64UnderflowsUint64: SKY_ErrInt64UnderflowsUint64, + coin.ErrIntUnderflowsUint32: SKY_ErrIntUnderflowsUint32, + coin.ErrIntOverflowsUint32: SKY_ErrIntOverflowsUint32, + // daemon + // Removed in 34ad39ddb350 + // gnet.ErrMaxDefaultConnectionsReached: SKY_ErrMaxDefaultConnectionsReached, + pex.ErrPeerlistFull: SKY_ErrPeerlistFull, + pex.ErrInvalidAddress: SKY_ErrInvalidAddress, + pex.ErrNoLocalhost: SKY_ErrNoLocalhost, + pex.ErrNotExternalIP: SKY_ErrNotExternalIP, + pex.ErrPortTooLow: SKY_ErrPortTooLow, + pex.ErrBlacklistedAddress: SKY_ErrBlacklistedAddress, + // gnet.ErrDisconnectReadFailed: SKY_ErrDisconnectReadFailed, + // gnet.ErrDisconnectWriteFailed: SKY_ErrDisconnectWriteFailed, + gnet.ErrDisconnectSetReadDeadlineFailed: SKY_ErrDisconnectSetReadDeadlineFailed, + gnet.ErrDisconnectInvalidMessageLength: SKY_ErrDisconnectInvalidMessageLength, + gnet.ErrDisconnectMalformedMessage: SKY_ErrDisconnectMalformedMessage, + gnet.ErrDisconnectUnknownMessage: SKY_ErrDisconnectUnknownMessage, + gnet.ErrConnectionPoolClosed: SKY_ErrConnectionPoolClosed, + gnet.ErrWriteQueueFull: SKY_ErrWriteQueueFull, + gnet.ErrNoReachableConnections: SKY_ErrNoReachableConnections, + daemon.ErrDisconnectVersionNotSupported: SKY_ErrDisconnectVersionNotSupported, + daemon.ErrDisconnectIntroductionTimeout: SKY_ErrDisconnectIntroductionTimeout, + daemon.ErrDisconnectIsBlacklisted: SKY_ErrDisconnectIsBlacklisted, + daemon.ErrDisconnectSelf: SKY_ErrDisconnectSelf, + daemon.ErrDisconnectConnectedTwice: SKY_ErrDisconnectConnectedTwice, + daemon.ErrDisconnectIdle: SKY_ErrDisconnectIdle, + daemon.ErrDisconnectNoIntroduction: SKY_ErrDisconnectNoIntroduction, + daemon.ErrDisconnectIPLimitReached: SKY_ErrDisconnectIPLimitReached, + // Removed + // daemon.ErrDisconnectMaxDefaultConnectionReached: SKY_ErrDisconnectMaxDefaultConnectionReached, + daemon.ErrDisconnectMaxOutgoingConnectionsReached: SKY_ErrDisconnectMaxOutgoingConnectionsReached, + // util + fee.ErrTxnNoFee: SKY_ErrTxnNoFee, + fee.ErrTxnInsufficientFee: SKY_ErrTxnInsufficientFee, + fee.ErrTxnInsufficientCoinHours: SKY_ErrTxnInsufficientCoinHours, + droplet.ErrNegativeValue: SKY_ErrNegativeValue, + droplet.ErrTooManyDecimals: SKY_ErrTooManyDecimals, + droplet.ErrTooLarge: SKY_ErrTooLarge, + file.ErrEmptyDirectoryName: SKY_ErrEmptyDirectoryName, + file.ErrDotDirectoryName: SKY_ErrDotDirectoryName, + // visor + blockdb.ErrNoHeadBlock: SKY_ErrNoHeadBlock, + visor.ErrVerifyStopped: SKY_ErrVerifyStopped, + // wallet + wallet.ErrInsufficientBalance: SKY_ErrInsufficientBalance, + wallet.ErrInsufficientHours: SKY_ErrInsufficientHours, + wallet.ErrZeroSpend: SKY_ErrZeroSpend, + wallet.ErrSpendingUnconfirmed: SKY_ErrSpendingUnconfirmed, + wallet.ErrInvalidEncryptedField: SKY_ErrInvalidEncryptedField, + wallet.ErrWalletEncrypted: SKY_ErrWalletEncrypted, + wallet.ErrWalletNotEncrypted: SKY_ErrWalletNotEncrypted, + wallet.ErrMissingPassword: SKY_ErrWalletMissingPassword, + wallet.ErrMissingEncrypt: SKY_ErrMissingEncrypt, + wallet.ErrInvalidPassword: SKY_ErrWalletInvalidPassword, + wallet.ErrMissingSeed: SKY_ErrMissingSeed, + wallet.ErrMissingAuthenticated: SKY_ErrMissingAuthenticated, + wallet.ErrWrongCryptoType: SKY_ErrWrongCryptoType, + wallet.ErrWalletNotExist: SKY_ErrWalletNotExist, + wallet.ErrSeedUsed: SKY_ErrSeedUsed, + wallet.ErrWalletAPIDisabled: SKY_ErrWalletAPIDisabled, + wallet.ErrSeedAPIDisabled: SKY_ErrSeedAPIDisabled, + wallet.ErrWalletNameConflict: SKY_ErrWalletNameConflict, + wallet.ErrInvalidHoursSelectionMode: SKY_ErrInvalidHoursSelectionMode, + wallet.ErrInvalidHoursSelectionType: SKY_ErrInvalidHoursSelectionType, + wallet.ErrUnknownAddress: SKY_ErrUnknownAddress, + wallet.ErrUnknownUxOut: SKY_ErrUnknownUxOut, + wallet.ErrNoUnspents: SKY_ErrNoUnspents, + wallet.ErrNullChangeAddress: SKY_ErrNullChangeAddress, + wallet.ErrMissingTo: SKY_ErrMissingTo, + wallet.ErrZeroCoinsTo: SKY_ErrZeroCoinsTo, + wallet.ErrNullAddressTo: SKY_ErrNullAddressTo, + wallet.ErrDuplicateTo: SKY_ErrDuplicateTo, + wallet.ErrMissingWalletID: SKY_ErrMissingWalletID, + wallet.ErrIncludesNullAddress: SKY_ErrIncludesNullAddress, + wallet.ErrDuplicateAddresses: SKY_ErrDuplicateAddresses, + wallet.ErrZeroToHoursAuto: SKY_ErrZeroToHoursAuto, + wallet.ErrMissingModeAuto: SKY_ErrMissingModeAuto, + wallet.ErrInvalidHoursSelMode: SKY_ErrInvalidHoursSelMode, + wallet.ErrInvalidModeManual: SKY_ErrInvalidModeManual, + wallet.ErrInvalidHoursSelType: SKY_ErrInvalidHoursSelType, + wallet.ErrMissingShareFactor: SKY_ErrMissingShareFactor, + wallet.ErrInvalidShareFactor: SKY_ErrInvalidShareFactor, + wallet.ErrShareFactorOutOfRange: SKY_ErrShareFactorOutOfRange, + wallet.ErrWalletParamsConflict: SKY_ErrWalletParamsConflict, + wallet.ErrDuplicateUxOuts: SKY_ErrDuplicateUxOuts, + wallet.ErrUnknownWalletID: SKY_ErrUnknownWalletID, + // params + params.ErrInvalidDecimals: SKY_ErrInvalidDecimals, + } +) + +func libErrorCode(err error) uint32 { + if err == nil { + return SKY_OK + } + if errcode, isKnownError := errorToCodeMap[err]; isKnownError { + return errcode + } + switch err.(type) { + case cli.WalletLoadError: + return SKY_WalletLoadError + case cli.WalletSaveError: + return SKY_WalletSaveError + // case daemon.ConnectionError: + // return SKY_ConnectionError + case historydb.ErrHistoryDBCorrupted: + return SKY_ErrHistoryDBCorrupted + case historydb.ErrUxOutNotExist: + return SKY_ErrUxOutNotExist + case blockdb.ErrUnspentNotExist: + return SKY_ErrUnspentNotExist + case blockdb.ErrMissingSignature: + return SKY_ErrMissingSignature + case dbutil.ErrCreateBucketFailed: + return SKY_ErrCreateBucketFailed + case dbutil.ErrBucketNotExist: + return SKY_ErrBucketNotExist + case visor.ErrTxnViolatesHardConstraint: + return SKY_ErrTxnViolatesHardConstraint + case visor.ErrTxnViolatesSoftConstraint: + return SKY_ErrTxnViolatesSoftConstraint + case visor.ErrTxnViolatesUserConstraint: + return SKY_ErrTxnViolatesUserConstraint + } + return SKY_ERROR +} + +func errorFromLibCode(errcode uint32) error { + if err, exists := codeToErrorMap[errcode]; exists { + return err + } + + // FIXME: Be more specific and encode type, sub-error in error code + err := errors.New("libskycoin error") + if errcode == SKY_WalletLoadError { + return cli.WalletLoadError{} + } + if errcode == SKY_WalletSaveError { + return cli.WalletSaveError{} + } + if errcode == SKY_ErrHistoryDBCorrupted { + return historydb.NewErrHistoryDBCorrupted(err) + } + if errcode == SKY_ErrUxOutNotExist { + return historydb.ErrUxOutNotExist{UxID: ""} + } + if errcode == SKY_ErrUnspentNotExist { + return blockdb.ErrUnspentNotExist{UxID: ""} + } + if errcode == SKY_ErrMissingSignature { + return blockdb.NewErrMissingSignature(nil) + } + if errcode == SKY_ErrCreateBucketFailed { + return dbutil.ErrCreateBucketFailed{Bucket: "", Err: nil} + } + if errcode == SKY_ErrBucketNotExist { + return dbutil.ErrBucketNotExist{Bucket: ""} + } + if errcode == SKY_ErrTxnViolatesHardConstraint { + return visor.ErrTxnViolatesHardConstraint{Err: err} + } + if errcode == SKY_ErrTxnViolatesSoftConstraint { + return visor.ErrTxnViolatesSoftConstraint{Err: err} + } + if errcode == SKY_ErrTxnViolatesUserConstraint { + return visor.ErrTxnViolatesUserConstraint{Err: err} + } + return nil +} + +func init() { + // Init reverse error code map + for _err := range errorToCodeMap { + codeToErrorMap[errorToCodeMap[_err]] = _err + } +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_handle.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_handle.go new file mode 100644 index 000000000..ee4fb7a4b --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_handle.go @@ -0,0 +1,521 @@ +package main + +/* + + #include + #include + + + #include "skytypes.h" +*/ +import "C" + +import ( + "hash" + + "github.com/spf13/cobra" + + "github.com/skycoin/skycoin/src/api" + "github.com/skycoin/skycoin/src/api/webrpc" + "github.com/skycoin/skycoin/src/cli" + "github.com/skycoin/skycoin/src/coin" + "github.com/skycoin/skycoin/src/readable" + "github.com/skycoin/skycoin/src/wallet" +) + +type Handle uint64 + +var ( + handlesCounter uint64 = 0 + handleMap = make(map[Handle]interface{}) +) + +func registerHandle(obj interface{}) C.Handle { + handlesCounter++ + handle := handlesCounter + //handle := *(*Handle)(unsafe.Pointer(&obj)) + handleMap[Handle(handle)] = obj + return (C.Handle)(handle) +} + +func lookupHandle(handle C.Handle) (interface{}, bool) { + obj, ok := handleMap[Handle(handle)] + return obj, ok +} + +func overwriteHandle(handle C.Handle, obj interface{}) bool { + _, ok := handleMap[Handle(handle)] + if ok { + handleMap[Handle(handle)] = obj + return true + } + return false +} + +func registerWebRpcClientHandle(obj *webrpc.Client) C.WebRpcClient__Handle { + return (C.WebRpcClient__Handle)(registerHandle(obj)) +} + +func lookupWebRpcClientHandle(handle C.WebRpcClient__Handle) (*webrpc.Client, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.Client); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletHandle(obj *wallet.Wallet) C.Wallet__Handle { + return (C.Wallet__Handle)(registerHandle(obj)) +} + +func lookupWalletHandle(handle C.Wallet__Handle) (*wallet.Wallet, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.Wallet); isOK { + return obj, true + } + } + return nil, false +} + +func registerReadableWalletHandle(obj *wallet.ReadableWallet) C.ReadableWallet__Handle { + return (C.ReadableWallet__Handle)(registerHandle(obj)) +} + +func lookupReadableWalletHandle(handle C.ReadableWallet__Handle) (*wallet.ReadableWallet, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.ReadableWallet); isOK { + return obj, true + } + } + return nil, false +} + +func registerReadableEntryHandle(obj *wallet.ReadableEntry) C.ReadableEntry__Handle { + return (C.ReadableEntry__Handle)(registerHandle(obj)) +} + +func lookupReadableEntryHandle(handle C.ReadableEntry__Handle) (*wallet.ReadableEntry, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.ReadableEntry); isOK { + return obj, true + } + } + return nil, false +} + +func registerOptionsHandle(obj *wallet.Options) C.Options__Handle { + return (C.Options__Handle)(registerHandle(obj)) +} + +func lookupOptionsHandle(handle C.Options__Handle) (*wallet.Options, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*wallet.Options); isOK { + return obj, true + } + } + return nil, false +} + +func registerConfigHandle(obj *cli.Config) C.Config__Handle { + return (C.Config__Handle)(registerHandle(obj)) +} + +func lookupConfigHandle(handle C.Config__Handle) (*cli.Config, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*cli.Config); isOK { + return obj, true + } + } + return nil, false +} + +func registerCLIHandle(obj *cobra.Command) C.CLI__Handle { + return (C.CLI__Handle)(registerHandle(obj)) +} + +func lookupCLIHandle(handle C.CLI__Handle) (*cobra.Command, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*cobra.Command); isOK { + return obj, true + } + } + return nil, false +} + +func registerClientHandle(obj *api.Client) C.Client__Handle { + return (C.Client__Handle)(registerHandle(obj)) +} + +func lookupClientHandle(handle C.Client__Handle) (*api.Client, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.Client); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletsHandle(obj *[]api.WalletResponse) C.Wallets__Handle { + return (C.Wallets__Handle)(registerHandle(obj)) +} + +func lookupWalletsHandle(handle C.Wallets__Handle) ([]*api.WalletResponse, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).([]*api.WalletResponse); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletResponseHandle(obj *api.WalletResponse) C.WalletResponse__Handle { + return (C.WalletResponse__Handle)(registerHandle(obj)) +} + +func lookupWalletResponseHandle(handle C.WalletResponse__Handle) (*api.WalletResponse, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.WalletResponse); isOK { + return obj, true + } + } + return nil, false +} + +func registerCreateTransactionRequestHandle(obj *api.CreateTransactionRequest) C.CreateTransactionRequest__Handle { + return (C.CreateTransactionRequest__Handle)(registerHandle(obj)) +} + +func lookupCreateTransactionRequestHandle(handle C.CreateTransactionRequest__Handle) (*api.CreateTransactionRequest, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreateTransactionRequest); isOK { + return obj, true + } + } + return nil, false +} + +func registerPasswordReaderHandle(obj *cli.PasswordReader) C.PasswordReader__Handle { + return (C.PasswordReader__Handle)(registerHandle(obj)) +} + +func lookupPasswordReaderHandle(handle C.PasswordReader__Handle) (*cli.PasswordReader, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*cli.PasswordReader); isOK { + return obj, true + } + } + return nil, false +} + +func registerTransactionHandle(obj *coin.Transaction) C.Transaction__Handle { + return (C.Transaction__Handle)(registerHandle(obj)) +} + +func lookupTransactionHandle(handle C.Transaction__Handle) (*coin.Transaction, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.Transaction); isOK { + return obj, true + } + } + return nil, false +} + +func registerTransactionsHandle(obj *coin.Transactions) C.Transactions__Handle { + return (C.Transactions__Handle)(registerHandle(obj)) +} + +func lookupTransactionsHandle(handle C.Transactions__Handle) (*coin.Transactions, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.Transactions); isOK { + return obj, true + } + } + return nil, false +} + +func registerBlockHandle(obj *coin.Block) C.Block__Handle { + return (C.Block__Handle)(registerHandle(obj)) +} + +func lookupBlockHandle(handle C.Block__Handle) (*coin.Block, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.Block); isOK { + return obj, true + } + } + return nil, false +} + +func registerSignedBlockHandle(obj *coin.SignedBlock) C.SignedBlock__Handle { + return (C.SignedBlock__Handle)(registerHandle(obj)) +} + +func lookupSignedBlockHandle(handle C.SignedBlock__Handle) (*coin.SignedBlock, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.SignedBlock); isOK { + return obj, true + } + } + return nil, false +} + +func registerBlockBodyHandle(obj *coin.BlockBody) C.BlockBody__Handle { + return (C.BlockBody__Handle)(registerHandle(obj)) +} + +func lookupBlockBodyHandle(handle C.BlockBody__Handle) (*coin.BlockBody, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.BlockBody); isOK { + return obj, true + } + } + return nil, false +} + +func registerCreatedTransactionHandle(obj *api.CreatedTransaction) C.CreatedTransaction__Handle { + return (C.CreatedTransaction__Handle)(registerHandle(obj)) +} + +func lookupCreatedTransactionHandle(handle C.CreatedTransaction__Handle) (*api.CreatedTransaction, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreatedTransaction); isOK { + return obj, true + } + } + return nil, false +} + +func registerCreatedTransactionOutputHandle(obj *api.CreatedTransactionOutput) C.CreatedTransactionOutput__Handle { + return (C.CreatedTransactionOutput__Handle)(registerHandle(obj)) +} + +func lookupCreatedTransactionOutputHandle(handle C.CreatedTransactionOutput__Handle) (*api.CreatedTransactionOutput, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreatedTransactionOutput); isOK { + return obj, true + } + } + return nil, false +} + +func registerCreatedTransactionInputHandle(obj *api.CreatedTransactionInput) C.CreatedTransactionInput__Handle { + return (C.CreatedTransactionInput__Handle)(registerHandle(obj)) +} + +func lookupCreatedTransactionInputHandle(handle C.CreatedTransactionInput__Handle) (*api.CreatedTransactionInput, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreatedTransactionInput); isOK { + return obj, true + } + } + return nil, false +} + +func registerCreateTransactionResponseHandle(obj *api.CreateTransactionResponse) C.CreateTransactionResponse__Handle { + return (C.CreateTransactionResponse__Handle)(registerHandle(obj)) +} + +func lookupCreateTransactionResponseHandle(handle C.CreateTransactionResponse__Handle) (*api.CreateTransactionResponse, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.CreateTransactionResponse); isOK { + return obj, true + } + } + return nil, false +} + +func registerBalanceResultHandle(obj *cli.BalanceResult) C.BalanceResult_Handle { + return (C.BalanceResult_Handle)(registerHandle(obj)) +} + +func lookupBalanceResultHandle(handle C.BalanceResult_Handle) (*cli.BalanceResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*cli.BalanceResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerSpendResultHandle(obj *api.SpendResult) C.SpendResult_Handle { + return (C.SpendResult_Handle)(registerHandle(obj)) +} + +func lookupSpendResultHandle(handle C.SpendResult_Handle) (*api.SpendResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.SpendResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerTransactionResultHandle(obj *webrpc.TxnResult) C.TransactionResult_Handle { + return (C.TransactionResult_Handle)(registerHandle(obj)) +} + +func lookupTransactionResultHandle(handle C.TransactionResult_Handle) (*webrpc.TxnResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.TxnResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerSortableTransactiontHandle(obj *coin.SortableTransactions) C.SortableTransactionResult_Handle { + return (C.SortableTransactionResult_Handle)(registerHandle(obj)) +} + +func lookupSortableTransactionHandle(handle C.SortableTransactionResult_Handle) (*coin.SortableTransactions, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.SortableTransactions); isOK { + return obj, true + } + } + return nil, false +} + +func registerOutputsResultHandle(obj *webrpc.OutputsResult) C.OutputsResult_Handle { + return (C.OutputsResult_Handle)(registerHandle(obj)) +} + +func lookupOutputsResultHandle(handle C.OutputsResult_Handle) (*webrpc.OutputsResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.OutputsResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerStatusResultHandle(obj *webrpc.StatusResult) C.StatusResult_Handle { + return (C.StatusResult_Handle)(registerHandle(obj)) +} + +func lookupStatusResultHandle(handle C.StatusResult_Handle) (*webrpc.StatusResult, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*webrpc.StatusResult); isOK { + return obj, true + } + } + return nil, false +} + +func registerAddressUxOutHandle(obj *coin.AddressUxOuts) C.AddressUxOuts_Handle { + return (C.AddressUxOuts_Handle)(registerHandle(obj)) +} + +func lookupAddressUxOutHandle(handle C.AddressUxOuts_Handle) (*coin.AddressUxOuts, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.AddressUxOuts); isOK { + return obj, true + } + } + return nil, false +} + +func registerHashHandle(obj *hash.Hash) C.Hash_Handle { + return (C.Hash_Handle)(registerHandle(obj)) +} + +func lookupHashHandle(handle C.Hash_Handle) (*hash.Hash, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*hash.Hash); isOK { + return obj, true + } + } + return nil, false +} + +func closeHandle(handle Handle) { + delete(handleMap, handle) +} + +//export SKY_handle_close +func SKY_handle_close(handle C.Handle) { + closeHandle(Handle(handle)) +} + +//export SKY_handle_copy +func SKY_handle_copy(handle C.Handle, copy *C.Handle) uint32 { + obj, ok := lookupHandle(handle) + if ok { + *copy = registerHandle(obj) + return SKY_OK + } else { + return SKY_BAD_HANDLE + } +} + +func registerReadableUnspentOutputsSummaryHandle(obj *readable.UnspentOutputsSummary) C.ReadableUnspentOutputsSummary_Handle { + return (C.ReadableUnspentOutputsSummary_Handle)(registerHandle(obj)) +} + +func lookupReadableUnspentOutputsSummaryHandle(handle C.ReadableUnspentOutputsSummary_Handle) (*readable.UnspentOutputsSummary, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*readable.UnspentOutputsSummary); isOK { + return obj, true + } + } + return nil, false +} + +func registerBuildInfoHandle(obj *readable.BuildInfo) C.BuildInfo_Handle { + return (C.BuildInfo_Handle)(registerHandle(obj)) +} + +func lookupBuildInfoHandle(handle C.BuildInfo_Handle) (*readable.BuildInfo, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*readable.BuildInfo); isOK { + return obj, true + } + } + return nil, false +} + +func registerBlockHeaderHandle(obj *coin.BlockHeader) C.BlockHeader__Handle { + return (C.BlockHeader__Handle)(registerHandle(obj)) +} + +func lookupBlockHeaderHandle(handle C.BlockHeader__Handle) (*coin.BlockHeader, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*coin.BlockHeader); isOK { + return obj, true + } + } + return nil, false +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_handle_helper.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_handle_helper.go new file mode 100644 index 000000000..8bb40e971 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_handle_helper.go @@ -0,0 +1,383 @@ +package main + +/* + + #include + #include + + + #include "skytypes.h" +*/ +import "C" + +import ( + "encoding/json" + "path/filepath" + "sort" + "unsafe" + + api "github.com/skycoin/skycoin/src/api" + "github.com/skycoin/skycoin/src/daemon" + "github.com/skycoin/skycoin/src/readable" +) + +//export SKY_JsonEncode_Handle +func SKY_JsonEncode_Handle(handle C.Handle, json_string *C.GoString_) uint32 { + obj, ok := lookupHandle(handle) + if ok { + jsonBytes, err := json.Marshal(obj) + if err == nil { + copyString(string(jsonBytes), json_string) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Progress_GetCurrent +func SKY_Handle_Progress_GetCurrent(handle C.Handle, current *uint64) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*daemon.BlockchainProgress); isOK { + *current = obj.Current + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Block_GetHeadSeq +func SKY_Handle_Block_GetHeadSeq(handle C.Handle, seq *uint64) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*readable.Block); isOK { + *seq = obj.Head.BkSeq + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Block_GetHeadHash +func SKY_Handle_Block_GetHeadHash(handle C.Handle, hash *C.GoString_) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*readable.Block); isOK { + copyString(obj.Head.Hash, hash) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Block_GetPreviousBlockHash +func SKY_Handle_Block_GetPreviousBlockHash(handle C.Handle, hash *C.GoString_) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*readable.Block); isOK { + copyString(obj.Head.PreviousHash, hash) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Blocks_GetAt +func SKY_Handle_Blocks_GetAt(handle C.Handle, + index uint64, blockHandle *C.Handle) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*readable.Blocks); isOK { + *blockHandle = registerHandle(&obj.Blocks[index]) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Blocks_GetCount +func SKY_Handle_Blocks_GetCount(handle C.Handle, + count *uint64) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*readable.Blocks); isOK { + *count = uint64(len(obj.Blocks)) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Connections_GetCount +func SKY_Handle_Connections_GetCount(handle C.Handle, + count *uint64) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*api.Connections); isOK { + *count = uint64(len(obj.Connections)) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Strings_GetCount +func SKY_Handle_Strings_GetCount(handle C.Strings__Handle, + count *uint32) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).([]string); isOK { + *count = uint32(len(obj)) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Strings_Sort +func SKY_Handle_Strings_Sort(handle C.Strings__Handle) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).([]string); isOK { + sort.Strings(obj) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_Handle_Strings_GetAt +func SKY_Handle_Strings_GetAt(handle C.Strings__Handle, + index int, + str *C.GoString_) uint32 { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).([]string); isOK { + copyString(obj[index], str) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_Client_GetWalletDir +func SKY_api_Handle_Client_GetWalletDir(handle C.Client__Handle, + walletDir *C.GoString_) uint32 { + client, ok := lookupClientHandle(handle) + if ok { + wf, err := client.WalletFolderName() + if err == nil { + copyString(wf.Address, walletDir) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_Client_GetWalletFileName +func SKY_api_Handle_Client_GetWalletFileName(handle C.WalletResponse__Handle, + walletFileName *C.GoString_) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + copyString(w.Meta.Filename, walletFileName) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_Client_GetWalletLabel +func SKY_api_Handle_Client_GetWalletLabel(handle C.WalletResponse__Handle, + walletLabel *C.GoString_) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + copyString(w.Meta.Label, walletLabel) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_Client_GetWalletFullPath +func SKY_api_Handle_Client_GetWalletFullPath( + clientHandle C.Client__Handle, + walletHandle C.WalletResponse__Handle, + fullPath *C.GoString_) uint32 { + client, ok := lookupClientHandle(clientHandle) + if ok { + wf, err := client.WalletFolderName() + if err == nil { + w, okw := lookupWalletResponseHandle(walletHandle) + if okw { + walletPath := filepath.Join(wf.Address, w.Meta.Filename) + copyString(walletPath, fullPath) + return SKY_OK + } + } + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_GetWalletMeta +func SKY_api_Handle_GetWalletMeta(handle C.Wallet__Handle, + gomap *C.GoStringMap_) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + copyToStringMap(w.Meta, gomap) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_GetWalletEntriesCount +func SKY_api_Handle_GetWalletEntriesCount(handle C.Wallet__Handle, + count *uint32) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + *count = uint32(len(w.Entries)) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_Client_GetWalletResponseEntriesCount +func SKY_api_Handle_Client_GetWalletResponseEntriesCount( + handle C.WalletResponse__Handle, + count *uint32) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + *count = uint32(len(w.Entries)) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_WalletGetEntry +func SKY_api_Handle_WalletGetEntry(handle C.Wallet__Handle, + index uint32, + address *C.cipher__Address, + pubkey *C.cipher__PubKey) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + if index < uint32(len(w.Entries)) { + *address = *(*C.cipher__Address)(unsafe.Pointer(&w.Entries[index].Address)) + *pubkey = *(*C.cipher__PubKey)(unsafe.Pointer(&w.Entries[index].Public)) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_WalletResponseGetEntry +func SKY_api_Handle_WalletResponseGetEntry(handle C.WalletResponse__Handle, + index uint32, + address *C.GoString_, + pubkey *C.GoString_) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + if index < uint32(len(w.Entries)) { + copyString(w.Entries[index].Address, address) + copyString(w.Entries[index].Public, pubkey) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_WalletResponseIsEncrypted +func SKY_api_Handle_WalletResponseIsEncrypted( + handle C.WalletResponse__Handle, + isEncrypted *bool) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + *isEncrypted = w.Meta.Encrypted + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_WalletResponseGetCryptoType +func SKY_api_Handle_WalletResponseGetCryptoType( + handle C.WalletResponse__Handle, + cryptoType *C.GoString_) uint32 { + w, ok := lookupWalletResponseHandle(handle) + if ok { + copyString(w.Meta.CryptoType, cryptoType) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_WalletsResponseGetCount +func SKY_api_Handle_WalletsResponseGetCount( + handle C.Wallets__Handle, + count *uint32) uint32 { + w, ok := lookupWalletsHandle(handle) + if ok { + *count = uint32(len(w)) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_WalletsResponseGetAt +func SKY_api_Handle_WalletsResponseGetAt( + walletsHandle C.Wallets__Handle, + index uint32, + walletHandle *C.WalletResponse__Handle) uint32 { + w, ok := lookupWalletsHandle(walletsHandle) + if ok { + if index < uint32(len(w)) { + *walletHandle = registerWalletResponseHandle(w[index]) + } + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_GetWalletFolderAddress +func SKY_api_Handle_GetWalletFolderAddress( + folderHandle C.Handle, + address *C.GoString_) uint32 { + obj, ok := lookupHandle(folderHandle) + if ok { + if obj, isOK := (obj).(*api.WalletFolder); isOK { + copyString(obj.Address, address) + return SKY_OK + } + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_GetWalletSeed +func SKY_api_Handle_GetWalletSeed(handle C.Wallet__Handle, + seed *C.GoString_) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + copyString(w.Meta["seed"], seed) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_GetWalletLastSeed +func SKY_api_Handle_GetWalletLastSeed(handle C.Wallet__Handle, + lastSeed *C.GoString_) uint32 { + w, ok := lookupWalletHandle(handle) + if ok { + copyString(w.Meta["lastSeed"], lastSeed) + return SKY_OK + } + return SKY_BAD_HANDLE +} + +//export SKY_api_Handle_GetBuildInfoData +func SKY_api_Handle_GetBuildInfoData(handle C.BuildInfo_Handle, + version *C.GoString_, commit *C.GoString_, branch *C.GoString_) uint32 { + bi, ok := lookupBuildInfoHandle(handle) + if ok { + copyString(bi.Version, version) + copyString(bi.Commit, commit) + copyString(bi.Branch, branch) + return SKY_OK + } + return SKY_BAD_HANDLE +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_map.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_map.go new file mode 100644 index 000000000..77bf5436d --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_map.go @@ -0,0 +1,52 @@ +package main + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_map_Get +func SKY_map_Get(gomap *C.GoStringMap_, key string, value *C.GoString_) (____error_code uint32) { + obj, ok := lookupHandle(C.Handle(*gomap)) + ____error_code = SKY_ERROR + if ok { + if m, isMap := (obj).(map[string]string); isMap { + result, ok := m[key] + if ok { + copyString(result, value) + ____error_code = SKY_OK + } + } + } + return +} + +//export SKY_map_HasKey +func SKY_map_HasKey(gomap *C.GoStringMap_, key string) (found bool) { + obj, ok := lookupHandle(C.Handle(*gomap)) + found = false + if ok { + if m, isMap := (obj).(map[string]string); isMap { + _, found = m[key] + } + } + return +} + +//export SKY_map_Close +func SKY_map_Close(gomap *C.GoStringMap_) (____error_code uint32) { + obj, ok := lookupHandle(C.Handle(*gomap)) + ____error_code = SKY_ERROR + if ok { + if _, isMap := (obj).(map[string]string); isMap { + closeHandle(Handle(*gomap)) + ____error_code = SKY_OK + } + } + return + +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_mem.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_mem.go new file mode 100644 index 000000000..04814402b --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_mem.go @@ -0,0 +1,131 @@ +package main + +import ( + "reflect" + "unsafe" + + "github.com/spf13/cobra" + + "github.com/skycoin/skycoin/src/cipher" + httphelper "github.com/skycoin/skycoin/src/util/http" +) + +/* + #include + + #include "skytypes.h" + + void eos(char *str, int len) { + str[len] = 0; + } + +*/ +import "C" + +const ( + SizeofRipemd160 = unsafe.Sizeof(C.cipher__Ripemd160{}) + SizeOfAddress = unsafe.Sizeof(C.cipher__Address{}) + SizeofPubKey = unsafe.Sizeof(C.cipher__PubKey{}) + SizeofSecKey = unsafe.Sizeof(C.cipher__SecKey{}) + SizeofSig = unsafe.Sizeof(C.cipher__Sig{}) + SizeofChecksum = unsafe.Sizeof(C.cipher__Checksum{}) + SizeofSendAmount = unsafe.Sizeof(C.cli__SendAmount{}) + SizeofSHA256 = unsafe.Sizeof(C.cipher__SHA256{}) + SizeofTransactionOutput = unsafe.Sizeof(C.coin__TransactionOutput{}) + SizeofTransaction = unsafe.Sizeof(C.coin__Transaction{}) + SizeofEntry = unsafe.Sizeof(C.wallet__Entry{}) + SizeofUxBalance = unsafe.Sizeof(C.wallet__UxBalance{}) +) + +/** + * Inplace memory references + */ + +func inplaceAddress(p *C.cipher__Address) *cipher.Address { + return (*cipher.Address)(unsafe.Pointer(p)) +} + +func inplaceHttpHelperAddress(p *C.httphelper__Address) *httphelper.Address { + return (*httphelper.Address)(unsafe.Pointer(p)) +} + +func inplaceCobraCommand(p interface{}) (cmd *cobra.Command, isInstance bool) { + cmd, isInstance = p.(*cobra.Command) + return +} + +/** + * Copy helpers + */ + +func copyString(src string, dest *C.GoString_) { + srcLen := len(src) + dest.p = (*C.char)(C.malloc(C.size_t(srcLen + 1))) + strAddr := (*C.GoString_)(unsafe.Pointer(&src)) + result := C.memcpy(unsafe.Pointer(dest.p), unsafe.Pointer(strAddr.p), C.size_t(srcLen)) + if result != nil { + C.eos(dest.p, C.int(srcLen)) + dest.n = C.GoInt_(srcLen) + } +} + +// Determine the memory address of a slice buffer and the +// size of its underlaying element type +func getBufferData(src reflect.Value) (bufferAddr unsafe.Pointer, elemSize C.size_t) { + firstElem := src.Index(0) + elemSize = C.size_t(firstElem.Type().Size()) + bufferAddr = unsafe.Pointer(src.Pointer()) + return +} + +// Copy n items in source slice/array/string onto C-managed memory buffer +// +// This function takes for granted that all values in src +// will be instances of the same type, and that src and dest +// element types will be aligned exactly the same +// in memory of the same size +func copyToBuffer(src reflect.Value, dest unsafe.Pointer, n uint) { + srcLen := src.Len() + if srcLen == 0 { + return + } + srcAddr, elemSize := getBufferData(src) + if C.memcpy(dest, srcAddr, C.size_t(n)*elemSize) != nil { + } +} + +// Copy source slice/array/string onto instance of C.GSlice struct +// +// This function takes for granted that all values in src +// will be instances of the same type, and that src and dest +// element types will be aligned exactly the same +// in memory of the same size +func copyToGoSlice(src reflect.Value, dest *C.GoSlice_) { + srcLen := src.Len() + if srcLen == 0 { + dest.len = 0 + return + } + srcAddr, elemSize := getBufferData(src) + if dest.cap == 0 { + dest.data = C.malloc(C.size_t(srcLen) * elemSize) + dest.cap = C.GoInt_(srcLen) + } + n, overflow := srcLen, srcLen > int(dest.cap) + if overflow { + n = int(dest.cap) + } + result := C.memcpy(dest.data, srcAddr, C.size_t(n)*elemSize) + if result != nil { + // Do not modify slice metadata until memory is actually copied + if overflow { + dest.len = dest.cap - C.GoInt_(srcLen) + } else { + dest.len = C.GoInt_(srcLen) + } + } +} + +func copyToStringMap(gomap map[string]string, dest *C.GoStringMap_) { + *dest = (C.GoStringMap_)(registerHandle(gomap)) +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_time.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_time.go new file mode 100644 index 000000000..256dd4e76 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_time.go @@ -0,0 +1,14 @@ +package main + +import ( + "log" + "time" +) + +func parseTimeValue(strTime string) (time.Time, error) { + t, err := time.Parse(time.RFC3339, strTime) + if err != nil { + log.Printf("Time conversion error. Format=%s Value=\"%s\" Error: %s", time.RFC3339, strTime, err) + } + return t, err +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_types.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_types.go new file mode 100644 index 000000000..20c43f143 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/libsky_types.go @@ -0,0 +1,23 @@ +package main + +import ( + cipher "github.com/skycoin/skycoin/src/cipher" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +func toAddresserArray(addrs []cipher.Address) []cipher.Addresser { + // TODO : Support for arrays of interface objects in cgogen + var __addrs = make([]cipher.Addresser, len(addrs)) + for _, addr := range addrs { + __addrs = append(__addrs, addr) + } + return __addrs +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/main.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/main.go new file mode 100644 index 000000000..62aa2735f --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/main.go @@ -0,0 +1,9 @@ +/* +libskycoin shim +*/ +package main + +// #cgo CFLAGS: -I../../include +import "C" + +func main() {} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/params.distribution.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/params.distribution.go new file mode 100644 index 000000000..90ef24c09 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/params.distribution.go @@ -0,0 +1,34 @@ +package main + +import ( + "reflect" + + params "github.com/skycoin/skycoin/src/params" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_params_GetDistributionAddresses +func SKY_params_GetDistributionAddresses(_arg0 *C.GoSlice_) { + __arg0 := params.GetDistributionAddresses() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) +} + +//export SKY_params_GetUnlockedDistributionAddresses +func SKY_params_GetUnlockedDistributionAddresses(_arg0 *C.GoSlice_) { + __arg0 := params.GetUnlockedDistributionAddresses() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) +} + +//export SKY_params_GetLockedDistributionAddresses +func SKY_params_GetLockedDistributionAddresses(_arg0 *C.GoSlice_) { + __arg0 := params.GetLockedDistributionAddresses() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/params.droplet.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/params.droplet.go new file mode 100644 index 000000000..3c66bfdd3 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/params.droplet.go @@ -0,0 +1,24 @@ +package main + +import ( + params "github.com/skycoin/skycoin/src/params" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_params_DropletPrecisionToDivisor +func SKY_params_DropletPrecisionToDivisor(precision uint8) uint64 { + return params.DropletPrecisionToDivisor(precision) +} + +//export SKY_params_DropletPrecisionCheck +func SKY_params_DropletPrecisionCheck(precision uint8, amount uint64) uint32 { + return libErrorCode(params.DropletPrecisionCheck(precision, amount)) +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/testutil.testutil.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/testutil.testutil.go new file mode 100644 index 000000000..ce8776849 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/testutil.testutil.go @@ -0,0 +1,23 @@ +package main + +import ( + "unsafe" + + testutil "github.com/skycoin/skycoin/src/testutil" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_testutil_MakeAddress +func SKY_testutil_MakeAddress(_arg0 *C.cipher__Address) (____error_code uint32) { + __arg0 := testutil.MakeAddress() + *_arg0 = *(*C.cipher__Address)(unsafe.Pointer(&__arg0)) + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/util.apputil.apputil.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.apputil.apputil.go new file mode 100644 index 000000000..4897d52da --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.apputil.apputil.go @@ -0,0 +1,30 @@ +package main + +import apputil "github.com/skycoin/skycoin/src/util/apputil" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_apputil_CatchInterruptPanic +func SKY_apputil_CatchInterruptPanic() (____error_code uint32) { + apputil.CatchInterruptPanic() + return +} + +//export SKY_apputil_CatchDebug +func SKY_apputil_CatchDebug() (____error_code uint32) { + apputil.CatchDebug() + return +} + +//export SKY_apputil_PrintProgramStatus +func SKY_apputil_PrintProgramStatus() (____error_code uint32) { + apputil.PrintProgramStatus() + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/util.cert.cert.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.cert.cert.go new file mode 100644 index 000000000..23943a2f5 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.cert.cert.go @@ -0,0 +1,30 @@ +package main + +import ( + "reflect" + + cert "github.com/skycoin/skycoin/src/util/certutil" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_certutil_NewTLSCertPair +func SKY_certutil_NewTLSCertPair(organization string, validUntil string, extraHosts []string, _cert *C.GoSlice_, _key *C.GoSlice_) (____error_code uint32) { + ____time_validUntil, ____return_err := parseTimeValue(validUntil) + if ____return_err == nil { + cert, key, ____return_err := cert.NewTLSCertPair(organization, ____time_validUntil, extraHosts) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(cert), _cert) + copyToGoSlice(reflect.ValueOf(key), _key) + } + } + ____error_code = libErrorCode(____return_err) + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/util.droplet.droplet.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.droplet.droplet.go new file mode 100644 index 000000000..4693a8453 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.droplet.droplet.go @@ -0,0 +1,34 @@ +package main + +import droplet "github.com/skycoin/skycoin/src/util/droplet" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_droplet_FromString +func SKY_droplet_FromString(_b string, _arg1 *uint64) (____error_code uint32) { + b := _b + __arg1, ____return_err := droplet.FromString(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export SKY_droplet_ToString +func SKY_droplet_ToString(_n uint64, _arg1 *C.GoString_) (____error_code uint32) { + n := _n + __arg1, ____return_err := droplet.ToString(n) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/util.fee.fee.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.fee.fee.go new file mode 100644 index 000000000..585e544a9 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.fee.fee.go @@ -0,0 +1,74 @@ +package main + +import ( + "unsafe" + + coin "github.com/skycoin/skycoin/src/coin" + fee "github.com/skycoin/skycoin/src/util/fee" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_fee_VerifyTransactionFee +func SKY_fee_VerifyTransactionFee(_t C.Transaction__Handle, _fee uint64, _burnFactor uint32) (____error_code uint32) { + t, ok := lookupTransactionHandle(_t) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + ____return_err := fee.VerifyTransactionFee(t, _fee, _burnFactor) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_fee_VerifyTransactionFeeForHours +func SKY_fee_VerifyTransactionFeeForHours(_hours, _fee uint64, _burnFactor uint32) (____error_code uint32) { + hours := _hours + ____return_err := fee.VerifyTransactionFeeForHours(hours, _fee, _burnFactor) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_fee_RequiredFee +func SKY_fee_RequiredFee(_hours uint64, _burnFactor uint32, _arg1 *uint64) (____error_code uint32) { + hours := _hours + __arg1 := fee.RequiredFee(hours, _burnFactor) + *_arg1 = __arg1 + return +} + +//export SKY_fee_RemainingHours +func SKY_fee_RemainingHours(_hours uint64, _burnFactor uint32, _arg1 *uint64) (____error_code uint32) { + hours := _hours + __arg1 := fee.RemainingHours(hours, _burnFactor) + *_arg1 = __arg1 + return +} + +//export SKY_fee_TransactionFee +func SKY_fee_TransactionFee(_tx C.Transaction__Handle, _headTime uint64, _inUxs *C.coin__UxArray, _arg3 *uint64) (____error_code uint32) { + tx, ok := lookupTransactionHandle(_tx) + if !ok { + ____error_code = SKY_BAD_HANDLE + return + } + headTime := _headTime + inUxs := *(*coin.UxArray)(unsafe.Pointer(_inUxs)) + __arg3, ____return_err := fee.TransactionFee(tx, headTime, inUxs) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg3 = __arg3 + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/util.file.file.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.file.file.go new file mode 100644 index 000000000..5b7d6c295 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.file.file.go @@ -0,0 +1,51 @@ +package main + +import file "github.com/skycoin/skycoin/src/util/file" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_file_InitDataDir +func SKY_file_InitDataDir(_dir string, _arg1 *C.GoString_) (____error_code uint32) { + dir := _dir + __arg1, ____return_err := file.InitDataDir(dir) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + } + return +} + +//export SKY_file_UserHome +func SKY_file_UserHome(_arg0 *C.GoString_) (____error_code uint32) { + __arg0 := file.UserHome() + copyString(__arg0, _arg0) + return +} + +//export SKY_file_ResolveResourceDirectory +func SKY_file_ResolveResourceDirectory(_path string, _arg1 *C.GoString_) (____error_code uint32) { + path := _path + __arg1 := file.ResolveResourceDirectory(path) + copyString(__arg1, _arg1) + return +} + +//export SKY_file_DetermineResourcePath +func SKY_file_DetermineResourcePath(_staticDir string, _resourceDir string, _devDir string, _arg3 *C.GoString_) (____error_code uint32) { + staticDir := _staticDir + resourceDir := _resourceDir + devDir := _devDir + __arg3, ____return_err := file.DetermineResourcePath(staticDir, resourceDir, devDir) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg3, _arg3) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/util.http.json.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.http.json.go new file mode 100644 index 000000000..d311d1965 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.http.json.go @@ -0,0 +1,99 @@ +package main + +import ( + "reflect" + "unsafe" + + http "github.com/skycoin/skycoin/src/util/http" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_httphelper_Address_UnmarshalJSON +func SKY_httphelper_Address_UnmarshalJSON(_a *C.httphelper__Address, _b []byte) (____error_code uint32) { + a := inplaceHttpHelperAddress(_a) + b := *(*[]byte)(unsafe.Pointer(&_b)) + ____return_err := a.UnmarshalJSON(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_httphelper_Address_MarshalJSON +func SKY_httphelper_Address_MarshalJSON(_a *C.httphelper__Address, _arg0 *C.GoSlice_) (____error_code uint32) { + a := *inplaceHttpHelperAddress(_a) + __arg0, ____return_err := a.MarshalJSON() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_httphelper_Coins_UnmarshalJSON +func SKY_httphelper_Coins_UnmarshalJSON(_c *C.httphelper__Coins, _b []byte) (____error_code uint32) { + c := (*http.Coins)(unsafe.Pointer(_c)) + b := *(*[]byte)(unsafe.Pointer(&_b)) + ____return_err := c.UnmarshalJSON(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_httphelper_Coins_MarshalJSON +func SKY_httphelper_Coins_MarshalJSON(_c *C.httphelper__Coins, _arg0 *C.GoSlice_) (____error_code uint32) { + c := *(*http.Coins)(unsafe.Pointer(_c)) + __arg0, ____return_err := c.MarshalJSON() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_httphelper_Coins_Value +func SKY_httphelper_Coins_Value(_c *C.httphelper__Coins, _arg0 *uint64) (____error_code uint32) { + c := *(*http.Coins)(unsafe.Pointer(_c)) + __arg0 := c.Value() + *_arg0 = __arg0 + return +} + +//export SKY_httphelper_Hours_UnmarshalJSON +func SKY_httphelper_Hours_UnmarshalJSON(_h *C.httphelper__Hours, _b []byte) (____error_code uint32) { + h := (*http.Hours)(unsafe.Pointer(_h)) + b := *(*[]byte)(unsafe.Pointer(&_b)) + ____return_err := h.UnmarshalJSON(b) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_httphelper_Hours_MarshalJSON +func SKY_httphelper_Hours_MarshalJSON(_h *C.httphelper__Hours, _arg0 *C.GoSlice_) (____error_code uint32) { + h := *(*http.Hours)(unsafe.Pointer(_h)) + __arg0, ____return_err := h.MarshalJSON() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + } + return +} + +//export SKY_httphelper_Hours_Value +func SKY_httphelper_Hours_Value(_h *C.httphelper__Hours, _arg0 *uint64) (____error_code uint32) { + h := *(*http.Hours)(unsafe.Pointer(_h)) + __arg0 := h.Value() + *_arg0 = __arg0 + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/util.iputil.iputil.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.iputil.iputil.go new file mode 100644 index 000000000..f3906de38 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.iputil.iputil.go @@ -0,0 +1,42 @@ +package main + +import iputil "github.com/skycoin/skycoin/src/util/iputil" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_iputil_LocalhostIP +func SKY_iputil_LocalhostIP(_arg0 *C.GoString_) (____error_code uint32) { + __arg0, ____return_err := iputil.LocalhostIP() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg0, _arg0) + } + return +} + +//export SKY_iputil_IsLocalhost +func SKY_iputil_IsLocalhost(_addr string, _arg1 *bool) (____error_code uint32) { + addr := _addr + __arg1 := iputil.IsLocalhost(addr) + *_arg1 = __arg1 + return +} + +//export SKY_iputil_SplitAddr +func SKY_iputil_SplitAddr(_addr string, _arg1 *C.GoString_, _arg2 *uint16) (____error_code uint32) { + addr := _addr + __arg1, __arg2, ____return_err := iputil.SplitAddr(addr) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(__arg1, _arg1) + *_arg2 = __arg2 + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/util.logging.logging.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.logging.logging.go new file mode 100644 index 000000000..b544364d6 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/util.logging.logging.go @@ -0,0 +1,30 @@ +package main + +import logging "github.com/skycoin/skycoin/src/util/logging" + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_logging_EnableColors +func SKY_logging_EnableColors() (____error_code uint32) { + logging.EnableColors() + return +} + +//export SKY_logging_DisableColors +func SKY_logging_DisableColors() (____error_code uint32) { + logging.DisableColors() + return +} + +//export SKY_logging_Disable +func SKY_logging_Disable() (____error_code uint32) { + logging.Disable() + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.balance.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.balance.go new file mode 100644 index 000000000..c491ab412 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.balance.go @@ -0,0 +1,76 @@ +package main + +import ( + "unsafe" + + coin "github.com/skycoin/skycoin/src/coin" + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_NewBalance +func SKY_wallet_NewBalance(_coins, _hours uint64, _arg1 *C.wallet__Balance) (____error_code uint32) { + coins := _coins + hours := _hours + __arg1 := wallet.NewBalance(coins, hours) + *_arg1 = *(*C.wallet__Balance)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_wallet_NewBalanceFromUxOut +func SKY_wallet_NewBalanceFromUxOut(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wallet__Balance) (____error_code uint32) { + headTime := _headTime + ux := (*coin.UxOut)(unsafe.Pointer(_ux)) + __arg2, ____return_err := wallet.NewBalanceFromUxOut(headTime, ux) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.wallet__Balance)(unsafe.Pointer(&__arg2)) + } + return +} + +//export SKY_wallet_Balance_Add +func SKY_wallet_Balance_Add(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *C.wallet__Balance) (____error_code uint32) { + bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) + other := *(*wallet.Balance)(unsafe.Pointer(_other)) + __arg1, ____return_err := bal.Add(other) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = *(*C.wallet__Balance)(unsafe.Pointer(&__arg1)) + } + return +} + +//export SKY_wallet_Balance_Sub +func SKY_wallet_Balance_Sub(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *C.wallet__Balance) (____error_code uint32) { + bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) + other := *(*wallet.Balance)(unsafe.Pointer(_other)) + __arg1 := bal.Sub(other) + *_arg1 = *(*C.wallet__Balance)(unsafe.Pointer(&__arg1)) + return +} + +//export SKY_wallet_Balance_Equals +func SKY_wallet_Balance_Equals(_bal *C.wallet__Balance, _other *C.wallet__Balance, _arg1 *bool) (____error_code uint32) { + bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) + other := *(*wallet.Balance)(unsafe.Pointer(_other)) + __arg1 := bal.Equals(other) + *_arg1 = __arg1 + return +} + +//export SKY_wallet_Balance_IsZero +func SKY_wallet_Balance_IsZero(_bal *C.wallet__Balance, _arg0 *bool) (____error_code uint32) { + bal := *(*wallet.Balance)(unsafe.Pointer(_bal)) + __arg0 := bal.IsZero() + *_arg0 = __arg0 + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.crypto.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.crypto.go new file mode 100644 index 000000000..86a9bc146 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.crypto.go @@ -0,0 +1,25 @@ +package main + +import ( + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_CryptoTypeFromString +func SKY_wallet_CryptoTypeFromString(_s string, _arg1 *C.GoString_) (____error_code uint32) { + s := _s + __arg1, ____return_err := wallet.CryptoTypeFromString(s) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyString(string(__arg1), _arg1) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.entry.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.entry.go new file mode 100644 index 000000000..2d7c7807e --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.entry.go @@ -0,0 +1,36 @@ +package main + +import ( + "unsafe" + + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_Entry_Verify +func SKY_wallet_Entry_Verify(_we *C.wallet__Entry) (____error_code uint32) { + we := (*wallet.Entry)(unsafe.Pointer(_we)) + ____return_err := we.Verify() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_Entry_VerifyPublic +func SKY_wallet_Entry_VerifyPublic(_we *C.wallet__Entry) (____error_code uint32) { + we := (*wallet.Entry)(unsafe.Pointer(_we)) + ____return_err := we.VerifyPublic() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.readable.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.readable.go new file mode 100644 index 000000000..0747bda66 --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.readable.go @@ -0,0 +1,77 @@ +package main + +import ( + "unsafe" + + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_NewReadableEntry +func SKY_wallet_NewReadableEntry(_coinType string, _w *C.wallet__Entry, _arg1 *C.ReadableEntry__Handle) (____error_code uint32) { + coinType := wallet.CoinType(_coinType) + w := *(*wallet.Entry)(unsafe.Pointer(_w)) + __arg1 := wallet.NewReadableEntry(coinType, w) + *_arg1 = registerReadableEntryHandle(&__arg1) + return +} + +//export SKY_wallet_LoadReadableWallet +func SKY_wallet_LoadReadableWallet(_filename string, _arg1 *C.ReadableWallet__Handle) (____error_code uint32) { + filename := _filename + __arg1, ____return_err := wallet.LoadReadableWallet(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerReadableWalletHandle(__arg1) + } + return +} + +//export SKY_wallet_ReadableWallet_Save +func SKY_wallet_ReadableWallet_Save(_rw C.ReadableWallet__Handle, _filename string) (____error_code uint32) { + rw, okrw := lookupReadableWalletHandle(_rw) + if !okrw { + ____error_code = SKY_BAD_HANDLE + return + } + filename := _filename + ____return_err := rw.Save(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_ReadableWallet_Load +func SKY_wallet_ReadableWallet_Load(_rw C.ReadableWallet__Handle, _filename string) (____error_code uint32) { + rw, okrw := lookupReadableWalletHandle(_rw) + if !okrw { + ____error_code = SKY_BAD_HANDLE + return + } + filename := _filename + ____return_err := rw.Load(filename) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_ReadableWallet_Erase +func SKY_wallet_ReadableWallet_Erase(_rw C.ReadableWallet__Handle) (____error_code uint32) { + rw, okrw := lookupReadableWalletHandle(_rw) + if !okrw { + ____error_code = SKY_BAD_HANDLE + return + } + rw.Erase() + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.wallet.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.wallet.go new file mode 100644 index 000000000..a69afb20d --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet.wallet.go @@ -0,0 +1,308 @@ +package main + +import ( + "reflect" + "unsafe" + + cipher "github.com/skycoin/skycoin/src/cipher" + coin "github.com/skycoin/skycoin/src/coin" + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_NewError +func SKY_wallet_NewError(_err error) (____error_code uint32) { + err := _err + ____return_err := wallet.NewError(err) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_NewWallet +func SKY_wallet_NewWallet(_wltName string, _opts C.Options__Handle, _arg2 *C.Wallet__Handle) (____error_code uint32) { + __opts, okopts := lookupOptionsHandle(_opts) + if !okopts { + ____error_code = SKY_BAD_HANDLE + return + } + opts := *__opts + __arg2, ____return_err := wallet.NewWallet(_wltName, opts) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = registerWalletHandle(__arg2) + } + return +} + +//export SKY_wallet_Wallet_Lock +func SKY_wallet_Wallet_Lock(_w C.Wallet__Handle, _password []byte, _cryptoType string) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + password := *(*[]byte)(unsafe.Pointer(&_password)) + cryptoType := wallet.CryptoType(_cryptoType) + ____return_err := w.Lock(password, cryptoType) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_Wallet_Unlock +func SKY_wallet_Wallet_Unlock(_w C.Wallet__Handle, _password []byte, _arg1 *C.Wallet__Handle) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + password := *(*[]byte)(unsafe.Pointer(&_password)) + __arg1, ____return_err := w.Unlock(password) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerWalletHandle(__arg1) + } + return +} + +//export SKY_wallet_Load +func SKY_wallet_Load(_wltFile string, _arg1 *C.Wallet__Handle) (____error_code uint32) { + wltFile := _wltFile + __arg1, ____return_err := wallet.Load(wltFile) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = registerWalletHandle(__arg1) + } + return +} + +//export SKY_wallet_Wallet_Save +func SKY_wallet_Wallet_Save(_w C.Wallet__Handle, _dir string) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + dir := _dir + ____return_err := w.Save(dir) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_Wallet_Validate +func SKY_wallet_Wallet_Validate(_w C.Wallet__Handle) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + ____return_err := w.Validate() + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_Wallet_Type +func SKY_wallet_Wallet_Type(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := w.Type() + copyString(__arg0, _arg0) + return +} + +//export SKY_wallet_Wallet_Version +func SKY_wallet_Wallet_Version(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := w.Version() + copyString(__arg0, _arg0) + return +} + +//export SKY_wallet_Wallet_Filename +func SKY_wallet_Wallet_Filename(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := w.Filename() + copyString(__arg0, _arg0) + return +} + +//export SKY_wallet_Wallet_Label +func SKY_wallet_Wallet_Label(_w C.Wallet__Handle, _arg0 *C.GoString_) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := w.Label() + copyString(__arg0, _arg0) + return +} + +//export SKY_wallet_Wallet_IsEncrypted +func SKY_wallet_Wallet_IsEncrypted(_w C.Wallet__Handle, _arg0 *bool) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := w.IsEncrypted() + *_arg0 = __arg0 + return +} + +//export SKY_wallet_Wallet_GenerateAddresses +func SKY_wallet_Wallet_GenerateAddresses(_w C.Wallet__Handle, _num uint64, _arg1 *C.GoSlice_) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + num := _num + __arg1, ____return_err := w.GenerateAddresses(num) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg1), _arg1) + } + return +} + +//export SKY_wallet_Wallet_GetAddresses +func SKY_wallet_Wallet_GetAddresses(_w C.Wallet__Handle, _arg0 *C.GoSlice_) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + __arg0 := w.GetAddresses() + copyToGoSlice(reflect.ValueOf(__arg0), _arg0) + return +} + +//export SKY_wallet_Wallet_GetEntry +func SKY_wallet_Wallet_GetEntry(_w C.Wallet__Handle, _a *C.cipher__Address, _arg1 *C.wallet__Entry, _arg2 *bool) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + a := *(*cipher.Address)(unsafe.Pointer(_a)) + __arg1, __arg2 := w.GetEntry(a) + *_arg1 = *(*C.wallet__Entry)(unsafe.Pointer(&__arg1)) + *_arg2 = __arg2 + return +} + +//export SKY_wallet_Wallet_AddEntry +func SKY_wallet_Wallet_AddEntry(_w C.Wallet__Handle, _entry *C.wallet__Entry) (____error_code uint32) { + w, okw := lookupWalletHandle(_w) + if !okw { + ____error_code = SKY_BAD_HANDLE + return + } + entry := *(*wallet.Entry)(unsafe.Pointer(_entry)) + ____return_err := w.AddEntry(entry) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + } + return +} + +//export SKY_wallet_DistributeSpendHours +func SKY_wallet_DistributeSpendHours(_inputHours, _nAddrs uint64, _haveChange bool, _arg2 *uint64, _arg3 *C.GoSlice_, _arg4 *uint64) (____error_code uint32) { + inputHours := _inputHours + nAddrs := _nAddrs + haveChange := _haveChange + __arg2, __arg3, __arg4 := wallet.DistributeSpendHours(inputHours, nAddrs, haveChange) + *_arg2 = __arg2 + copyToGoSlice(reflect.ValueOf(__arg3), _arg3) + *_arg4 = __arg4 + return +} + +//export SKY_wallet_DistributeCoinHoursProportional +func SKY_wallet_DistributeCoinHoursProportional(_coins []uint64, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { + coins := *(*[]uint64)(unsafe.Pointer(&_coins)) + hours := _hours + __arg2, ____return_err := wallet.DistributeCoinHoursProportional(coins, hours) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + } + return +} + +//export SKY_wallet_NewUxBalances +func SKY_wallet_NewUxBalances(_headTime uint64, _uxa *C.coin__UxArray, _arg2 *C.GoSlice_) (____error_code uint32) { + headTime := _headTime + uxa := *(*coin.UxArray)(unsafe.Pointer(_uxa)) + __arg2, ____return_err := wallet.NewUxBalances(headTime, uxa) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + } + return +} + +//export SKY_wallet_NewUxBalance +func SKY_wallet_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.wallet__UxBalance) (____error_code uint32) { + headTime := _headTime + ux := *(*coin.UxOut)(unsafe.Pointer(_ux)) + __arg2, ____return_err := wallet.NewUxBalance(headTime, ux) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg2 = *(*C.wallet__UxBalance)(unsafe.Pointer(&__arg2)) + } + return +} + +//export SKY_wallet_ChooseSpendsMinimizeUxOuts +func SKY_wallet_ChooseSpendsMinimizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { + uxa := *(*[]wallet.UxBalance)(unsafe.Pointer(&_uxa)) + coins := _coins + hours := _hours + __arg2, ____return_err := wallet.ChooseSpendsMinimizeUxOuts(uxa, coins, hours) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + } + return +} + +//export SKY_wallet_ChooseSpendsMaximizeUxOuts +func SKY_wallet_ChooseSpendsMaximizeUxOuts(_uxa []C.wallet__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) { + uxa := *(*[]wallet.UxBalance)(unsafe.Pointer(&_uxa)) + coins := _coins + hours := _hours + __arg2, ____return_err := wallet.ChooseSpendsMaximizeUxOuts(uxa, coins, hours) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + copyToGoSlice(reflect.ValueOf(__arg2), _arg2) + } + return +} diff --git a/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet_option.go b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet_option.go new file mode 100644 index 000000000..e38ab73df --- /dev/null +++ b/vendor/github.com/skycoin/libskycoin/lib/cgo/wallet_option.go @@ -0,0 +1,27 @@ +package main + +import ( + wallet "github.com/skycoin/skycoin/src/wallet" +) + +/* + #include + #include + + #include "skytypes.h" +*/ +import "C" + +//export SKY_wallet_CreateOptionsHandle +func SKY_wallet_CreateOptionsHandle(coin string, label string, seed string, encrypt bool, pwd string, cryptoType string, scanN uint64, _opts *C.Options__Handle) (____error_code uint32) { + var walletOptions wallet.Options + walletOptions.Coin = (wallet.CoinType)(coin) + walletOptions.Label = label + walletOptions.Seed = seed + walletOptions.Encrypt = encrypt + walletOptions.Password = []byte(pwd) + walletOptions.CryptoType = (wallet.CryptoType)(cryptoType) + walletOptions.ScanN = scanN + *_opts = registerOptionsHandle(&walletOptions) + return +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go new file mode 100644 index 000000000..bc22e9732 --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go @@ -0,0 +1,683 @@ +package cmd + +func initAgpl() { + Licenses["agpl"] = License{ + Name: "GNU Affero General Public License", + PossibleMatches: []string{"agpl", "affero gpl", "gnu agpl"}, + Header: ` +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see .`, + Text: ` GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. +`, + } +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go new file mode 100644 index 000000000..38393d541 --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go @@ -0,0 +1,238 @@ +// Copyright © 2015 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Parts inspired by https://github.com/ryanuber/go-license + +package cmd + +func initApache2() { + Licenses["apache"] = License{ + Name: "Apache 2.0", + PossibleMatches: []string{"apache", "apache20", "apache 2.0", "apache2.0", "apache-2.0"}, + Header: ` +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.`, + Text: ` + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +`, + } +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go new file mode 100644 index 000000000..4a847e04a --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go @@ -0,0 +1,71 @@ +// Copyright © 2015 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Parts inspired by https://github.com/ryanuber/go-license + +package cmd + +func initBsdClause2() { + Licenses["freebsd"] = License{ + Name: "Simplified BSD License", + PossibleMatches: []string{"freebsd", "simpbsd", "simple bsd", "2-clause bsd", + "2 clause bsd", "simplified bsd license"}, + Header: `All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE.`, + Text: `{{ .copyright }} +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +`, + } +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go new file mode 100644 index 000000000..c7476b31f --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go @@ -0,0 +1,78 @@ +// Copyright © 2015 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Parts inspired by https://github.com/ryanuber/go-license + +package cmd + +func initBsdClause3() { + Licenses["bsd"] = License{ + Name: "NewBSD", + PossibleMatches: []string{"bsd", "newbsd", "3 clause bsd", "3-clause bsd"}, + Header: `All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE.`, + Text: `{{ .copyright }} +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +`, + } +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go new file mode 100644 index 000000000..03e05b3a7 --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go @@ -0,0 +1,376 @@ +// Copyright © 2015 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Parts inspired by https://github.com/ryanuber/go-license + +package cmd + +func initGpl2() { + Licenses["gpl2"] = License{ + Name: "GNU General Public License 2.0", + PossibleMatches: []string{"gpl2", "gnu gpl2", "gplv2"}, + Header: ` +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see .`, + Text: ` GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type 'show c' for details. + +The hypothetical commands 'show w' and 'show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than 'show w' and 'show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + 'Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. +`, + } +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go new file mode 100644 index 000000000..ce07679c7 --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go @@ -0,0 +1,711 @@ +// Copyright © 2015 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Parts inspired by https://github.com/ryanuber/go-license + +package cmd + +func initGpl3() { + Licenses["gpl3"] = License{ + Name: "GNU General Public License 3.0", + PossibleMatches: []string{"gpl3", "gplv3", "gpl", "gnu gpl3", "gnu gpl"}, + Header: ` +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see .`, + Text: ` GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type 'show c' for details. + +The hypothetical commands 'show w' and 'show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. +`, + } +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go new file mode 100644 index 000000000..0f8b96cad --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go @@ -0,0 +1,186 @@ +package cmd + +func initLgpl() { + Licenses["lgpl"] = License{ + Name: "GNU Lesser General Public License", + PossibleMatches: []string{"lgpl", "lesser gpl", "gnu lgpl"}, + Header: ` +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see .`, + Text: ` GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library.`, + } +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go new file mode 100644 index 000000000..bd2d0c4fa --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go @@ -0,0 +1,63 @@ +// Copyright © 2015 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Parts inspired by https://github.com/ryanuber/go-license + +package cmd + +func initMit() { + Licenses["mit"] = License{ + Name: "MIT License", + PossibleMatches: []string{"mit"}, + Header: ` +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.`, + Text: `The MIT License (MIT) + +{{ .copyright }} + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +`, + } +} diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go new file mode 100644 index 000000000..a070134dd --- /dev/null +++ b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go @@ -0,0 +1,118 @@ +// Copyright © 2015 Steve Francia . +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Parts inspired by https://github.com/ryanuber/go-license + +package cmd + +import ( + "strings" + "time" + + "github.com/spf13/viper" +) + +// Licenses contains all possible licenses a user can choose from. +var Licenses = make(map[string]License) + +// License represents a software license agreement, containing the Name of +// the license, its possible matches (on the command line as given to cobra), +// the header to be used with each file on the file's creating, and the text +// of the license +type License struct { + Name string // The type of license in use + PossibleMatches []string // Similar names to guess + Text string // License text data + Header string // License header for source files +} + +func init() { + // Allows a user to not use a license. + Licenses["none"] = License{"None", []string{"none", "false"}, "", ""} + + initApache2() + initMit() + initBsdClause3() + initBsdClause2() + initGpl2() + initGpl3() + initLgpl() + initAgpl() +} + +// getLicense returns license specified by user in flag or in config. +// If user didn't specify the license, it returns Apache License 2.0. +// +// TODO: Inspect project for existing license +func getLicense() License { + // If explicitly flagged, use that. + if userLicense != "" { + return findLicense(userLicense) + } + + // If user wants to have custom license, use that. + if viper.IsSet("license.header") || viper.IsSet("license.text") { + return License{Header: viper.GetString("license.header"), + Text: viper.GetString("license.text")} + } + + // If user wants to have built-in license, use that. + if viper.IsSet("license") { + return findLicense(viper.GetString("license")) + } + + // If user didn't set any license, use Apache 2.0 by default. + return Licenses["apache"] +} + +func copyrightLine() string { + author := viper.GetString("author") + + year := viper.GetString("year") // For tests. + if year == "" { + year = time.Now().Format("2006") + } + + return "Copyright © " + year + " " + author +} + +// findLicense looks for License object of built-in licenses. +// If it didn't find license, then the app will be terminated and +// error will be printed. +func findLicense(name string) License { + found := matchLicense(name) + if found == "" { + er("unknown license: " + name) + } + return Licenses[found] +} + +// matchLicense compares the given a license name +// to PossibleMatches of all built-in licenses. +// It returns blank string, if name is blank string or it didn't find +// then appropriate match to name. +func matchLicense(name string) string { + if name == "" { + return "" + } + + for key, lic := range Licenses { + for _, match := range lic.PossibleMatches { + if strings.EqualFold(name, match) { + return key + } + } + } + + return "" +} diff --git a/vendor/vendor.json b/vendor/vendor.json index abb3e601a..9376258a2 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -294,4 +294,4 @@ } ], "rootPath": "github.com/fibercrypto/libskycoin" -} +} \ No newline at end of file