def safe_sign_transaction( transaction: Transaction, wallet: Wallet, check_fee: bool = True, ) -> Transaction: """ Signs a transaction locally, without trusting external rippled nodes. Args: transaction: the transaction to be signed. wallet: the wallet with which to sign the transaction. check_fee: whether to check if the fee is higher than the expected transaction type fee. Defaults to True. Returns: The signed transaction blob. """ if check_fee: _check_fee(transaction) transaction_json = _prepare_transaction(transaction, wallet) serialized_for_signing = encode_for_signing(transaction_json) serialized_bytes = bytes.fromhex(serialized_for_signing) signature = sign(serialized_bytes, wallet.private_key) transaction_json["TxnSignature"] = signature return cast(Transaction, Transaction.from_xrpl(transaction_json))
def safe_sign_transaction( transaction: Transaction, wallet: Wallet, ) -> Transaction: """ Signs a transaction locally, without trusting external rippled nodes. Args: transaction: the transaction to be signed. wallet: the wallet with which to sign the transaction. Returns: The signed transaction blob. """ transaction_json = _prepare_transaction(transaction, wallet) serialized_for_signing = encode_for_signing(transaction_json) serialized_bytes = bytes.fromhex(serialized_for_signing) signature = sign(serialized_bytes, wallet.private_key) transaction_json["TxnSignature"] = signature return cast(Transaction, Transaction.from_xrpl(transaction_json))
def safe_sign_transaction(transaction: Transaction, wallet: Wallet) -> str: """ Signs a transaction locally, without trusting external rippled nodes. Args: transaction: the transaction to be signed. wallet: the wallet with which to sign the transaction. Returns: The signed transaction blob. """ # Increment the wallet sequence number, since we're about to use one. wallet.next_sequence_num += 1 transaction_json = transaction_json_to_binary_codec_form( transaction.to_dict()) transaction_json["SigningPubKey"] = wallet.pub_key serialized_for_signing = encode_for_signing(transaction_json) serialized_bytes = bytes.fromhex(serialized_for_signing) signature = sign(serialized_bytes, wallet.priv_key) transaction_json["TxnSignature"] = signature return encode(transaction_json)