Locally signing ECDSA transactions with Blockcypher API

132 views Asked by At

So I'm using Blockcypher in a project of mine and I am following the guide presented here to create a new transaction:

https://www.blockcypher.com/dev/bitcoin/?shell#creating-transactions

I'm stuck at the part where you have to sign a transaction using a signing tool. They presented a tool which is hosted on github at https://github.com/blockcypher/btcutils/tree/master/signer. Please I need clear instructions and/or clarification on how this tool is to be deployed and used.

From the GitHub page I learnt that go language has to be installed on the server before it can be used. I get that part. And I have installed and generated the signer binary. What I don't get is how exactly will the tool be used in my PHP codebase.

I am using PHP and curl to call APIs. So my question is: how exactly am I supposed to use this in my PHP code since it is a compiled go binary? The only solution that has worked for me so far is to login via SSH through the PHP code using a library like phpseclib then call the go binary from the shell programmatically to get the signed key. Somewhat like this:

private function sign_payload($to_sign, $private_key)
    {
        $ssh = new Net_SSH2('[IP]');
        if (!$ssh->login('[ssh_user]', '[password]')) {
            exit('ssh connect failure');
        }

        return $ssh->exec("cd [dir]/btcutils/signer\n./signer " . $to_sign . " " . $private_key);
    }

This is obviously extremely sub-optimal and un-scalable as I can't be having thousands of users concurrently logging in via SSH just to get a signature.

Is there no easy or straightforward endpoint or API to call to get this signature? Why is it so hard and poorly explained? Is there a PHP version? I would appreciate a prompt response to this request.

Thank you.

0

There are 0 answers