mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-23 22:15:52 +00:00
Allow lock time to be optionally set when adding a transparent input.
This commit is contained in:
parent
1a8686863b
commit
9768e4af78
@ -175,6 +175,7 @@ impl TransparentInputs {
|
|||||||
coin: TxOut,
|
coin: TxOut,
|
||||||
secret: Vec<u8>,
|
secret: Vec<u8>,
|
||||||
redeem_script: Vec<u8>,
|
redeem_script: Vec<u8>,
|
||||||
|
lock_time: u32,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if coin.value.is_negative() {
|
if coin.value.is_negative() {
|
||||||
return Err(Error::InvalidAmount);
|
return Err(Error::InvalidAmount);
|
||||||
@ -197,6 +198,12 @@ impl TransparentInputs {
|
|||||||
mtx.vin.push(TxIn::new(utxo));
|
mtx.vin.push(TxIn::new(utxo));
|
||||||
self.inputs.push(TransparentInputInfo { sk, pubkey, coin, secret, redeem_script });
|
self.inputs.push(TransparentInputInfo { sk, pubkey, coin, secret, redeem_script });
|
||||||
|
|
||||||
|
// Set lock time if present
|
||||||
|
if (lock_time > 0) {
|
||||||
|
mtx.sequence = 4294967294; // max value (0xFFFFFFFF - 1), so lockTime can be used but not RBF
|
||||||
|
mtx.lock_time = lock_time;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +416,8 @@ impl<R: RngCore + CryptoRng> Builder<R> {
|
|||||||
utxo: OutPoint,
|
utxo: OutPoint,
|
||||||
coin: TxOut,
|
coin: TxOut,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin, Vec::new(), Vec::new())
|
let lock_time: u32 = 0;
|
||||||
|
self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin, Vec::new(), Vec::new(), lock_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a transparent coin to be spent in this transaction, with HTLC secret.
|
/// Adds a transparent coin to be spent in this transaction, with HTLC secret.
|
||||||
@ -421,8 +429,9 @@ impl<R: RngCore + CryptoRng> Builder<R> {
|
|||||||
coin: TxOut,
|
coin: TxOut,
|
||||||
secret: Vec<u8>,
|
secret: Vec<u8>,
|
||||||
redeem_script: Vec<u8>,
|
redeem_script: Vec<u8>,
|
||||||
|
lock_time: u32,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin, secret, redeem_script)
|
self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin, secret, redeem_script, lock_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a transparent address to send funds to.
|
/// Adds a transparent address to send funds to.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user