Fix reorg issues
[electrum-server.git] / scrypt / scryptmodule.c
1 #include <Python.h>
2
3 //#include "scrypt.h"
4
5 static PyObject *scrypt_getpowhash(PyObject *self, PyObject *args)
6 {
7     char *output;
8     PyObject *value;
9     PyStringObject *input;
10     if (!PyArg_ParseTuple(args, "S", &input))
11         return NULL;
12     Py_INCREF(input);
13     output = PyMem_Malloc(32);
14
15     scrypt_1024_1_1_256((char *)PyString_AsString((PyObject*) input), output);
16     Py_DECREF(input);
17     value = Py_BuildValue("s#", output, 32);
18     PyMem_Free(output);
19     return value;
20 }
21
22 static PyMethodDef ScryptMethods[] = {
23     { "getPoWHash", scrypt_getpowhash, METH_VARARGS, "Returns the proof of work hash using scrypt" },
24     { NULL, NULL, 0, NULL }
25 };
26
27 PyMODINIT_FUNC initltc_scrypt(void) {
28     (void) Py_InitModule("ltc_scrypt", ScryptMethods);
29 }