Adding account encoding function.

This commit is contained in:
clemahieu 2017-12-19 11:37:24 -06:00
commit c26a0543d0
2 changed files with 10 additions and 2 deletions

View file

@ -14,13 +14,19 @@ extern "C" {
void xrb_uint256_to_string (xrb_uint256 source, char * destination)
{
auto const & number (*reinterpret_cast <rai::uint256_union *> (source));
strncpy (destination, number.to_string ().c_str (), 65);
strncpy (destination, number.to_string ().c_str (), 64);
}
void xrb_uint256_to_address (xrb_uint256 source, char * destination)
{
auto const & number (*reinterpret_cast <rai::uint256_union *> (source));
strncpy (destination, number.to_account ().c_str (), 65);
}
void xrb_uint512_to_string (xrb_uint512 source, char * destination)
{
auto const & number (*reinterpret_cast <rai::uint512_union *> (source));
strncpy (destination, number.to_string ().c_str (), 129);
strncpy (destination, number.to_string ().c_str (), 128);
}
int xrb_uint256_from_string (const char * source, xrb_uint256 destination)

View file

@ -11,6 +11,8 @@ typedef void * xrb_transaction;
// Convert public/private key bytes 'source' to a 64 byte not-null-terminated hex string 'destination'
void xrb_uint256_to_string (const xrb_uint256 source, char * destination);
// Convert public key bytes 'source' to a 65 byte non-null-terminated account string 'destination'
void xrb_uint256_to_address (xrb_uint256 source, char * destination)
// Convert public/private key bytes 'source' to a 128 byte not-null-terminated hex string 'destination'
void xrb_uint512_to_string (const xrb_uint512 source, char * destination);