mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
docs: add note about hashing (#7073)
This commit is contained in:
@ -857,8 +857,12 @@ impl TransactionSignedNoHash {
|
||||
}
|
||||
|
||||
/// Converts into a transaction type with its hash: [`TransactionSigned`].
|
||||
///
|
||||
/// Note: This will recalculate the hash of the transaction.
|
||||
#[inline]
|
||||
pub fn with_hash(self) -> TransactionSigned {
|
||||
self.into()
|
||||
let Self { signature, transaction } = self;
|
||||
TransactionSigned::from_transaction_and_signature(transaction, signature)
|
||||
}
|
||||
|
||||
/// Recovers a list of signers from a transaction list iterator
|
||||
@ -941,7 +945,7 @@ impl Compact for TransactionSignedNoHash {
|
||||
|
||||
impl From<TransactionSignedNoHash> for TransactionSigned {
|
||||
fn from(tx: TransactionSignedNoHash) -> Self {
|
||||
TransactionSigned::from_transaction_and_signature(tx.transaction, tx.signature)
|
||||
tx.with_hash()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1155,6 +1159,7 @@ impl TransactionSigned {
|
||||
}
|
||||
|
||||
/// Create a new signed transaction from a transaction and its signature.
|
||||
///
|
||||
/// This will also calculate the transaction hash using its encoding.
|
||||
pub fn from_transaction_and_signature(transaction: Transaction, signature: Signature) -> Self {
|
||||
let mut initial_tx = Self { transaction, hash: Default::default(), signature };
|
||||
|
||||
Reference in New Issue
Block a user