Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: madmadmax on April 21, 2013, 07:28:20 PM



Title: Advanced users
Post by: madmadmax on April 21, 2013, 07:28:20 PM
Code:
  
  $arr = GetTx($client,$myAddress);
  $RawTx = $client->getrawtransaction($arr,1);
  $pieces = explode(" ", $RawTx["vin"][0]["scriptSig"]["asm"]);
  $myHash = hash('ripemd160',hash('sha256',$pieces[1]));
  $myHashStr = chr(0x00).$myHash;
  $myHash2 = hash('sha256',hash('sha256',$myHashStr));
  $myHashStr.=substr($myHash2,0,4);
  echo "Hash:".$myHashStr."<br>";
  echo "Base58:".base58_encode($myHashStr)."<br>";

function base58_encode($num) {
    $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
    $base_count = strlen($alphabet);
    $encoded = '';
    while ($num >= $base_count) {
        $div = $num / $base_count;
        $mod = ($num - ($base_count * intval($div)));
        $encoded = $alphabet[$mod] . $encoded;
        $num = intval($div);
    }
    if ($num) {$encoded = $alphabet[$num] . $encoded;}
    return $encoded;
}

What is wrong with this code?


Title: Re: Advanced users
Post by: jackjack on April 21, 2013, 07:35:24 PM
It's PHP


Title: Re: Advanced users
Post by: madmadmax on April 21, 2013, 08:16:43 PM
It's PHP


Well played  ;D

But could you point out how I get the address that signed that input properly?


Title: Re: Advanced users
Post by: madmadmax on April 21, 2013, 09:00:31 PM
The logic behind these posts amazes me, it's like where does this kind of douchebaggery and need to prove oneself to be more smart than the peers arises.

You open a topic.
There is instantly a reply from a person giving criticism of the structure of the code or the language itself EVEN though is unable to answer the question.
You point out the hypocrisy of the situation to the person only to get a reply along the lines of "I know the answer but I won't tell it to you blah blah".

Back to 4chan/stackoverflow plz, people actually solve problems here,


Title: Re: Advanced users
Post by: minzie on April 21, 2013, 09:39:44 PM
When asking for help it is useful to explain what you are trying to do, what you expected to happen, what really happened, how you are able to replicate it, etc.


Title: Re: Advanced users
Post by: madmadmax on April 21, 2013, 10:37:36 PM
Solved