remove PackedLockTime type
This can be replicated by deleting the `type PackedLockTime = LockTime' line, and then running find . -type f | xargs sed -i 's/PackedLockTime/LockTime/g at the root of the repo.
This commit is contained in:
parent
4dee116b8a
commit
5b7d801ee6
|
@ -185,7 +185,7 @@ impl WatchOnly {
|
||||||
|
|
||||||
let tx = Transaction {
|
let tx = Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(INPUT_UTXO_TXID)?,
|
txid: Txid::from_hex(INPUT_UTXO_TXID)?,
|
||||||
|
|
|
@ -225,7 +225,7 @@ fn generate_bip86_key_spend_tx(
|
||||||
// CREATOR + UPDATER
|
// CREATOR + UPDATER
|
||||||
let tx1 = Transaction {
|
let tx1 = Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(input_utxo.txid)?,
|
txid: Txid::from_hex(input_utxo.txid)?,
|
||||||
|
@ -412,7 +412,7 @@ impl BenefactorWallet {
|
||||||
// CREATOR + UPDATER
|
// CREATOR + UPDATER
|
||||||
let next_tx = Transaction {
|
let next_tx = Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::from_consensus(lock_time),
|
lock_time: absolute::LockTime::from_consensus(lock_time),
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint { txid: tx.txid(), vout: 0 },
|
previous_output: OutPoint { txid: tx.txid(), vout: 0 },
|
||||||
script_sig: Script::new(),
|
script_sig: Script::new(),
|
||||||
|
@ -501,7 +501,7 @@ impl BenefactorWallet {
|
||||||
psbt.unsigned_tx.output =
|
psbt.unsigned_tx.output =
|
||||||
vec![TxOut { script_pubkey: output_script_pubkey.clone(), value: output_value }];
|
vec![TxOut { script_pubkey: output_script_pubkey.clone(), value: output_value }];
|
||||||
psbt.outputs = vec![Output::default()];
|
psbt.outputs = vec![Output::default()];
|
||||||
psbt.unsigned_tx.lock_time = absolute::PackedLockTime::ZERO;
|
psbt.unsigned_tx.lock_time = absolute::LockTime::ZERO;
|
||||||
|
|
||||||
let hash_ty = input
|
let hash_ty = input
|
||||||
.sighash_type
|
.sighash_type
|
||||||
|
@ -557,7 +557,7 @@ impl BenefactorWallet {
|
||||||
|
|
||||||
let next_tx = Transaction {
|
let next_tx = Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::from_consensus(lock_time),
|
lock_time: absolute::LockTime::from_consensus(lock_time),
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint { txid: tx.txid(), vout: 0 },
|
previous_output: OutPoint { txid: tx.txid(), vout: 0 },
|
||||||
script_sig: Script::new(),
|
script_sig: Script::new(),
|
||||||
|
@ -632,7 +632,7 @@ impl BeneficiaryWallet {
|
||||||
let input_value = psbt.inputs[0].witness_utxo.as_ref().unwrap().value;
|
let input_value = psbt.inputs[0].witness_utxo.as_ref().unwrap().value;
|
||||||
let input_script_pubkey =
|
let input_script_pubkey =
|
||||||
psbt.inputs[0].witness_utxo.as_ref().unwrap().script_pubkey.clone();
|
psbt.inputs[0].witness_utxo.as_ref().unwrap().script_pubkey.clone();
|
||||||
psbt.unsigned_tx.lock_time = absolute::PackedLockTime::from_consensus(lock_time);
|
psbt.unsigned_tx.lock_time = absolute::LockTime::from_consensus(lock_time);
|
||||||
psbt.unsigned_tx.output = vec![TxOut {
|
psbt.unsigned_tx.output = vec![TxOut {
|
||||||
script_pubkey: to_address.script_pubkey(),
|
script_pubkey: to_address.script_pubkey(),
|
||||||
value: input_value - ABSOLUTE_FEES_IN_SATS,
|
value: input_value - ABSOLUTE_FEES_IN_SATS,
|
||||||
|
|
|
@ -67,7 +67,7 @@ fn bitcoin_genesis_tx() -> Transaction {
|
||||||
// Base
|
// Base
|
||||||
let mut ret = Transaction {
|
let mut ret = Transaction {
|
||||||
version: 1,
|
version: 1,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![],
|
input: vec![],
|
||||||
output: vec![],
|
output: vec![],
|
||||||
};
|
};
|
||||||
|
@ -213,7 +213,7 @@ mod test {
|
||||||
assert_eq!(serialize(&gen.output[0].script_pubkey),
|
assert_eq!(serialize(&gen.output[0].script_pubkey),
|
||||||
Vec::from_hex("434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac").unwrap());
|
Vec::from_hex("434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac").unwrap());
|
||||||
assert_eq!(gen.output[0].value, 50 * COIN_VALUE);
|
assert_eq!(gen.output[0].value, 50 * COIN_VALUE);
|
||||||
assert_eq!(gen.lock_time, absolute::PackedLockTime::ZERO);
|
assert_eq!(gen.lock_time, absolute::LockTime::ZERO);
|
||||||
|
|
||||||
assert_eq!(gen.wtxid().to_hex(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
|
assert_eq!(gen.wtxid().to_hex(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,6 @@ use crate::absolute;
|
||||||
/// [Bitcoin Core]: https://github.com/bitcoin/bitcoin/blob/9ccaee1d5e2e4b79b0a7c29aadb41b97e4741332/src/script/script.h#L39
|
/// [Bitcoin Core]: https://github.com/bitcoin/bitcoin/blob/9ccaee1d5e2e4b79b0a7c29aadb41b97e4741332/src/script/script.h#L39
|
||||||
pub const LOCK_TIME_THRESHOLD: u32 = 500_000_000;
|
pub const LOCK_TIME_THRESHOLD: u32 = 500_000_000;
|
||||||
|
|
||||||
/// Will be deleted in next commit
|
|
||||||
pub type PackedLockTime = LockTime;
|
|
||||||
|
|
||||||
/// An absolute lock time value, representing either a block height or a UNIX timestamp (seconds
|
/// An absolute lock time value, representing either a block height or a UNIX timestamp (seconds
|
||||||
/// since epoch).
|
/// since epoch).
|
||||||
///
|
///
|
||||||
|
@ -734,21 +731,21 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn packed_lock_time_from_str_hex_happy_path() {
|
fn packed_lock_time_from_str_hex_happy_path() {
|
||||||
let actual = PackedLockTime::from_hex_str("0xBA70D").unwrap();
|
let actual = LockTime::from_hex_str("0xBA70D").unwrap();
|
||||||
let expected = PackedLockTime::from_consensus(0xBA70D);
|
let expected = LockTime::from_consensus(0xBA70D);
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn packed_lock_time_from_str_hex_no_prefix_happy_path() {
|
fn packed_lock_time_from_str_hex_no_prefix_happy_path() {
|
||||||
let lock_time = PackedLockTime::from_hex_str_no_prefix("BA70D").unwrap();
|
let lock_time = LockTime::from_hex_str_no_prefix("BA70D").unwrap();
|
||||||
assert_eq!(lock_time, PackedLockTime::from_consensus(0xBA70D));
|
assert_eq!(lock_time, LockTime::from_consensus(0xBA70D));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn packed_lock_time_from_str_hex_invalid_hex_should_ergr() {
|
fn packed_lock_time_from_str_hex_invalid_hex_should_ergr() {
|
||||||
let hex = "0xzb93";
|
let hex = "0xzb93";
|
||||||
let result = PackedLockTime::from_hex_str(hex);
|
let result = LockTime::from_hex_str(hex);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -592,7 +592,7 @@ pub struct Transaction {
|
||||||
///
|
///
|
||||||
/// * [BIP-65 OP_CHECKLOCKTIMEVERIFY](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)
|
/// * [BIP-65 OP_CHECKLOCKTIMEVERIFY](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)
|
||||||
/// * [BIP-113 Median time-past as endpoint for lock-time calculations](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki)
|
/// * [BIP-113 Median time-past as endpoint for lock-time calculations](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki)
|
||||||
pub lock_time: absolute::PackedLockTime,
|
pub lock_time: absolute::LockTime,
|
||||||
/// List of transaction inputs.
|
/// List of transaction inputs.
|
||||||
pub input: Vec<TxIn>,
|
pub input: Vec<TxIn>,
|
||||||
/// List of transaction outputs.
|
/// List of transaction outputs.
|
||||||
|
@ -1159,7 +1159,7 @@ mod tests {
|
||||||
"ce9ea9f6f5e422c6a9dbcddb3b9a14d1c78fab9ab520cb281aa2a74a09575da1".to_string());
|
"ce9ea9f6f5e422c6a9dbcddb3b9a14d1c78fab9ab520cb281aa2a74a09575da1".to_string());
|
||||||
assert_eq!(realtx.input[0].previous_output.vout, 1);
|
assert_eq!(realtx.input[0].previous_output.vout, 1);
|
||||||
assert_eq!(realtx.output.len(), 1);
|
assert_eq!(realtx.output.len(), 1);
|
||||||
assert_eq!(realtx.lock_time, absolute::PackedLockTime::ZERO);
|
assert_eq!(realtx.lock_time, absolute::LockTime::ZERO);
|
||||||
|
|
||||||
assert_eq!(format!("{:x}", realtx.txid()),
|
assert_eq!(format!("{:x}", realtx.txid()),
|
||||||
"a6eab3c14ab5272a58a5ba91505ba1a4b6d7a3a9fcbd187b6cd99a7b6d548cb7".to_string());
|
"a6eab3c14ab5272a58a5ba91505ba1a4b6d7a3a9fcbd187b6cd99a7b6d548cb7".to_string());
|
||||||
|
@ -1193,7 +1193,7 @@ mod tests {
|
||||||
"7cac3cf9a112cf04901a51d605058615d56ffe6d04b45270e89d1720ea955859".to_string());
|
"7cac3cf9a112cf04901a51d605058615d56ffe6d04b45270e89d1720ea955859".to_string());
|
||||||
assert_eq!(realtx.input[0].previous_output.vout, 1);
|
assert_eq!(realtx.input[0].previous_output.vout, 1);
|
||||||
assert_eq!(realtx.output.len(), 1);
|
assert_eq!(realtx.output.len(), 1);
|
||||||
assert_eq!(realtx.lock_time, absolute::PackedLockTime::ZERO);
|
assert_eq!(realtx.lock_time, absolute::LockTime::ZERO);
|
||||||
|
|
||||||
assert_eq!(format!("{:x}", realtx.txid()),
|
assert_eq!(format!("{:x}", realtx.txid()),
|
||||||
"f5864806e3565c34d1b41e716f72609d00b55ea5eac5b924c9719a842ef42206".to_string());
|
"f5864806e3565c34d1b41e716f72609d00b55ea5eac5b924c9719a842ef42206".to_string());
|
||||||
|
|
|
@ -907,7 +907,7 @@ mod tests {
|
||||||
let psbt = PartiallySignedTransaction {
|
let psbt = PartiallySignedTransaction {
|
||||||
unsigned_tx: Transaction {
|
unsigned_tx: Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![],
|
input: vec![],
|
||||||
output: vec![],
|
output: vec![],
|
||||||
},
|
},
|
||||||
|
@ -977,7 +977,7 @@ mod tests {
|
||||||
let expected = PartiallySignedTransaction {
|
let expected = PartiallySignedTransaction {
|
||||||
unsigned_tx: Transaction {
|
unsigned_tx: Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::from_consensus(1257139),
|
lock_time: absolute::LockTime::from_consensus(1257139),
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(
|
txid: Txid::from_hex(
|
||||||
|
@ -1050,7 +1050,7 @@ mod tests {
|
||||||
// create some values to use in the PSBT
|
// create some values to use in the PSBT
|
||||||
let tx = Transaction {
|
let tx = Transaction {
|
||||||
version: 1,
|
version: 1,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex("e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389").unwrap(),
|
txid: Txid::from_hex("e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389").unwrap(),
|
||||||
|
@ -1237,7 +1237,7 @@ mod tests {
|
||||||
let unserialized = PartiallySignedTransaction {
|
let unserialized = PartiallySignedTransaction {
|
||||||
unsigned_tx: Transaction {
|
unsigned_tx: Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::from_consensus(1257139),
|
lock_time: absolute::LockTime::from_consensus(1257139),
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(
|
txid: Txid::from_hex(
|
||||||
|
@ -1268,7 +1268,7 @@ mod tests {
|
||||||
inputs: vec![Input {
|
inputs: vec![Input {
|
||||||
non_witness_utxo: Some(Transaction {
|
non_witness_utxo: Some(Transaction {
|
||||||
version: 1,
|
version: 1,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(
|
txid: Txid::from_hex(
|
||||||
|
@ -1549,7 +1549,7 @@ mod tests {
|
||||||
let mut unserialized = PartiallySignedTransaction {
|
let mut unserialized = PartiallySignedTransaction {
|
||||||
unsigned_tx: Transaction {
|
unsigned_tx: Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::from_consensus(1257139),
|
lock_time: absolute::LockTime::from_consensus(1257139),
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(
|
txid: Txid::from_hex(
|
||||||
|
@ -1580,7 +1580,7 @@ mod tests {
|
||||||
inputs: vec![Input {
|
inputs: vec![Input {
|
||||||
non_witness_utxo: Some(Transaction {
|
non_witness_utxo: Some(Transaction {
|
||||||
version: 1,
|
version: 1,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(
|
txid: Txid::from_hex(
|
||||||
|
@ -1719,7 +1719,7 @@ mod tests {
|
||||||
let mut t = PartiallySignedTransaction {
|
let mut t = PartiallySignedTransaction {
|
||||||
unsigned_tx: Transaction {
|
unsigned_tx: Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::from_consensus(1257139),
|
lock_time: absolute::LockTime::from_consensus(1257139),
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(
|
txid: Txid::from_hex(
|
||||||
|
@ -1749,7 +1749,7 @@ mod tests {
|
||||||
inputs: vec![Input {
|
inputs: vec![Input {
|
||||||
non_witness_utxo: Some(Transaction {
|
non_witness_utxo: Some(Transaction {
|
||||||
version: 1,
|
version: 1,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(
|
txid: Txid::from_hex(
|
||||||
|
@ -1818,7 +1818,7 @@ mod tests {
|
||||||
|
|
||||||
let unsigned_tx = Transaction {
|
let unsigned_tx = Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn::default(), TxIn::default()],
|
input: vec![TxIn::default(), TxIn::default()],
|
||||||
output: vec![TxOut::default()],
|
output: vec![TxOut::default()],
|
||||||
};
|
};
|
||||||
|
|
|
@ -1001,7 +1001,7 @@ impl<R: DerefMut<Target = Transaction>> SighashCache<R> {
|
||||||
/// use bitcoin::{absolute, Transaction, Script};
|
/// use bitcoin::{absolute, Transaction, Script};
|
||||||
/// use bitcoin::sighash::{EcdsaSighashType, SighashCache};
|
/// use bitcoin::sighash::{EcdsaSighashType, SighashCache};
|
||||||
///
|
///
|
||||||
/// let mut tx_to_sign = Transaction { version: 2, lock_time: absolute::PackedLockTime::ZERO, input: Vec::new(), output: Vec::new() };
|
/// let mut tx_to_sign = Transaction { version: 2, lock_time: absolute::LockTime::ZERO, input: Vec::new(), output: Vec::new() };
|
||||||
/// let input_count = tx_to_sign.input.len();
|
/// let input_count = tx_to_sign.input.len();
|
||||||
///
|
///
|
||||||
/// let mut sig_hasher = SighashCache::new(&mut tx_to_sign);
|
/// let mut sig_hasher = SighashCache::new(&mut tx_to_sign);
|
||||||
|
@ -1075,7 +1075,7 @@ mod tests {
|
||||||
// We need a tx with more inputs than outputs.
|
// We need a tx with more inputs than outputs.
|
||||||
let tx = Transaction {
|
let tx = Transaction {
|
||||||
version: 1,
|
version: 1,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn::default(), TxIn::default()],
|
input: vec![TxIn::default(), TxIn::default()],
|
||||||
output: vec![TxOut::default()],
|
output: vec![TxOut::default()],
|
||||||
};
|
};
|
||||||
|
@ -1264,7 +1264,7 @@ mod tests {
|
||||||
fn test_sighash_errors() {
|
fn test_sighash_errors() {
|
||||||
let dumb_tx = Transaction {
|
let dumb_tx = Transaction {
|
||||||
version: 0,
|
version: 0,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn::default()],
|
input: vec![TxIn::default()],
|
||||||
output: vec![],
|
output: vec![],
|
||||||
};
|
};
|
||||||
|
|
|
@ -162,7 +162,7 @@ fn create_transaction() -> Transaction {
|
||||||
|
|
||||||
Transaction {
|
Transaction {
|
||||||
version: 2,
|
version: 2,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![
|
input: vec![
|
||||||
TxIn {
|
TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
|
|
|
@ -223,7 +223,7 @@ fn serde_regression_public_key() {
|
||||||
fn serde_regression_psbt() {
|
fn serde_regression_psbt() {
|
||||||
let tx = Transaction {
|
let tx = Transaction {
|
||||||
version: 1,
|
version: 1,
|
||||||
lock_time: absolute::PackedLockTime::ZERO,
|
lock_time: absolute::LockTime::ZERO,
|
||||||
input: vec![TxIn {
|
input: vec![TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: Txid::from_hex(
|
txid: Txid::from_hex(
|
||||||
|
|
Loading…
Reference in New Issue