script_sig: ScriptBuf::new(),
sequence: Sequence::MAX,
witness: witness.clone(),
});
}
let value_per_output = (total_value - template.fee) / template.outputs as u64;
assert_eq!(
value_per_output * template.outputs as u64 + template.fee,
total_value
);
let mut tx = Transaction {
version: 0,
lock_time: LockTime::ZERO,
input,
output: (0..template.outputs)
.map(|i| TxOut {
value: template
.output_values
.get(i)
.cloned()
.unwrap_or(value_per_output),
script_pubkey: script::Builder::new().into_script(),
})
.collect(),
};
if let Some(script_pubkey) = template.op_return {
tx.output.insert(
template.op_return_index.unwrap_or(tx.output.len()),
TxOut {
value: 0,
script_pubkey,
},
);
}
self.mempool.push(tx.clone());
tx.txid()
}
pub(crate) fn mempool(&self) -> &[Transaction] {