From aac51a5fed9d0a50c45f4760e94f48b05a02ab8a Mon Sep 17 00:00:00 2001 From: "Jamie C. Driver" Date: Thu, 20 Mar 2025 14:45:59 +0000 Subject: [PATCH 1/2] treat (void*,size_t) as a buffer - improved export of 'wally_bzero() --- include/wally.hpp | 4 ++-- src/swig_java/swig.i | 1 + src/swig_python/swig.i | 1 + tools/build_wrappers.py | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/wally.hpp b/include/wally.hpp index b077d9a13..e2f7d04a8 100644 --- a/include/wally.hpp +++ b/include/wally.hpp @@ -512,8 +512,8 @@ inline int bip340_tagged_hash(const BYTES& bytes, const TAG& tag, BYTES_OUT& byt } template -inline int bzero(const BYTES& bytes, size_t bytes_len) { - int ret = ::wally_bzero(detail::get_p(bytes), bytes_len); +inline int bzero(BYTES& bytes) { + int ret = ::wally_bzero(bytes.data(), bytes.size()); return detail::check_ret(__FUNCTION__, ret); } diff --git a/src/swig_java/swig.i b/src/swig_java/swig.i index e314fddc2..ac130a78c 100644 --- a/src/swig_java/swig.i +++ b/src/swig_java/swig.i @@ -328,6 +328,7 @@ static jobjectArray create_jstringArray(JNIEnv *jenv, char **p, size_t len) { %apply(char *STRING, size_t LENGTH) { (unsigned char* s2c_opening_out, size_t s2c_opening_out_len) }; %apply(char *STRING, size_t LENGTH) { (unsigned char* scalar, size_t scalar_len) }; %apply(char *STRING, size_t LENGTH) { (unsigned char* vbf_out, size_t vbf_out_len) }; +%apply(char *STRING, size_t LENGTH) { (void* bytes, size_t bytes_len) }; %ignore bip32_key_from_base58; %ignore bip32_key_from_base58_n; %ignore bip32_key_from_parent; diff --git a/src/swig_python/swig.i b/src/swig_python/swig.i index 44fb4264c..6310dd9d6 100644 --- a/src/swig_python/swig.i +++ b/src/swig_python/swig.i @@ -395,6 +395,7 @@ static void destroy_words(PyObject *obj) { (void)obj; } %pybuffer_nullable_binary(const unsigned char* vbf, size_t vbf_len); %pybuffer_nullable_binary(const unsigned char* whitelistproof, size_t whitelistproof_len); %pybuffer_nullable_binary(const unsigned char* witness, size_t witness_len); +%pybuffer_nullable_binary(void* bytes, size_t bytes_len); %pybuffer_output_binary(unsigned char* abf_out, size_t abf_out_len); %pybuffer_output_binary(unsigned char* asset_out, size_t asset_out_len); %pybuffer_output_binary(unsigned char* bytes_out, size_t len); diff --git a/tools/build_wrappers.py b/tools/build_wrappers.py index 81277e67c..3f52d564c 100755 --- a/tools/build_wrappers.py +++ b/tools/build_wrappers.py @@ -149,7 +149,7 @@ def is_array(func, arg, n, num_args, types): def is_buffer(func, arg, n, num_args): - return is_array(func, arg, n, num_args, [u'const unsigned char*', u'unsigned char*']) + return is_array(func, arg, n, num_args, [u'const unsigned char*', u'unsigned char*', u'void*']) def is_int_buffer(func, arg, n, num_args): From 82b20f1e2629edea94ea170782608815a7909e07 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Fri, 21 Mar 2025 14:07:35 +1300 Subject: [PATCH 2/2] build: clean up forward decls --- include/wally_psbt.h | 2 -- include/wally_transaction.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/wally_psbt.h b/include/wally_psbt.h index d74d9180a..cd01d1500 100644 --- a/include/wally_psbt.h +++ b/include/wally_psbt.h @@ -61,8 +61,6 @@ extern "C" { #define WALLY_SCALAR_OFFSET_LEN 32 /* Length of a PSET scalar offset */ -struct ext_key; - #ifdef SWIG struct wally_psbt_input; struct wally_psbt_output; diff --git a/include/wally_transaction.h b/include/wally_transaction.h index 8e07e06f1..614024aca 100644 --- a/include/wally_transaction.h +++ b/include/wally_transaction.h @@ -81,6 +81,8 @@ extern "C" { struct wally_map; #ifdef SWIG +struct wally_tx_witness_item; +struct wally_tx_witness_stack; struct wally_tx_input; struct wally_tx_output; struct wally_tx;