Browse Source

Add a helper function for converting an M of N script address to a transaction

master
Con Kolivas 10 years ago
parent
commit
6cd2778477
  1. 15
      src/libckpool.c
  2. 1
      src/libckpool.h

15
src/libckpool.c

@ -1503,7 +1503,7 @@ static const int b58tobin_tbl[] = {
47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57
};
/* b58bin should always be at least 25 bytes long and already checked to be
/* b58bin should always be at least 21 bytes long and already checked to be
* valid. */
void b58tobin(char *b58bin, const char *b58)
{
@ -1619,9 +1619,8 @@ char *http_base64(const char *src)
void address_to_pubkeytxn(char *pkh, const char *addr)
{
char b58bin[25];
char b58bin[25] = {};
memset(b58bin, 0, 25);
b58tobin(b58bin, addr);
pkh[0] = 0x76;
pkh[1] = 0xa9;
@ -1631,6 +1630,16 @@ void address_to_pubkeytxn(char *pkh, const char *addr)
pkh[24] = 0xac;
}
void address_to_scripttxn(char *pkh, const char *addr)
{
char b58bin[23] = {};
b58tobin(b58bin, addr);
pkh[0] = 0xa9;
memcpy(&pkh[1], &b58bin[1], 20);
pkh[22] = 0x87;
}
/* For encoding nHeight into coinbase, return how many bytes were used */
int ser_number(uchar *s, int32_t val)
{

1
src/libckpool.h

@ -537,6 +537,7 @@ int safecmp(const char *a, const char *b);
bool cmdmatch(const char *buf, const char *cmd);
void address_to_pubkeytxn(char *pkh, const char *addr);
void address_to_scripttxn(char *pkh, const char *addr);
int ser_number(uchar *s, int32_t val);
int get_sernumber(uchar *s);
bool fulltest(const uchar *hash, const uchar *target);

Loading…
Cancel
Save