Skip to content

Create transaction example #915

@tcolonel

Description

@tcolonel

Hello.

Could you write an example of creating a transaction, signing it, and obtaining a transaction hash that can be sent further - having:

  • only with private key
  • only private key in WIF format

So I don't know nothing about prev tx and so on. I have only private key in diff formats which I get from:

private function generateWallet()
{
    $oPrivateKeyFactory = new PrivateKeyFactory();
    $oRandom = new Random();
    $this->sPrivateKey = $oPrivateKeyFactory->generateCompressed($oRandom);
    $this->sPrivateKeyWif = $this->sPrivateKey->toWif();
    $this->sPublicKey = $this->sPrivateKey->getPublicKey();
    $sPublicKeyHash = $this->sPublicKey->getPubKeyHash();
    $oAddress = new PayToPubKeyHashAddress($sPublicKeyHash);
    $this->sAddress = $oAddress->getAddress($this->oNetwork);
    $oSegwitAddress = new SegwitAddress(WitnessProgram::v0($sPublicKeyHash));
    $this->sSegwitAddress = $oSegwitAddress->getAddress();
}

I read these links and many others, but they didn't help me:

I need a simple solution: received the keys, the address, created a transaction, signed, sent (I know that I a not empty balance).

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions