remove external lib
This commit is contained in:
parent
719c239ac6
commit
88a39e60ec
@ -21,7 +21,9 @@ static PyObject* crypto_decode_base58(PyObject *, PyObject* args) {
|
||||
*rp = *i;
|
||||
rp++;
|
||||
}
|
||||
return Py_BuildValue("y#", r, result.size());
|
||||
PyObject *return_value = Py_BuildValue("y#", r, result.size());
|
||||
Py_DECREF(r);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static PyObject* crypto_encode_base58(PyObject *, PyObject* args) {
|
||||
@ -30,7 +32,9 @@ static PyObject* crypto_encode_base58(PyObject *, PyObject* args) {
|
||||
std::string result = EncodeBase58((const unsigned char*)buffer.buf,
|
||||
(const unsigned char*)buffer.buf + buffer.len);
|
||||
const char * c = result.c_str();
|
||||
return Py_BuildValue("s", c);
|
||||
PyObject *return_value = Py_BuildValue("s", c);
|
||||
Py_DECREF(c);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static PyObject* crypto_double_sha256(PyObject *, PyObject* args) {
|
||||
@ -40,7 +44,9 @@ static PyObject* crypto_double_sha256(PyObject *, PyObject* args) {
|
||||
CSHA256().Write((const unsigned char*)buffer.buf, buffer.len).Finalize(h);
|
||||
uint8_t h2[CSHA256::OUTPUT_SIZE];
|
||||
CSHA256().Write(h, CSHA256::OUTPUT_SIZE).Finalize(h2);
|
||||
return Py_BuildValue("y#", h2, CSHA256::OUTPUT_SIZE);
|
||||
PyObject *return_value = Py_BuildValue("y#", h2, CSHA256::OUTPUT_SIZE);
|
||||
Py_DECREF(h2);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -42,8 +42,9 @@ static PyObject *secp256k1_secp256k1_ec_pubkey_tweak_add(PyObject *self, PyObjec
|
||||
unsigned char pubkeyo[outl];
|
||||
t = secp256k1_ec_pubkey_serialize(secp256k1_context_no_precomp, pubkeyo, &outl, &data, flag);
|
||||
if (t != 1) { return Py_BuildValue("b", 0); }
|
||||
return Py_BuildValue("y#", pubkeyo, outl);
|
||||
return Py_BuildValue("b", 0);
|
||||
PyObject *return_value = Py_BuildValue("y#", pubkeyo, outl);
|
||||
Py_DECREF(pubkeyo);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
@ -79,8 +80,9 @@ static PyObject *secp256k1_secp256k1_ecdsa_add_points(PyObject *self, PyObject *
|
||||
unsigned char pubkeyo[outl];
|
||||
t = secp256k1_ec_pubkey_serialize(secp256k1_context_no_precomp, pubkeyo, &outl, &out, flag);
|
||||
if (t != 1) { return Py_BuildValue("b", 0); }
|
||||
return Py_BuildValue("y#", pubkeyo, outl);
|
||||
return Py_BuildValue("b", 0);
|
||||
PyObject *return_value = Py_BuildValue("y#", pubkeyo, outl);
|
||||
Py_DECREF(pubkeyo);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static PyObject *secp256k1_secp256k1_ecdsa_signature_serialize_der(PyObject *self, PyObject *args) {
|
||||
@ -98,8 +100,9 @@ static PyObject *secp256k1_secp256k1_ecdsa_signature_serialize_der(PyObject *sel
|
||||
&outputLen,
|
||||
&signature);
|
||||
if (t==0) { return Py_BuildValue("b", 0); }
|
||||
return Py_BuildValue("y#", &outputSer, outputLen);
|
||||
|
||||
PyObject *return_value = Py_BuildValue("y#", &outputSer, outputLen);
|
||||
Py_DECREF(outputSer);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static PyObject *secp256k1_secp256k1_nonce_rfc6979(PyObject *self, PyObject *args) {
|
||||
@ -110,7 +113,9 @@ static PyObject *secp256k1_secp256k1_nonce_rfc6979(PyObject *self, PyObject *arg
|
||||
if (!PyArg_ParseTuple(args,"y*y*b", &msg32, &key32, &counter)) { return NULL; }
|
||||
int r = secp256k1_nonce_function_rfc6979(nonce, msg32.buf, key32.buf, NULL, NULL, counter);
|
||||
if (r == 0 ) { return Py_BuildValue("b", 0); }
|
||||
return Py_BuildValue("y#", &nonce, 32);
|
||||
PyObject *return_value = Py_BuildValue("y#", &nonce, 32);
|
||||
Py_DECREF(nonce);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static PyObject *secp256k1_secp256k1_ecdsa_recover(PyObject *self, PyObject *args) {
|
||||
@ -160,7 +165,9 @@ static PyObject *secp256k1_secp256k1_ecdsa_recover(PyObject *self, PyObject *arg
|
||||
if (r != 1) {
|
||||
return Py_BuildValue("b", -3);
|
||||
}
|
||||
return Py_BuildValue("y#", pubkeyo, outl);
|
||||
PyObject *return_value = Py_BuildValue("y#", pubkeyo, outl);
|
||||
Py_DECREF(pubkeyo);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static PyObject *secp256k1_secp256k1_ecdsa_verify(PyObject *self, PyObject *args) {
|
||||
@ -209,8 +216,9 @@ static PyObject *secp256k1_secp256k1_context_randomize(PyObject *self, PyObject
|
||||
int r = 0;
|
||||
r += secp256k1_context_randomize(secp256k1_precomp_context_sign, buffer.buf);
|
||||
r += secp256k1_context_randomize(secp256k1_precomp_context_sign, buffer.buf);
|
||||
if (r == 2) { r = 1; } else { r = 0; }
|
||||
return Py_BuildValue("b", r);
|
||||
if (r == 2) { return Py_BuildValue("b", 1); }
|
||||
else { return Py_BuildValue("b", 0); }
|
||||
|
||||
}
|
||||
|
||||
static PyObject *secp256k1_secp256k1_ec_pubkey_create(PyObject *self, PyObject *args) {
|
||||
@ -239,7 +247,9 @@ static PyObject *secp256k1_secp256k1_ec_pubkey_create(PyObject *self, PyObject *
|
||||
if (r != 1) {
|
||||
return Py_BuildValue("b", 0);
|
||||
}
|
||||
return Py_BuildValue("y#", pubkeyo, outl);
|
||||
PyObject *return_value = Py_BuildValue("y#", pubkeyo, outl);
|
||||
Py_DECREF(pubkeyo);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
@ -261,7 +271,9 @@ static PyObject *secp256k1_secp256k1_ecdsa_sign(PyObject *self, PyObject *args)
|
||||
return Py_BuildValue("b", 0);
|
||||
}
|
||||
if (der_encoding == 0) {
|
||||
return Py_BuildValue("y#", &signature, 65);
|
||||
PyObject *return_value = Py_BuildValue("y#", &signature, 65);
|
||||
// Py_DECREF(signature);
|
||||
return return_value;
|
||||
} else {
|
||||
unsigned char outputSer[72];
|
||||
size_t outputLen = 72;
|
||||
@ -269,7 +281,9 @@ static PyObject *secp256k1_secp256k1_ecdsa_sign(PyObject *self, PyObject *args)
|
||||
outputSer,
|
||||
&outputLen,
|
||||
(const secp256k1_ecdsa_signature *)&signature);
|
||||
return Py_BuildValue("y#", &outputSer, outputLen);
|
||||
PyObject *return_value = Py_BuildValue("y#", &outputSer, outputLen);
|
||||
Py_DECREF(outputSer);
|
||||
return return_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ def create_master_xprivate_key(seed, testnet=False, base58=True, hex=False):
|
||||
key = b"".join([key, double_sha256(key)[:4]])
|
||||
return encode_base58(key)
|
||||
else:
|
||||
return key
|
||||
return key if not hex else key.hex()
|
||||
|
||||
|
||||
def xprivate_to_xpublic_key(xprivate_key, base58=True, hex=False):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user