mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 13:39:25 +00:00
Implement a proper Monero Timelock type
Transaction scanning now returns the timelock to ensure it's acknowledged by wallets. Fixes https://github.com/serai-dex/serai/issues/16.
This commit is contained in:
@@ -11,7 +11,7 @@ use monero::{consensus::deserialize, blockdata::transaction::ExtraField};
|
||||
use crate::{
|
||||
Commitment,
|
||||
serialize::{write_varint, read_32, read_scalar, read_point},
|
||||
transaction::Transaction,
|
||||
transaction::{Timelock, Transaction},
|
||||
wallet::{uniqueness, shared_key, amount_decryption, commitment_mask}
|
||||
};
|
||||
|
||||
@@ -57,13 +57,7 @@ impl Transaction {
|
||||
&self,
|
||||
view: Scalar,
|
||||
spend: EdwardsPoint
|
||||
) -> Vec<SpendableOutput> {
|
||||
// Ignore transactions which utilize a timelock. Almost no transactions on Monero do,
|
||||
// and they're not worth the effort to track given their complexities
|
||||
if self.prefix.unlock_time != 0 {
|
||||
return vec![];
|
||||
}
|
||||
|
||||
) -> (Vec<SpendableOutput>, Timelock) {
|
||||
let mut extra = vec![];
|
||||
write_varint(&u64::try_from(self.prefix.extra.len()).unwrap(), &mut extra).unwrap();
|
||||
extra.extend(&self.prefix.extra);
|
||||
@@ -81,7 +75,7 @@ impl Transaction {
|
||||
|
||||
pubkeys = m_pubkeys.iter().map(|key| key.point.decompress()).filter_map(|key| key).collect();
|
||||
} else {
|
||||
return vec![];
|
||||
return (vec![], self.prefix.timelock);
|
||||
};
|
||||
|
||||
let mut res = vec![];
|
||||
@@ -136,6 +130,7 @@ impl Transaction {
|
||||
}
|
||||
}
|
||||
}
|
||||
res
|
||||
|
||||
(res, self.prefix.timelock)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ use crate::{
|
||||
bulletproofs::Bulletproofs,
|
||||
RctBase, RctPrunable, RctSignatures
|
||||
},
|
||||
transaction::{Input, Output, TransactionPrefix, Transaction},
|
||||
transaction::{Input, Output, Timelock, TransactionPrefix, Transaction},
|
||||
rpc::{Rpc, RpcError},
|
||||
wallet::{SpendableOutput, Decoys, key_image_sort, uniqueness, shared_key, commitment_mask, amount_encryption}
|
||||
};
|
||||
@@ -255,7 +255,7 @@ impl SignableTransaction {
|
||||
Transaction {
|
||||
prefix: TransactionPrefix {
|
||||
version: 2,
|
||||
unlock_time: 0,
|
||||
timelock: Timelock::None,
|
||||
inputs: vec![],
|
||||
outputs: tx_outputs,
|
||||
extra
|
||||
|
||||
Reference in New Issue
Block a user