How to create hex of raw transaction

1

1

Below is my response after creating the transaction. How do I create the hex encoded string of raw transaction in PHP. Is there package for it in PHP ?

{
      "tx": {
        "block_height": -1,
        "block_index": -1,
        "hash": "e489b823ac92e0f6f254f40ffca90aa026536c0a969302c0dbf27cc746613283",
        "addresses": [
          "C4TBnUyFj5kX9CPp4im8LDWa8d9kgJZMP8",
          "CCLA1wbxJEKLugrPvfpbzo9ApFVPg54asv"
        ],
        "total": 954600,
        "fees": 45400,
        "size": 119,
        "preference": "high",
        "relayed_by": "182.72.122.170",
        "received": "2018-02-06T08:47:01.900244013Z",
        "ver": 1,
        "double_spend": false,
        "vin_sz": 1,
        "vout_sz": 2,
        "confirmations": 0,
        "inputs": [
          {
            "prev_hash": "48e09cbf4701230038783a8ea3ef8c6b46b79aef897f54ed7af9ffc130f2072b",
            "output_index": 0,
            "output_value": 1000000,
            "sequence": 4294967295,
            "addresses": [
              "C4TBnUyFj5kX9CPp4im8LDWa8d9kgJZMP8"
            ],
            "script_type": "pay-to-pubkey-hash",
            "age": 1695612
          }
        ],
        "outputs": [
          {
            "value": 10,
            "script": "76a914d2a9103585799178a88be5cc9c6e7fcb4813e29788ac",
            "addresses": [
              "CCLA1wbxJEKLugrPvfpbzo9ApFVPg54asv"
            ],
            "script_type": "pay-to-pubkey-hash"
          },
          {
            "value": 954590,
            "script": "76a9147c3c71d0560de62cbfcb70d7f753aa487191646988ac",
            "addresses": [
              "C4TBnUyFj5kX9CPp4im8LDWa8d9kgJZMP8"
            ],
            "script_type": "pay-to-pubkey-hash"
          }
        ]
      },
      "tosign": [
        "3fad63985892f8e3ddb36f926503b6873bd91c456a24e12771d47a0cb5dc730f"
      ]
}

Shubham Dharamkar

Posted 2018-02-07T10:53:03.580

Reputation: 11

3I'm voting to close this question as off-topic because this is a simple programming question that belongs on stackoverflow.comMax Vernon 2018-02-07T13:56:32.153

I'm voting to close this question as off-topic because this is a simple programming question that belongs on stackoverflow.comAdam 2018-02-07T15:43:29.577

I am just interested in knowing the type of encoding get followed while encryption of the txSkeleton. Can you please help me out with this?Shubham Dharamkar 2018-02-07T17:13:20.007

Answers

1

Bitwasp-PHP can do it. with much more features.

Adam

Posted 2018-02-07T10:53:03.580

Reputation: 3 215

Is there any other way where I can easily encode my raw transaction into HEX without using any package? I have mostly used curl call for the creating transaction so it would be a good option if I get any code segment to convert my transaction into HEX.Shubham Dharamkar 2018-02-07T14:32:22.377

1Yes, you need to take the fields in the arrays of your result, construct the objects in bitcoin-php, and then call getHex on the transaction. With the library you can also create raw unsigned transactions without using curl/bitcoind.karimkorun 2018-03-03T14:59:47.127

0

Welcome Shubham to bitcoin.SE. To my knowledge there isn't a library, but maybe you are working on it? I found two links, which might help you to come to the goal:

What you would need to do, is get the details of the tx correctly serialized. Amaclin explained in his answer very detailed, how to do this.

And then some there is some string to hex conversion in PHP (maybe here).

pebwindkraft

Posted 2018-02-07T10:53:03.580

Reputation: 4 568