Wednesday, December 7, 2022
HomeBitcoinbitcoin core - PHP Blockcypher error validating generated transaction: Error operating script...

bitcoin core – PHP Blockcypher error validating generated transaction: Error operating script for enter 0


Trying to make use of Blockcypher’s /txs/ship endpoint utilizing detailed right here: https://www.blockcypher.com/dev/bitcoin/#creating-transactions and I am getting the next error:

Error validating generated transaction: Error operating script for enter 0 referencing 5bf99cd9191700eb9c324a00dee0ac857b804f63c391490d9c21036e4c78ac73 at 0: Script was NOT verified efficiently.

Searched far and vast and might’t discover a affordable answer.

I generate the transaction successufully and this is a replica of my TX:

"tx": {
        "block_height": -1,
        "block_index": -1,
        "hash": "d64c7acf354b55c69756c4646b100245fe496633b1a5be9a7cc66f4f46cf797e",
        "addresses": [
            "n3nsT38n7k83FL5p7PPvkHgdwJAzA5QBoi",
            "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt"
        ],
        "whole": 81172,
        "charges": 29300,
        "dimension": 223,
        "vsize": 223,
        "desire": "excessive",
        "relayed_by": "20.185.53.173",
        "acquired": "2022-04-19T11:58:00.294345726Z",
        "ver": 1,
        "double_spend": false,
        "vin_sz": 2,
        "vout_sz": 2,
        "confirmations": 0,
        "inputs": [
            {
                "prev_hash": "5bf99cd9191700eb9c324a00dee0ac857b804f63c391490d9c21036e4c78ac73",
                "output_index": 0,
                "output_value": 10000,
                "sequence": 4294967295,
                "addresses": [
                    "n3nsT38n7k83FL5p7PPvkHgdwJAzA5QBoi"
                ],
                "script_type": "pay-to-pubkey-hash",
                "age": 2196309
            },
            {
                "prev_hash": "f21f9e457d61ba4fa5858f3a4ba4c37179c12d1275a1bd799f0c0c91d3f15269",
                "output_index": 1,
                "output_value": 100472,
                "sequence": 4294967295,
                "addresses": [
                    "n3nsT38n7k83FL5p7PPvkHgdwJAzA5QBoi"
                ],
                "script_type": "pay-to-pubkey-hash",
                "age": 2196316
            }
        ],
        "outputs": [
            {
                "value": 500,
                "script": "0014ff9da567e62f30ea8654fa1d5fbd47bef8e3be13",
                "addresses": [
                    "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt"
                ],
                "script_type": "pay-to-witness-pubkey-hash"
            },
            {
                "worth": 80672,
                "script": "76a914f45560cd98d9a84d6c568bb845db0cef81ed548288ac",
                "addresses": [
                    "n3nsT38n7k83FL5p7PPvkHgdwJAzA5QBoi"
                ],
                "script_type": "pay-to-pubkey-hash"
            }
        ]
    }

tosign:

"tosign": [
        "7a407b770128fd9cd51f95010904f05fecde80202d2fecd2340020d0994ce582",
        "1d03cbac44034426c236268684bedf169beb38210f9857a46086cdade4a9c910"
    ]

signatures:

"signatures": [
        "30450221009f04eccdc41ec135083110b1dcf2ed0edb4c68aefd627820944f9314020faa4e02202337b880a133e22c03df252cf43114158774173229efe2d2d47df6cdc70a610f",
        "3045022100de59d669e38b669b0a0d4451d7a453269da849a202cd325f4923565897d562e002202db8883506cc8f5cd87b6a61cbcfd793dd6107e3a073debf1b4d2b008fcb002e"
    ]

pubkeys:

"pubkeys": [
        "303231393839646331643236333136303662653139396564333261666531636238313362343034353565326462623232303563613962393336356134626232373330",
        "303231393839646331643236333136303662653139396564333261666531636238313362343034353565326462623232303563613962393336356134626232373330"
    ]

Handle data (earlier than hex encoding utilizing bin2hex):

"personal": "a76b15c0b931b54141f73f127535ae946d45a52872306f7b5eaf3623290a1518",
    "public": "021989dc1d2631606be199ed32afe1cb813b40455e2dbb2205ca9b9365a4bb2730",
    "handle": "n3nsT38n7k83FL5p7PPvkHgdwJAzA5QBoi",
    "wif": "cTC98Ng4DP92Mgi34bJADkcDbc5giMMmmcTiSUHQQkEr92MsxYd2"

For context I exploit the next signing instrument supplied by them to do the signing:

https://github.com/blockcypher/btcutils/tree/grasp/signer

It is a go binary which I complie and run by logging in by SSH utilizing phpseclib within the following method:

protected operate create_new_transaction()
{
    $enter = [["wallet_name" => $this->wallet_name, "wallet_token" => self::token]];
    $output = [["addresses" => ["$this->destination"], "worth" => (int)$this->worth]];

    $api_settings = $this->api_settings('/v1/btc/test3/txs/new?token=' . self::token . '&inputs=" . $enter . "&outputs=" . $output, "POST', TRUE, array('token' => self::token, 'inputs' => $enter, 'outputs' => $output));
    $outcome = GuzzleHttpjson_decode($api_settings, true);

    $to_sign = $outcome['tosign'];
    $inputs = $outcome['tx']['inputs'];


    // hex encoded arrays of values
    $public_keys_hex = $private_keys_hex = $addresses_hex = $signatures = array();

    foreach ($inputs as $worth) {
        $profile = new Profile();
        $profile->handle = $worth['addresses'][0];

        $address_lookup = $profile->single_address_lookup();

        if ($address_lookup['status']) {
            array_push($public_keys_hex, bin2hex($address_lookup['address_data'][0]['public_key']));
            array_push($private_keys_hex, bin2hex($address_lookup['address_data'][0]['private_key']));
            array_push($addresses_hex, bin2hex($address_lookup['address_data'][0]['address']));

        } else return [
            'status' => false,
            'message' => 'failed to retrieve address data'
        ];
    }


    foreach ($to_sign as $index => $signal) {
        $signature = $this->sign_payload($signal, $private_keys_hex[$index]);
        array_push($signatures, str_replace("n", "", $signature));
    }

    $outcome += ['signatures' => $signatures];
    $outcome += ['pubkeys' => $public_keys_hex];

    return empty($outcome) ? [
        'status' => false,
        'message' => "invalid response"
    ] : [
        'status' => true,
        'message' => $result
    ];
}

The precise sign_payload operate:

personal operate sign_payload($to_sign, $private_key)
{
    $ssh = new Net_SSH2('[ip_address]');
    if (!$ssh->login('root', '[password]')) {
        exit('ssh join failure');
    }

    return $ssh->exec("cd /var/www/vhosts/[domain_name]/httpdocs/btcutils/signern./signer " . $to_sign . " " . $private_key);
}

I am utterly misplaced and I would recognize some assist concerning this. PS: Tried reaching Blockcypher however they by no means reply emails, and there is very restricted data concerning this on-line.

On the Blockcypher docs there’s this remark:

One of the widespread errors we see are customers who use uncompressed public keys when compressed public keys had been used to generate the handle; keep in mind to watch out to make use of the correct keys!

I do not know what meaning, and I would love some clarification. Would additionally prefer to know if that’s inflicting my difficulty.

Thanks quite a bit.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments