public function signTransaction(TxModel $transaction, KeyPair $kp = null)
    {
        // always set optional `signer` in case we provide a KeyPair
        if (null !== $kp) {
            $transaction->setAttribute("signer", $kp->getPublicKey("hex"));
        }

        // now we can serialize and sign
        $serialized = $transaction->serialize();
        $serialHex = Buffer::fromUInt8($serialized)->getHex();
        $serialBin = hex2bin($serialHex);
        return null !== $kp ? $kp->sign($serialBin) : null;
    }
public function signTransaction(TxModel $transaction, KeyPair $kp = null)
    {
        // always set optional `signer` in case we provide a KeyPair
        if (null !== $kp) {
            $transaction->setAttribute("signer", $kp->getPublicKey("hex"));
        }

        // now we can serialize and sign
        $serialized = $transaction->serialize();
        $serialHex = Buffer::fromUInt8($serialized)->getHex();
        $serialBin = hex2bin($serialHex);
        return null !== $kp ? $kp->sign($serialBin) : null;
    }
public function signTransaction ( TxModel $ transaction , KeyPair $ kp = null ) { // always set optional `signer` in case we provide a KeyPair if ( null !== $ kp ) { $ transaction -> setAttribute ( "signer" , $ kp -> getPublicKey ( "hex" ) ) ; } // now we can serialize and sign $ serialized = $ transaction -> serialize ( ) ; $ serialHex = Buffer :: fromUInt8 ( $ serialized ) -> getHex ( ) ; $ serialBin = hex2bin ( $ serialHex ) ; return null !== $ kp ? $ kp -> sign ( $ serialBin ) : null ; }
Helper method to sign a transaction with a given keypair `kp`.

If no keypair is provided, this method will return `null`.

@internal This method is used internally to determined whether
instanciated keypairs are detected and to make sure that
Client Signatures are always created when possible.

@param   \NEM\Models\Transaction     $transaction
@param   null|\NEM\Core\KeyPair      $kp
@return  null|\NEM\Core\Buffer
Helper method to sign a transaction with a given keypair kp .