Merge rust-bitcoin/rust-bitcoin#1629: Add methods for pushing locktimes
1e0e712bb0
Add push_* methods for lock times (Tobin C. Harding) Pull request description: Lock times are `u32` and can require encoding using 5 bytes. 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. ACKs for top commit: Kixunil: ACK1e0e712bb0
apoelstra: ACK1e0e712bb0
Tree-SHA512: 4b511679270e7ef73937259ccf7d1b9b4b7512b2464f302310519a6e02d55c9cc24e3559302aeb671156e68130478258c1c565f474880e8be708b0ee234e67ff
This commit is contained in:
commit
1514205e5f
|
@ -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