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"
      ]
}
  • 3
    I'm voting to close this question as off-topic because this is a simple programming question that belongs on stackoverflow.com – Max Vernon Feb 7 '18 at 13:56
  • I'm voting to close this question as off-topic because this is a simple programming question that belongs on stackoverflow.com – Adam Feb 7 '18 at 15:43
  • 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 Feb 7 '18 at 17:13
1

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

  • 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 Feb 7 '18 at 14:32
  • 1
    Yes, 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 Mar 3 '18 at 14:59
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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.