From df5cd4d4a8370d7cacd19caa7de13f42321d1e9f Mon Sep 17 00:00:00 2001 From: "alexey.stratulat" <alexey.stratulat@demlabs.net> Date: Fri, 13 Dec 2019 18:05:04 +0700 Subject: [PATCH] [+] Added wrapping functions dap_chain_addr_fill and dap_chain_addr_check_sum --- include/wrapping_dap_chain_common.h | 5 +++++ src/wrapping_dap_chain_common.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/wrapping_dap_chain_common.h b/include/wrapping_dap_chain_common.h index 7feec9c3..d73dede9 100644 --- a/include/wrapping_dap_chain_common.h +++ b/include/wrapping_dap_chain_common.h @@ -2,6 +2,7 @@ #define _WRAPPING_DAP_CHAIN_COMMON_ #include <Python.h> #include "dap_chain_common.h" +#include "libdap_crypto_key_python.h" #ifdef __cplusplus extern "C" { @@ -73,10 +74,14 @@ typedef struct PyDapChainAddr{ PyObject *dap_chain_addr_to_str_py(PyObject *self, PyObject *args); PyObject *dap_chain_addr_from_str_py(PyObject *self, PyObject *args); +PyObject *dap_chain_addr_fill_py(PyObject *self, PyObject *args); +PyObject *dap_chain_addr_check_sum_py(PyObject *self, PyObject *args); PyMethodDef DapChainAddrMethods[] = { {"toStr", (PyCFunction)dap_chain_addr_to_str_py, METH_VARARGS, ""}, {"fromStr", (PyCFunction)dap_chain_addr_from_str_py, METH_VARARGS | METH_STATIC, ""}, + {"fill", (PyCFunction)dap_chain_addr_fill_py, METH_VARARGS, ""}, + {"checkSum", (PyCFunction)dap_chain_addr_check_sum_py, METH_VARARGS, ""}, {NULL, NULL, 0, NULL} }; diff --git a/src/wrapping_dap_chain_common.c b/src/wrapping_dap_chain_common.c index 21cf5647..9bb16e5d 100644 --- a/src/wrapping_dap_chain_common.c +++ b/src/wrapping_dap_chain_common.c @@ -28,6 +28,19 @@ PyObject *dap_chain_addr_from_str_py(PyObject *self, PyObject *args){ return Py_BuildValue("O", obj); } +PyObject *dap_chain_addr_fill_py(PyObject *self, PyObject *args){ + PyObject *key; + PyObject *net_id; + if (!PyArg_ParseTuple(args, "O|O", &key, &net_id)) + return NULL; + dap_chain_addr_fill(((PyDapChainAddrObject*)self)->addr, ((PyCryptoKeyObject*)key)->key, &(((PyDapChainNetIdObject*)net_id)->net_id)); +} + +PyObject *dap_chain_addr_check_sum_py(PyObject *self, PyObject *args){ + int res = dap_chain_addr_check_sum(((PyDapChainAddrObject*)self)->addr); + return PyLong_FromLong(res); +} + PyObject *dap_chain_net_id_from_str_py(PyObject *self, PyObject *args){ const char *str; if (!PyArg_ParseTuple(args, "s", &str)) -- GitLab