1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
crate::ix!();
/**
| An input of a transaction. It contains
| the location of the previous transaction's
| output that it claims and a signature
| that matches the output's public key.
|
*/
#[derive(Clone,Serialize,Deserialize)]
pub struct TxIn {
pub prevout: OutPoint,
pub script_sig: Script,
pub n_sequence: u32,
/**
| Only serialized through CTransaction
|
*/
pub script_witness: ScriptWitness,
}
impl RecursiveDynamicUsage for TxIn {
fn recursive_dynamic_usage(&self) -> usize {
todo!();
/*
size_t mem = RecursiveDynamicUsage(in.scriptSig) + RecursiveDynamicUsage(in.prevout) + memusage::DynamicUsage(in.scriptWitness.stack);
for (std::vector<std::vector<unsigned char> >::const_iterator it = in.scriptWitness.stack.begin(); it != in.scriptWitness.stack.end(); it++) {
mem += memusage::DynamicUsage(*it);
}
return mem;
*/
}
}
pub mod tx_in {
/**
| Setting nSequence to this value for
| every input in a transaction disables
| nLockTime.
|
*/
pub const SEQUENCE_FINAL: u32 = 0xffffffff;
/**
| Below flags apply in the context of BIP
| 68
|
| If this flag set, CTxIn::nSequence
| is NOT interpreted as a relative lock-time.
|
*/
pub const SEQUENCE_LOCKTIME_DISABLE_FLAG: u32 = 1 << 31;
/**
| If CTxIn::nSequence encodes a relative
| lock-time and this flag is set, the relative
| lock-time has units of 512 seconds,
| otherwise it specifies blocks with
| a granularity of 1.
|
*/
pub const SEQUENCE_LOCKTIME_TYPE_FLAG: u32 = 1 << 22;
/**
| If CTxIn::nSequence encodes a relative
| lock-time, this mask is applied to extract
| that lock-time from the sequence field.
|
*/
pub const SEQUENCE_LOCKTIME_MASK: u32 = 0x0000ffff;
/**
| In order to use the same number of bits
| to encode roughly the same wall-clock
| duration, and because blocks are naturally
| limited to occur every 600s on average,
| the minimum granularity for time-based
| relative lock-time is fixed at 512 seconds.
|
| Converting from CTxIn::nSequence
| to seconds is performed by multiplying
| by 512 = 2^9, or equivalently shifting
| up by 9 bits.
|
*/
pub const SEQUENCE_LOCKTIME_GRANULARITY: i32 = 9;
}
impl Default for TxIn {
fn default() -> Self {
todo!();
/*
nSequence = SEQUENCE_FINAL;
*/
}
}
lazy_static!{
/*
SERIALIZE_METHODS(CTxIn, obj) {
READWRITE(obj.prevout, obj.scriptSig, obj.nSequence);
}
*/
}
impl PartialEq<TxIn> for TxIn {
#[inline] fn eq(&self, other: &TxIn) -> bool {
todo!();
/*
return (a.prevout == b.prevout &&
a.scriptSig == b.scriptSig &&
a.nSequence == b.nSequence);
*/
}
}
impl Eq for TxIn {}
impl TxIn {
pub fn new_from_outpoint(
prevout_in: OutPoint,
script_sig_in: Option<Script>,
n_sequence_in: Option<u32>) -> Self {
let script_sig_in: Script =
script_sig_in.unwrap_or(Script::default());
let n_sequence_in: u32 =
n_sequence_in.unwrap_or(tx_in::SEQUENCE_FINAL);
todo!();
/*
prevout = prevoutIn;
scriptSig = scriptSigIn;
nSequence = nSequenceIn;
*/
}
pub fn new(
hash_prev_tx: u256,
n_out: u32,
script_sig_in: Option<Script>,
n_sequence_in: Option<u32>) -> Self {
let script_sig_in: Script =
script_sig_in.unwrap_or(Script::default());
let n_sequence_in: u32 =
n_sequence_in.unwrap_or(tx_in::SEQUENCE_FINAL);
todo!();
/*
prevout = OutPoint(hashPrevTx, nOut);
scriptSig = scriptSigIn;
nSequence = nSequenceIn;
*/
}
pub fn to_string(&self) -> String {
todo!();
/*
std::string str;
str += "CTxIn(";
str += prevout.ToString();
if (prevout.IsNull())
str += strprintf(", coinbase %s", HexStr(scriptSig));
else
str += strprintf(", scriptSig=%s", HexStr(scriptSig).substr(0, 24));
if (nSequence != tx_in::SEQUENCE_FINAL)
str += strprintf(", nSequence=%u", nSequence);
str += ")";
return str;
*/
}
}