Add push_* methods for lock times
Lock times are u32 and can necessitate encoding using 5 bytes. As such they are "special". Add methods `push_lock_time` and `push_sequence` for pushing absolute lock times and sequence numbers. We do not push relative locktimes because they are only 16 bits from the original sequence number.
This commit is contained in:
parent
b6387db47f
commit
1e0e712bb0
|
@ -7,8 +7,10 @@ use core::fmt;
|
||||||
|
|
||||||
use secp256k1::XOnlyPublicKey;
|
use secp256k1::XOnlyPublicKey;
|
||||||
|
|
||||||
|
use crate::blockdata::locktime::absolute;
|
||||||
use crate::blockdata::opcodes::{self, all::*};
|
use crate::blockdata::opcodes::{self, all::*};
|
||||||
use crate::blockdata::script::{write_scriptint, opcode_to_verify, Script, ScriptBuf};
|
use crate::blockdata::script::{write_scriptint, opcode_to_verify, Script, ScriptBuf};
|
||||||
|
use crate::blockdata::transaction::Sequence;
|
||||||
use crate::key::PublicKey;
|
use crate::key::PublicKey;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
@ -106,6 +108,16 @@ impl Builder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds instructions to push an absolute lock time onto the stack.
|
||||||
|
pub fn push_lock_time(self, lock_time: absolute::LockTime) -> Builder {
|
||||||
|
self.push_int(lock_time.to_consensus_u32().into())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds instructions to push a sequence number onto the stack.
|
||||||
|
pub fn push_sequence(self, sequence: Sequence) -> Builder {
|
||||||
|
self.push_int(sequence.to_consensus_u32().into())
|
||||||
|
}
|
||||||
|
|
||||||
/// Converts the `Builder` into `ScriptBuf`.
|
/// Converts the `Builder` into `ScriptBuf`.
|
||||||
pub fn into_script(self) -> ScriptBuf {
|
pub fn into_script(self) -> ScriptBuf {
|
||||||
self.0
|
self.0
|
||||||
|
|
Loading…
Reference in New Issue