I offer 200 BTSX to the best solution for the following task.
Given: a bitcoin public key (in hexadecimal char vector)
Input:
- from command line argument: public key for a bitcoin address in hexformat
Ouput:
- the BTSX address that can be accessed if you own the private key to the input private key
- the PTS address that can be accessed by the same private key
Hint .. go over to the BitShares Toolkit sources .. in the programs/utils folder there are tools that
can be expended to achieve this task. I tried figuring it out myself but just failed :(
Ah, yha, please post the documented source code (probably less than 50 lines of code)
string client_impl::btctobts(const string& btcaddress)const
{
balance_record initial_balance(pts_address(btcaddress),
asset(share_type(0), 0),
0 /* Not voting for anyone */
);
return string(initial_balance.condition.get_address());
}
this work on client.cpp.
bts::blockchain::address btc _address convert_to_bts_address (std::string& ptsbase58str)
{
return address(pts_address(ptsbase58str ));
}
i write this with my phone, not test yet.
nice solutions so far ...
As I am not a coder (and I figured those parts out my self already)
I'd really like to see a full-length compileable file ...
(from within the toolkit)
(best for me would be a git pull request to the official repo that includes that file in the utilities of the toolbox .. )
edit:// and I figured 200 BTSX is to few for that task ..
I will send both of you the 200 BTSX and as soon as I get to it I will raise the bounty price to sth. that is more like 40-50$ ..
2014-08-27T18:33:54 332007 xeroc cgafeng 200.00000 BTSX bounty 0.50000 BTSX 56a975d8
2014-08-27T18:34:04 332008 xeroc crazybit 200.00000 BTSX bounty 0.50000 BTSX 8891114bThanks for pointing me there .. I try to figure out the rest my self
#include <bts/blockchain/address.hpp>
#include <bts/blockchain/pts_address.hpp>
#include <bts/utilities/key_conversion.hpp>
#include <fc/crypto/elliptic.hpp>
#include <iostream>
using namespace bts::blockchain;
bts::blockchain::address btc_address_convert_to_bts_address(const std::string& base58str)
{
return address(pts_address(base58str));
}
int main( int argc, char** argv )
{
if( argc == 1 )
{
std::cout << "useage: convert_btc_address <btcaddress>" <<"\n";
}
else
{
std::string myarg = argv[1];
std::cout << "Input: " << myarg << "\n";
std::cout << "BTS address: " << std::string(btc_address_convert_to_bts_address(myarg)) << "\n";
}
}
But it is not working as intended :(
I generated a random new key and added it to an existing account ... result
>> wallet_account_list_public_keys xeroc
[{
"hex": "029ce4fb7d77478a8760d08b79b4664d78453958d2efeb1b8d91d033a175c35b7c",
"native_pubkey": "BTSX65b1ez7zLiJZ5PwGQ3qdQ6bWr5goeyZnfwqYBtzjAVVZr9dxcP",
"native_address": "BTSXEkMHfXiWnRb7hHSZ67Gw9iJ8ZbL8FEJKw",
"pts_normal_address": "PdVJKUTwGdtV1RDrZ8TbXsC2dU874MSqyS",
"pts_compressed_address": "PmLJC5PbKgL6WS51c823LciPsMbtKdSMSm",
"btc_normal_address": "16ZXBPmoWXwRD9R1BdokNqwyPDhHBgfhH1",
"btc_compressed_address": "1EQX3zhTZaP2iAGAEdNCBbULd7B4Vjt5Eq"
},{
I took the BTC address 16ZXBPmoWXwRD9R1BdokNqwyPDhHBgfhH1 and put it into the executable:
./convert_btc_address 16ZXBPmoWXwRD9R1BdokNqwyPDhHBgfhH1
Input: 16ZXBPmoWXwRD9R1BdokNqwyPDhHBgfhH1
BTS address: BTSXPfmi29tucM9HRpPAEKD1dqJuFQRY5gqcY
BTS addresses don't match ... No what?
BTSX addresses are not used anywhere in the API... we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
Quote from: bytemaster on August 27, 2014, 08:53:21 PM
BTSX addresses are not used anywhere in the API... we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
So I cannot register a name on the above results ...
can I convert a hex.formated bitcoin pubkey into a BTSX pubkey so that I can register a name on a bitcoin pubkey/address ?
Quote from: bytemaster on August 27, 2014, 08:53:21 PM
BTSX addresses are not used anywhere in the API... we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
BM, how does the toolkit generates the balance id from the existing btc/pts address in genesis block?similar to the following logic? is the balance id same with balance record owner ?
balance id =ripemd160(sha512(hash of public key))
Quote from: crazybit on August 28, 2014, 09:20:41 AM
Quote from: bytemaster on August 27, 2014, 08:53:21 PM
BTSX addresses are not used anywhere in the API... we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
BM, how does the toolkit generates the balance id from the existing btc/pts address in genesis block?similar to the following logic? is the balance id same with balance record owner ?
balance id =ripemd160(sha512(hash of public key))
The initial balances it stored in a BTSX ADDRESS .. the rest of the network works on BTSX PUBLIC KEYSs (ie, when you register a name, you register a pubkey .. not an address)
Thus, I cannot use the result of the above script to register a name on his behalf as I need to register a PUBKEY ... so I need to take the bitcoin pubkey of that address and convert that one to a bitsharesx pubkey ... just don't know yet how to do it :(
Quote from: bytemaster on August 27, 2014, 08:53:21 PM
BTSX addresses are not used anywhere in the API... we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
I tried to figure this out .. but failed ... could you points me to some direction so that I can try figure this out myself?
Is it even possible to to register a btsx account using a pubkey generated from a bitcoin
address pubkey .. so that the holder of the privkey (bitcoin) can import an account name I registered for him?
Quote from: xeroc on August 28, 2014, 01:57:25 PM
Quote from: bytemaster on August 27, 2014, 08:53:21 PM
BTSX addresses are not used anywhere in the API... we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
I tried to figure this out .. but failed ... could you points me to some direction so that I can try figure this out myself?
Is it even possible to to register a btsx account using a pubkey generated from a bitcoin address .. so that the holder of the privkey (bitcoin) can import an account name I registered for him?
I don't think this can work.
Quote from: xeroc on August 28, 2014, 01:57:25 PM
Quote from: bytemaster on August 27, 2014, 08:53:21 PM
but there is no way to convert an address to a public key (address is hash of public key)
Is it even possible to to register a btsx account using a pubkey generated from a bitcoin address .. so that the holder of the privkey (bitcoin) can import an account name I registered for him?
You cannot "generate a pubkey from a bitcoin address" because the address is essentially a cryptographic hash of the pubkey. Cryptographic hashes are one way - it's easy to compute the hash for a key but close to impossible to find the key(s) generating a given hash.
Quote from: pc on August 28, 2014, 08:12:45 PM
You cannot "generate a pubkey from a bitcoin address" because the address is essentially a cryptographic hash of the pubkey. Cryptographic hashes are one way - it's easy to compute the hash for a key but close to impossible to find the key(s) generating a given hash.
I know that .. fixed the typo above
I want to generate a BTSX PubKey from a BTC PubKey!
I think i got it .. gonna have to test it first .. publish code next week ... have a nace weekend
Here we go:
https://github.com/BitShares/bitshares_toolkit/pull/734
edit: just figured I need to distinguish between compressed and uncompressed format .. thought they where only for private keys ..
sth learned to day .. maybe I can figure that out too