Open jackyxie opened 3 years ago
txid: 68f283ecda28bfaa3e2a79370b9fe7473143875a49c0dc817ba1c09cbdaf6572
68f283ecda28bfaa3e2a79370b9fe7473143875a49c0dc817ba1c09cbdaf6572
code: showup " Newly Generated Coins"
<?php use BitWasp\Bitcoin\Address\AddressCreator; require __DIR__ . "/vendor/autoload.php"; $raw = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804fd68011c024705ffffffff0100f2052a01000000434104b43343369809f32af2ef87d75b86140358041f9cc70f3449cff407edf864a3b4b1042183cb0b1954e7f10698329d68785b344695a1f17aa858f6091bd9b14ff1ac00000000'; $tx = \BitWasp\Bitcoin\Transaction\TransactionFactory::fromHex($raw); $addrCreator = new AddressCreator(); $result['txid'] = $tx->getTxId()->getHex(); foreach ($tx->getOutputs() as $key=>$output) { var_dump($output->getScript()); try{ $result['outputs'][$key]['address'] = $addrCreator->fromOutputScript($output->getScript())->getAddress(); }catch (\Exception $e){ var_dump($e->getMessage()); $result['outputs'][$key]['address'] = 'Newly Generated Coins'; } $result['outputs'][$key]['value'] = $output->getValue() / 100000000; } die(print_r($result));
tx data:
{ "result": { "txid": "68f283ecda28bfaa3e2a79370b9fe7473143875a49c0dc817ba1c09cbdaf6572", "hash": "68f283ecda28bfaa3e2a79370b9fe7473143875a49c0dc817ba1c09cbdaf6572", "version": 1, "size": 135, "vsize": 135, "weight": 540, "locktime": 0, "vin": [ { "coinbase": "04fd68011c024705", "sequence": 4294967295 } ], "vout": [ { "value": 50.00000000, "n": 0, "scriptPubKey": { "asm": "04b43343369809f32af2ef87d75b86140358041f9cc70f3449cff407edf864a3b4b1042183cb0b1954e7f10698329d68785b344695a1f17aa858f6091bd9b14ff1 OP_CHECKSIG", "hex": "4104b43343369809f32af2ef87d75b86140358041f9cc70f3449cff407edf864a3b4b1042183cb0b1954e7f10698329d68785b344695a1f17aa858f6091bd9b14ff1ac", "type": "pubkey" } } ], "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804fd68011c024705ffffffff0100f2052a01000000434104b43343369809f32af2ef87d75b86140358041f9cc70f3449cff407edf864a3b4b1042183cb0b1954e7f10698329d68785b344695a1f17aa858f6091bd9b14ff1ac00000000", "blockhash": "00000000002b8cd0faa58444df3ba2a22af2b5838c7e4a5b687444f913a575c2", "confirmations": 638885, "time": 1279986642, "blocktime": 1279986642 }, "error": null, "id": "curltest" }
txid:
68f283ecda28bfaa3e2a79370b9fe7473143875a49c0dc817ba1c09cbdaf6572
code: showup " Newly Generated Coins"
tx data: