lib/eth/tx/legacy.rb
def sign(key)
        if Tx.is_signed? self
          raise Signature::SignatureError, "Transaction is already signed!"
        end

        # ensure the sender address matches the given key
        unless @sender.nil? or sender.empty?
          signer_address = Tx.sanitize_address key.address.to_s
          from_address = Tx.sanitize_address @sender
          raise Signature::SignatureError, "Signer does not match sender" unless signer_address == from_address
        end

        # sign a keccak hash of the unsigned, encoded transaction
        signature = key.sign(unsigned_hash, @chain_id)
        r, s, v = Signature.dissect signature
        @signature_v = v
        @signature_r = r
        @signature_s = s
        return hash
      end
# Sign the transaction with a given key.
#
# @param key [Eth::Key] the key-pair to use for signing.
# @return [String] a transaction hash.
# @raise [Signature::SignatureError] if transaction is already signed.
# @raise [Signature::SignatureError] if sender address does not match signing key.
Sign the transaction with a given key.
Sign the transaction with a given key .
def sign(key)
        if Tx.is_signed? self
          raise Signature::SignatureError, "Transaction is already signed!"
        end
        unless @sender.nil? or sender.empty?
          signer_address = Tx.sanitize_address key.address.to_s
          from_address = Tx.sanitize_address @sender
          raise Signature::SignatureError, "Signer does not match sender" unless signer_address == from_address
        end
        signature = key.sign(unsigned_hash, @chain_id)
        r, s, v = Signature.dissect signature
        @signature_v = v
        @signature_r = r
        @signature_s = s
        return hash
      end
def sign ( key ) if Tx . is_signed? self raise Signature :: SignatureError , "Transaction is already signed!" end unless @sender . nil? or sender . empty? signer_address = Tx . sanitize_address key . address . to_s from_address = Tx . sanitize_address @sender raise Signature :: SignatureError , "Signer does not match sender" unless signer_address == from_address end signature = key . sign ( unsigned_hash , @chain_id ) r , s , v = Signature . dissect signature @signature_v = v @signature_r = r @signature_s = s return hash end
Sign the transaction with a given key.
Sign the transaction with a given key .
# ensure the sender address matches the given key # sign a keccak hash of the unsigned, encoded transaction
a transaction hash.
a transaction hash .
String
[Signature::SignatureError] if transaction is already signed.
[ Signature :: SignatureError ] if transaction is already signed .
[Signature::SignatureError] if sender address does not match signing key.
[ Signature :: SignatureError ] if sender address does not match signing key .
key
the key-pair to use for signing.
the key - pair to use for signing .