Created
February 15, 2017 03:29
-
-
Save sniper7kills/3a3e2911564144cabb84ccaee3273757 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ec = Bitcoin::getEcAdapter(); | |
$key = PrivateKeyFactory::fromWif('YOUR_WIF'); | |
$outpoint = new OutPoint(Buffer::hex('YOUR_TRANSACTION', 32), 0); | |
$scriptPubKey = ScriptFactory::scriptPubKey()->payToPubKeyHash($key->getPublicKey()); | |
$value = 0; | |
$txOut = new TransactionOutput($value, $scriptPubKey); | |
$op = new Opcodes(); | |
$destination = new WitnessProgram(0, $key->getPubKeyHash()); | |
$sh = ScriptFactory::sequence([Opcodes::OP_RETURN, Buffer::hex('WHAT YOU WANT TO SEND']); | |
$p2sh = new \BitWasp\Bitcoin\Script\P2shScript($destination->getScript(), $op); | |
$tx = TransactionFactory::build() | |
->spendOutPoint($outpoint) | |
->payToAddress($txref['value'], AddressFactory::fromString($key->getPublicKey()->getAddress()->getAddress())) | |
->output(0, $sh) | |
->get(); | |
$signed = new \BitWasp\Bitcoin\Transaction\Factory\Signer($tx, $ec); | |
$signed->sign(0, $key, $txOut); | |
$ss = $signed->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment